aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.htaccess1
-rw-r--r--apps/dav/lib/comments/commentnode.php1
-rw-r--r--apps/dav/lib/comments/commentsplugin.php15
-rw-r--r--apps/dav/tests/unit/comments/commentnode.php3
-rw-r--r--apps/dav/tests/unit/comments/commentsplugin.php25
-rw-r--r--core/js/systemtags/systemtagsinputfield.js11
-rw-r--r--cron.php13
-rw-r--r--lib/private/backgroundjob/joblist.php2
-rw-r--r--lib/private/share20/defaultshareprovider.php18
-rw-r--r--lib/public/backgroundjob.php38
-rw-r--r--lib/public/backgroundjob/ijoblist.php2
-rw-r--r--tests/lib/share20/defaultshareprovidertest.php114
12 files changed, 128 insertions, 115 deletions
diff --git a/.htaccess b/.htaccess
index 1b516789563..4a4adce144c 100644
--- a/.htaccess
+++ b/.htaccess
@@ -59,6 +59,7 @@
RewriteCond %{REQUEST_FILENAME} !/status.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
+ RewriteCond %{REQUEST_FILENAME} !/updater/
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
RewriteRule .* index.php [PT,E=PATH_INFO:$1]
</IfModule>
diff --git a/apps/dav/lib/comments/commentnode.php b/apps/dav/lib/comments/commentnode.php
index 376c1bf3274..eb26e350a42 100644
--- a/apps/dav/lib/comments/commentnode.php
+++ b/apps/dav/lib/comments/commentnode.php
@@ -170,7 +170,6 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties {
function propPatch(PropPatch $propPatch) {
// other properties than 'message' are read only
$propPatch->handle('{'.self::NS_OWNCLOUD.'}message', [$this, 'updateComment']);
- $propPatch->commit();
}
/**
diff --git a/apps/dav/lib/comments/commentsplugin.php b/apps/dav/lib/comments/commentsplugin.php
index 2f9b7bab59f..7e227fd2914 100644
--- a/apps/dav/lib/comments/commentsplugin.php
+++ b/apps/dav/lib/comments/commentsplugin.php
@@ -43,6 +43,7 @@ class CommentsPlugin extends ServerPlugin {
// namespace
const NS_OWNCLOUD = 'http://owncloud.org/ns';
+ const REPORT_NAME = '{http://owncloud.org/ns}filter-comments';
const REPORT_PARAM_LIMIT = '{http://owncloud.org/ns}limit';
const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset';
const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime';
@@ -125,6 +126,18 @@ class CommentsPlugin extends ServerPlugin {
}
/**
+ * Returns a list of reports this plugin supports.
+ *
+ * This will be used in the {DAV:}supported-report-set property.
+ *
+ * @param string $uri
+ * @return array
+ */
+ public function getSupportedReportSet($uri) {
+ return [self::REPORT_NAME];
+ }
+
+ /**
* REPORT operations to look for comments
*
* @param string $reportName
@@ -136,7 +149,7 @@ class CommentsPlugin extends ServerPlugin {
*/
public function onReport($reportName, $report, $uri) {
$node = $this->server->tree->getNodeForPath($uri);
- if(!$node instanceof EntityCollection) {
+ if(!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) {
throw new ReportNotSupported();
}
$args = ['limit' => 0, 'offset' => 0, 'datetime' => null];
diff --git a/apps/dav/tests/unit/comments/commentnode.php b/apps/dav/tests/unit/comments/commentnode.php
index e1498459ce8..aa75e35d665 100644
--- a/apps/dav/tests/unit/comments/commentnode.php
+++ b/apps/dav/tests/unit/comments/commentnode.php
@@ -114,9 +114,6 @@ class CommentsNode extends \Test\TestCase {
->method('handle')
->with('{http://owncloud.org/ns}message');
- $propPatch->expects($this->once())
- ->method('commit');
-
$this->node->propPatch($propPatch);
}
diff --git a/apps/dav/tests/unit/comments/commentsplugin.php b/apps/dav/tests/unit/comments/commentsplugin.php
index 391c79d156a..bd0b56fc650 100644
--- a/apps/dav/tests/unit/comments/commentsplugin.php
+++ b/apps/dav/tests/unit/comments/commentsplugin.php
@@ -517,7 +517,26 @@ class CommentsPlugin extends \Test\TestCase {
->will($this->returnValue($path));
$this->plugin->initialize($this->server);
- $this->plugin->onReport('', [], '/' . $path);
+ $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, [], '/' . $path);
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\ReportNotSupported
+ */
+ public function testOnReportInvalidReportName() {
+ $path = 'comments/files/42';
+
+ $this->tree->expects($this->any())
+ ->method('getNodeForPath')
+ ->with('/' . $path)
+ ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+
+ $this->server->expects($this->any())
+ ->method('getRequestUri')
+ ->will($this->returnValue($path));
+ $this->plugin->initialize($this->server);
+
+ $this->plugin->onReport('{whoever}whatever', [], '/' . $path);
}
public function testOnReportDateTimeEmpty() {
@@ -572,7 +591,7 @@ class CommentsPlugin extends \Test\TestCase {
$this->server->httpResponse = $response;
$this->plugin->initialize($this->server);
- $this->plugin->onReport('', $parameters, '/' . $path);
+ $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
}
public function testOnReport() {
@@ -627,7 +646,7 @@ class CommentsPlugin extends \Test\TestCase {
$this->server->httpResponse = $response;
$this->plugin->initialize($this->server);
- $this->plugin->onReport('', $parameters, '/' . $path);
+ $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
}
diff --git a/core/js/systemtags/systemtagsinputfield.js b/core/js/systemtags/systemtagsinputfield.js
index 461b52d88e9..48fc98c6188 100644
--- a/core/js/systemtags/systemtagsinputfield.js
+++ b/core/js/systemtags/systemtagsinputfield.js
@@ -133,7 +133,7 @@
cid: this.cid,
name: oldName,
deleteTooltip: t('core', 'Delete'),
- renameLabel: t('core', 'Rename'),
+ renameLabel: t('core', 'Rename')
}));
$item.find('.label').after($renameForm);
$item.find('.label, .systemtags-actions').addClass('hidden');
@@ -160,7 +160,7 @@
var $item = $form.closest('.systemtags-item');
var tagId = $item.attr('data-id');
var tagModel = this.collection.get(tagId);
- var newName = $(ev.target).find('input').val();
+ var newName = $(ev.target).find('input').val().trim();
if (newName && newName !== tagModel.get('name')) {
tagModel.save({'name': newName});
// TODO: spinner, and only change text after finished saving
@@ -204,7 +204,7 @@
// newly created tag, check if existing
// create a new tag
tag = this.collection.create({
- name: e.object.name,
+ name: e.object.name.trim(),
userVisible: true,
userAssignable: true
}, {
@@ -219,7 +219,7 @@
self.collection.fetch({
success: function(collection) {
// find the tag in the collection
- var model = collection.where({name: e.object.name, userVisible: true, userAssignable: true});
+ var model = collection.where({name: e.object.name.trim(), userVisible: true, userAssignable: true});
if (model.length) {
model = model[0];
// the tag already exists or was already assigned,
@@ -260,7 +260,7 @@
var self = this;
this.collection.fetch({
success: function(collection) {
- var tagModels = collection.filterByName(query.term);
+ var tagModels = collection.filterByName(query.term.trim());
if (!self._isAdmin) {
tagModels = _.filter(tagModels, function(tagModel) {
return tagModel.get('userAssignable');
@@ -319,6 +319,7 @@
* @return {Object} dummy tag
*/
_createSearchChoice: function(term) {
+ term = term.trim();
if (this.collection.filterByName(term).length) {
return;
}
diff --git a/cron.php b/cron.php
index afcf47cb0e9..73f233e1350 100644
--- a/cron.php
+++ b/cron.php
@@ -130,11 +130,20 @@ try {
// Work
$jobList = \OC::$server->getJobList();
- $jobs = $jobList->getAll();
- foreach ($jobs as $job) {
+
+ $executedJobs = [];
+ while ($job = $jobList->getNext()) {
+ if (isset($executedJobs[$job->getId()])) {
+ break;
+ }
+
$logger->debug('Run job with ID ' . $job->getId(), ['app' => 'cron']);
$job->execute($jobList, $logger);
$logger->debug('Finished job with ID ' . $job->getId(), ['app' => 'cron']);
+
+ $jobList->setLastJob($job);
+ $executedJobs[$job->getId()] = true;
+ unset($job);
}
// unlock the file
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index cc9be574807..2920cb5214c 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -139,6 +139,8 @@ class JobList implements IJobList {
* get all jobs in the list
*
* @return IJob[]
+ * @deprecated 9.0.0 - This method is dangerous since it can cause load and
+ * memory problems when creating too many instances.
*/
public function getAll() {
$query = $this->connection->getQueryBuilder();
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php
index baa12d6c933..35b3f71f3de 100644
--- a/lib/private/share20/defaultshareprovider.php
+++ b/lib/private/share20/defaultshareprovider.php
@@ -288,21 +288,21 @@ class DefaultShareProvider implements IShareProvider {
* Delete a share
*
* @param \OCP\Share\IShare $share
- * @throws BackendError
*/
public function delete(\OCP\Share\IShare $share) {
- // Fetch share to make sure it exists
- $share = $this->getShareById($share->getId());
-
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())));
-
- try {
- $qb->execute();
- } catch (\Exception $e) {
- throw new BackendError();
+
+ /*
+ * If the share is a group share delete all possible
+ * user defined groups shares.
+ */
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())));
}
+
+ $qb->execute();
}
/**
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php
index c8acb7e538b..cc76506758b 100644
--- a/lib/public/backgroundjob.php
+++ b/lib/public/backgroundjob.php
@@ -34,7 +34,6 @@
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
-use \OC\BackgroundJob\JobList;
/**
* This class provides functions to register backgroundjobs in ownCloud
@@ -115,16 +114,7 @@ class BackgroundJob {
* @since 4.5.0
*/
static public function allRegularTasks() {
- $jobList = \OC::$server->getJobList();
- $allJobs = $jobList->getAll();
- $regularJobs = array();
- foreach ($allJobs as $job) {
- if ($job instanceof RegularLegacyJob) {
- $key = implode('-', $job->getArgument());
- $regularJobs[$key] = $job->getArgument();
- }
- }
- return $regularJobs;
+ return [];
}
/**
@@ -146,17 +136,7 @@ class BackgroundJob {
* @since 4.5.0
*/
public static function allQueuedTasks() {
- $jobList = \OC::$server->getJobList();
- $allJobs = $jobList->getAll();
- $queuedJobs = array();
- foreach ($allJobs as $job) {
- if ($job instanceof QueuedLegacyJob) {
- $queuedJob = $job->getArgument();
- $queuedJob['id'] = $job->getId();
- $queuedJobs[] = $queuedJob;
- }
- }
- return $queuedJobs;
+ return [];
}
/**
@@ -167,19 +147,7 @@ class BackgroundJob {
* @since 4.5.0
*/
public static function queuedTaskWhereAppIs($app) {
- $jobList = \OC::$server->getJobList();
- $allJobs = $jobList->getAll();
- $queuedJobs = array();
- foreach ($allJobs as $job) {
- if ($job instanceof QueuedLegacyJob) {
- $queuedJob = $job->getArgument();
- $queuedJob['id'] = $job->getId();
- if ($queuedJob['app'] === $app) {
- $queuedJobs[] = $queuedJob;
- }
- }
- }
- return $queuedJobs;
+ return [];
}
/**
diff --git a/lib/public/backgroundjob/ijoblist.php b/lib/public/backgroundjob/ijoblist.php
index 13775457edd..5a76ce1ba26 100644
--- a/lib/public/backgroundjob/ijoblist.php
+++ b/lib/public/backgroundjob/ijoblist.php
@@ -64,6 +64,8 @@ interface IJobList {
*
* @return \OCP\BackgroundJob\IJob[]
* @since 7.0.0
+ * @deprecated 9.0.0 - This method is dangerous since it can cause load and
+ * memory problems when creating too many instances.
*/
public function getAll();
diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php
index eb3be0bde14..45f2bedcb63 100644
--- a/tests/lib/share20/defaultshareprovidertest.php
+++ b/tests/lib/share20/defaultshareprovidertest.php
@@ -330,19 +330,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->method('getId')->willReturn($id);
$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
- ->setConstructorArgs([
- $this->dbConn,
- $this->userManager,
- $this->groupManager,
- $this->rootFolder,
- ]
- )
- ->setMethods(['getShareById'])
- ->getMock();
- $provider
- ->expects($this->once())
- ->method('getShareById')
- ->willReturn($share);
+ ->setConstructorArgs([
+ $this->dbConn,
+ $this->userManager,
+ $this->groupManager,
+ $this->rootFolder,
+ ])
+ ->setMethods(['getShareById'])
+ ->getMock();
$provider->delete($share);
@@ -357,53 +352,60 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEmpty($result);
}
- /**
- * @expectedException \OC\Share20\Exception\BackendError
- */
- public function testDeleteFails() {
+ public function testDeleteGroupShareWithUserGroupShares() {
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->insert('share')
+ ->values([
+ 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_with' => $qb->expr()->literal('sharedWith'),
+ 'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
+ 'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
+ 'permissions' => $qb->expr()->literal(13),
+ ]);
+ $this->assertEquals(1, $qb->execute());
+ $id = $qb->getLastInsertId();
+
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->insert('share')
+ ->values([
+ 'share_type' => $qb->expr()->literal(2),
+ 'share_with' => $qb->expr()->literal('sharedWithUser'),
+ 'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
+ 'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
+ 'permissions' => $qb->expr()->literal(13),
+ 'parent' => $qb->expr()->literal($id),
+ ]);
+ $this->assertEquals(1, $qb->execute());
+
$share = $this->getMock('OCP\Share\IShare');
- $share
- ->method('getId')
- ->willReturn(42);
-
- $expr = $this->getMock('OCP\DB\QueryBuilder\IExpressionBuilder');
- $qb = $this->getMock('OCP\DB\QueryBuilder\IQueryBuilder');
- $qb->expects($this->once())
- ->method('delete')
- ->will($this->returnSelf());
- $qb->expects($this->once())
- ->method('expr')
- ->willReturn($expr);
- $qb->expects($this->once())
- ->method('where')
- ->will($this->returnSelf());
- $qb->expects($this->once())
- ->method('execute')
- ->will($this->throwException(new \Exception));
-
- $db = $this->getMock('OCP\IDBConnection');
- $db->expects($this->once())
- ->method('getQueryBuilder')
- ->with()
- ->willReturn($qb);
+ $share->method('getId')->willReturn($id);
+ $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
- ->setConstructorArgs([
- $db,
- $this->userManager,
- $this->groupManager,
- $this->rootFolder,
- ]
- )
- ->setMethods(['getShareById'])
- ->getMock();
- $provider
- ->expects($this->once())
- ->method('getShareById')
- ->with(42)
- ->willReturn($share);
-
+ ->setConstructorArgs([
+ $this->dbConn,
+ $this->userManager,
+ $this->groupManager,
+ $this->rootFolder,
+ ])
+ ->setMethods(['getShareById'])
+ ->getMock();
+
$provider->delete($share);
+
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->select('*')
+ ->from('share');
+
+ $cursor = $qb->execute();
+ $result = $cursor->fetchAll();
+ $cursor->closeCursor();
+
+ $this->assertEmpty($result);
}
public function testGetChildren() {