From 74ae7b8929a7fd3f539fd15efb9533424114a480 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 17 Feb 2015 16:49:14 +0100 Subject: [PATCH 01/11] Add async command system to handle asynchronous operations --- lib/private/backgroundjob/queuedjob.php | 2 +- lib/private/command/asyncbus.php | 70 +++++++++++ lib/private/command/callablejob.php | 22 ++++ lib/private/command/closurejob.php | 24 ++++ lib/private/command/commandjob.php | 26 +++++ lib/private/server.php | 12 ++ lib/public/command/ibus.php | 18 +++ lib/public/command/icommand.php | 16 +++ lib/public/iservercontainer.php | 5 + tests/lib/backgroundjob/dummyjoblist.php | 7 +- tests/lib/command/asyncbus.php | 143 +++++++++++++++++++++++ 11 files changed, 343 insertions(+), 2 deletions(-) create mode 100644 lib/private/command/asyncbus.php create mode 100644 lib/private/command/callablejob.php create mode 100644 lib/private/command/closurejob.php create mode 100644 lib/private/command/commandjob.php create mode 100644 lib/public/command/ibus.php create mode 100644 lib/public/command/icommand.php create mode 100644 tests/lib/command/asyncbus.php diff --git a/lib/private/backgroundjob/queuedjob.php b/lib/private/backgroundjob/queuedjob.php index 884b22a40fb..93dc5a2f063 100644 --- a/lib/private/backgroundjob/queuedjob.php +++ b/lib/private/backgroundjob/queuedjob.php @@ -35,7 +35,7 @@ abstract class QueuedJob extends Job { * @param \OC\Log $logger */ public function execute($jobList, $logger = null) { - $jobList->remove($this); + $jobList->remove($this, $this->argument); parent::execute($jobList, $logger); } } diff --git a/lib/private/command/asyncbus.php b/lib/private/command/asyncbus.php new file mode 100644 index 00000000000..fc9c85acc3f --- /dev/null +++ b/lib/private/command/asyncbus.php @@ -0,0 +1,70 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Command; + +use OCP\Command\IBus; +use OCP\Command\ICommand; +use SuperClosure\Serializer; + +/** + * Asynchronous command bus that uses the background job system as backend + */ +class AsyncBus implements IBus { + /** + * @var \OCP\BackgroundJob\IJobList + */ + private $jobList; + + /** + * @param \OCP\BackgroundJob\IJobList $jobList + */ + function __construct($jobList) { + $this->jobList = $jobList; + } + + /** + * Schedule a command to be fired + * + * @param \OCP\Command\ICommand | callable $command + */ + public function push($command) { + $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command)); + } + + /** + * @param \OCP\Command\ICommand | callable $command + * @return string + */ + private function getJobClass($command) { + if ($command instanceof \Closure) { + return 'OC\Command\ClosureJob'; + } else if (is_callable($command)) { + return 'OC\Command\CallableJob'; + } else if ($command instanceof ICommand) { + return 'OC\Command\CommandJob'; + } else { + throw new \InvalidArgumentException('Invalid command'); + } + } + + /** + * @param \OCP\Command\ICommand | callable $command + * @return string + */ + private function serializeCommand($command) { + if ($command instanceof \Closure) { + $serializer = new Serializer(); + return $serializer->serialize($command); + } else if (is_callable($command) or $command instanceof ICommand) { + return serialize($command); + } else { + throw new \InvalidArgumentException('Invalid command'); + } + } +} diff --git a/lib/private/command/callablejob.php b/lib/private/command/callablejob.php new file mode 100644 index 00000000000..6b755d615e6 --- /dev/null +++ b/lib/private/command/callablejob.php @@ -0,0 +1,22 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Command; + +use OC\BackgroundJob\QueuedJob; + +class CallableJob extends QueuedJob { + protected function run($serializedCallable) { + $callable = unserialize($serializedCallable); + if (is_callable($callable)) { + $callable(); + } else { + throw new \InvalidArgumentException('Invalid serialized callable'); + } + } +} diff --git a/lib/private/command/closurejob.php b/lib/private/command/closurejob.php new file mode 100644 index 00000000000..abba120b745 --- /dev/null +++ b/lib/private/command/closurejob.php @@ -0,0 +1,24 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Command; + +use OC\BackgroundJob\QueuedJob; +use SuperClosure\Serializer; + +class ClosureJob extends QueuedJob { + protected function run($serializedCallable) { + $serializer = new Serializer(); + $callable = $serializer->unserialize($serializedCallable); + if (is_callable($callable)) { + $callable(); + } else { + throw new \InvalidArgumentException('Invalid serialized callable'); + } + } +} diff --git a/lib/private/command/commandjob.php b/lib/private/command/commandjob.php new file mode 100644 index 00000000000..b2c7d30ee56 --- /dev/null +++ b/lib/private/command/commandjob.php @@ -0,0 +1,26 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Command; + +use OC\BackgroundJob\QueuedJob; +use OCP\Command\ICommand; + +/** + * Wrap a command in the background job interface + */ +class CommandJob extends QueuedJob { + protected function run($serializedCommand) { + $command = unserialize($serializedCommand); + if ($command instanceof ICommand) { + $command->handle(); + } else { + throw new \InvalidArgumentException('Invalid serialized command'); + } + } +} diff --git a/lib/private/server.php b/lib/private/server.php index f6fa5387e49..ca3a17451ac 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -38,6 +38,7 @@ use OC\AppFramework\Http\Request; use OC\AppFramework\Db\Db; use OC\AppFramework\Utility\SimpleContainer; use OC\Cache\UserCache; +use OC\Command\AsyncBus; use OC\Diagnostics\NullQueryLogger; use OC\Diagnostics\EventLogger; use OC\Diagnostics\QueryLogger; @@ -291,6 +292,10 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('IniWrapper', function ($c) { return new IniGetWrapper(); }); + $this->registerService('AsyncCommandBus', function (Server $c) { + $jobList = $c->getJobList(); + return new AsyncBus($jobList); + }); $this->registerService('TrustedDomainHelper', function ($c) { return new TrustedDomainHelper($this->getConfig()); }); @@ -777,6 +782,13 @@ class Server extends SimpleContainer implements IServerContainer { return $this->query('IniWrapper'); } + /** + * @return \OCP\Command\IBus + */ + function getAsyncCommandBus(){ + return $this->query('AsyncCommandBus'); + } + /** * Get the trusted domain helper * diff --git a/lib/public/command/ibus.php b/lib/public/command/ibus.php new file mode 100644 index 00000000000..707f8fd072d --- /dev/null +++ b/lib/public/command/ibus.php @@ -0,0 +1,18 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Command; + +interface IBus { + /** + * Schedule a command to be fired + * + * @param \OCP\Command\ICommand | callable $command + */ + public function push($command); +} diff --git a/lib/public/command/icommand.php b/lib/public/command/icommand.php new file mode 100644 index 00000000000..6de61258a41 --- /dev/null +++ b/lib/public/command/icommand.php @@ -0,0 +1,16 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Command; + +interface ICommand { + /** + * Run the command + */ + public function handle(); +} diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index f2806529a4c..3b73426d9fb 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -317,4 +317,9 @@ interface IServerContainer { * @return \bantu\IniGetWrapper\IniGetWrapper */ function getIniWrapper(); + + /** + * @return \OCP\Command\IBus + */ + function getAsyncCommandBus(); } diff --git a/tests/lib/backgroundjob/dummyjoblist.php b/tests/lib/backgroundjob/dummyjoblist.php index 7801269b27e..6cc690fd553 100644 --- a/tests/lib/backgroundjob/dummyjoblist.php +++ b/tests/lib/backgroundjob/dummyjoblist.php @@ -21,13 +21,18 @@ class DummyJobList extends \OC\BackgroundJob\JobList { private $last = 0; - public function __construct(){} + public function __construct() { + } /** * @param \OC\BackgroundJob\Job|string $job * @param mixed $argument */ public function add($job, $argument = null) { + if (is_string($job)) { + /** @var \OC\BackgroundJob\Job $job */ + $job = new $job; + } $job->setArgument($argument); if (!$this->has($job, null)) { $this->jobs[] = $job; diff --git a/tests/lib/command/asyncbus.php b/tests/lib/command/asyncbus.php new file mode 100644 index 00000000000..030c416953d --- /dev/null +++ b/tests/lib/command/asyncbus.php @@ -0,0 +1,143 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Command; + +use OCP\Command\ICommand; +use Test\BackgroundJob\DummyJobList; +use Test\TestCase; + +class SimpleCommand implements ICommand { + public function handle() { + AsyncBus::$lastCommand = 'SimpleCommand'; + } +} + +class StateFullCommand implements ICommand { + private $state; + + function __construct($state) { + $this->state = $state; + } + + public function handle() { + AsyncBus::$lastCommand = $this->state; + } +} + +function basicFunction() { + AsyncBus::$lastCommand = 'function'; +} + +class AsyncBus extends TestCase { + /** + * Basic way to check output from a command + * + * @var string + */ + public static $lastCommand; + + /** + * @var \OCP\BackgroundJob\IJobList + */ + private $jobList; + + /** + * @var \OCP\Command\IBus + */ + private $bus; + + public static function DummyCommand() { + self::$lastCommand = 'static'; + } + + public function setUp() { + $this->jobList = new DummyJobList(); + $this->bus = new \OC\Command\AsyncBus($this->jobList); + self::$lastCommand = ''; + } + + public function testSimpleCommand() { + $command = new SimpleCommand(); + $this->bus->push($command); + $this->runJobs(); + $this->assertEquals('SimpleCommand', self::$lastCommand); + } + + public function testStateFullCommand() { + $command = new StateFullCommand('foo'); + $this->bus->push($command); + $this->runJobs(); + $this->assertEquals('foo', self::$lastCommand); + } + + public function testStaticCallable() { + $this->bus->push(['\Test\Command\AsyncBus', 'DummyCommand']); + $this->runJobs(); + $this->assertEquals('static', self::$lastCommand); + } + + public function testMemberCallable() { + $command = new StateFullCommand('bar'); + $this->bus->push([$command, 'handle']); + $this->runJobs(); + $this->assertEquals('bar', self::$lastCommand); + } + + public function testFunctionCallable() { + $this->bus->push('\Test\Command\BasicFunction'); + $this->runJobs(); + $this->assertEquals('function', self::$lastCommand); + } + + public function testClosure() { + $this->bus->push(function () { + AsyncBus::$lastCommand = 'closure'; + }); + $this->runJobs(); + $this->assertEquals('closure', self::$lastCommand); + } + + public function testClosureSelf() { + $this->bus->push(function () { + self::$lastCommand = 'closure-self'; + }); + $this->runJobs(); + $this->assertEquals('closure-self', self::$lastCommand); + } + + private function privateMethod() { + self::$lastCommand = 'closure-this'; + } + + public function testClosureThis() { + $this->bus->push(function () { + $this->privateMethod(); + }); + $this->runJobs(); + $this->assertEquals('closure-this', self::$lastCommand); + } + + public function testClosureBind() { + $state = 'bar'; + $this->bus->push(function () use ($state) { + self::$lastCommand = 'closure-' . $state; + }); + $this->runJobs(); + $this->assertEquals('closure-bar', self::$lastCommand); + } + + + private function runJobs() { + $jobs = $this->jobList->getAll(); + foreach ($jobs as $job) { + $job->execute($this->jobList); + } + } +} From 6fc0eb02360dc9f997bdffd0a4efeb25425ddd75 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 17 Feb 2015 16:49:45 +0100 Subject: [PATCH 02/11] expand cron argument column to 2048 --- db_structure.xml | 2 +- version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db_structure.xml b/db_structure.xml index eb6540047d6..9f8cfdce4c5 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -979,7 +979,7 @@ text true - 256 + 2048 diff --git a/version.php b/version.php index f122170df57..7f18cbbc6aa 100644 --- a/version.php +++ b/version.php @@ -23,7 +23,7 @@ // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version=array(8, 0, 0, 9); +$OC_Version=array(8, 0, 0, 10); // The human readable string $OC_VersionString='8.0'; From c2a7fff4f6f79e37aedf299fd01727efd9082450 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 17 Feb 2015 16:52:09 +0100 Subject: [PATCH 03/11] throw an exception when trying to push a background job that wont fit in the table otherwise it will lead to failures in json decode and unexpected and hard to debug issues when running the job --- lib/private/backgroundjob/joblist.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php index 4011572f62e..95a7b125801 100644 --- a/lib/private/backgroundjob/joblist.php +++ b/lib/private/backgroundjob/joblist.php @@ -57,6 +57,9 @@ class JobList implements IJobList { $class = $job; } $argument = json_encode($argument); + if (strlen($argument) > 2048) { + throw new \InvalidArgumentException('Background job arguments cant exceed 2048 characters (json encoded'); + } $query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)'); $query->execute(array($class, $argument)); } From be930e338d6ea2be40889e8c76b31167b3599540 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 17 Feb 2015 16:52:39 +0100 Subject: [PATCH 04/11] add superclosure to thirdparty --- 3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty b/3rdparty index 588b1308f4a..fa00c2f1b34 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 588b1308f4abf58acb3bb8519f6952d9890cca89 +Subproject commit fa00c2f1b348441cd777370098d266aa78a90833 From 8213f8d67d5a73b43b871d305e911e22b4144f79 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 23 Feb 2015 15:25:59 +0100 Subject: [PATCH 05/11] Allow apps to determine which commands should be run synchronous based on traints --- lib/private/command/asyncbus.php | 59 +++++++++++++++++++++++++++++++- lib/public/command/ibus.php | 7 ++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/lib/private/command/asyncbus.php b/lib/private/command/asyncbus.php index fc9c85acc3f..084842fa6f1 100644 --- a/lib/private/command/asyncbus.php +++ b/lib/private/command/asyncbus.php @@ -21,6 +21,13 @@ class AsyncBus implements IBus { */ private $jobList; + /** + * List of traits for command which require sync execution + * + * @var string[] + */ + private $syncTraits = []; + /** * @param \OCP\BackgroundJob\IJobList $jobList */ @@ -34,7 +41,31 @@ class AsyncBus implements IBus { * @param \OCP\Command\ICommand | callable $command */ public function push($command) { - $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command)); + if ($this->canRunAsync($command)) { + $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command)); + } else { + $this->runCommand($command); + } + } + + /** + * Require all commands using a trait to be run synchronous + * + * @param string $trait + */ + public function requireSync($trait) { + $this->syncTraits[] = trim($trait, '\\'); + } + + /** + * @param \OCP\Command\ICommand | callable $command + */ + private function runCommand($command) { + if ($command instanceof ICommand) { + $command->handle(); + } else { + $command(); + } } /** @@ -67,4 +98,30 @@ class AsyncBus implements IBus { throw new \InvalidArgumentException('Invalid command'); } } + + /** + * @param \OCP\Command\ICommand | callable $command + * @return bool + */ + private function canRunAsync($command) { + $traits = $this->getTraits($command); + foreach ($traits as $trait) { + if (array_search($trait, $this->syncTraits) !== false) { + return false; + } + } + return true; + } + + /** + * @param \OCP\Command\ICommand | callable $command + * @return string[] + */ + private function getTraits($command) { + if ($command instanceof ICommand) { + return class_uses($command); + } else { + return []; + } + } } diff --git a/lib/public/command/ibus.php b/lib/public/command/ibus.php index 707f8fd072d..bbb89ee04e6 100644 --- a/lib/public/command/ibus.php +++ b/lib/public/command/ibus.php @@ -15,4 +15,11 @@ interface IBus { * @param \OCP\Command\ICommand | callable $command */ public function push($command); + + /** + * Require all commands using a trait to be run synchronous + * + * @param string $trait + */ + public function requireSync($trait); } From a39c7bf4643fdaa17e62ea503fede1c2f4a30d35 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 23 Feb 2015 15:26:12 +0100 Subject: [PATCH 06/11] Add FileAccess trait for commands --- lib/private/command/fileaccess.php | 18 ++++++++++++++++++ tests/lib/command/asyncbus.php | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 lib/private/command/fileaccess.php diff --git a/lib/private/command/fileaccess.php b/lib/private/command/fileaccess.php new file mode 100644 index 00000000000..5de00862fac --- /dev/null +++ b/lib/private/command/fileaccess.php @@ -0,0 +1,18 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Command; + +use OCP\IUser; + +trait FileAccess { + protected function getUserFolder(IUser $user) { + \OC_Util::setupFS($user->getUID()); + return \OC::$server->getUserFolder($user->getUID()); + } +} diff --git a/tests/lib/command/asyncbus.php b/tests/lib/command/asyncbus.php index 030c416953d..d22ce34d839 100644 --- a/tests/lib/command/asyncbus.php +++ b/tests/lib/command/asyncbus.php @@ -9,6 +9,7 @@ namespace Test\Command; +use OC\Command\FileAccess; use OCP\Command\ICommand; use Test\BackgroundJob\DummyJobList; use Test\TestCase; @@ -31,6 +32,14 @@ class StateFullCommand implements ICommand { } } +class FilesystemCommand implements ICommand { + use FileAccess; + + public function handle() { + AsyncBus::$lastCommand = 'FileAccess'; + } +} + function basicFunction() { AsyncBus::$lastCommand = 'function'; } @@ -133,6 +142,22 @@ class AsyncBus extends TestCase { $this->assertEquals('closure-bar', self::$lastCommand); } + public function testFileFileAccessCommand() { + $this->bus->push(new FilesystemCommand()); + $this->assertEquals('', self::$lastCommand); + $this->runJobs(); + $this->assertEquals('FileAccess', self::$lastCommand); + } + + public function testFileFileAccessCommandSync() { + $this->bus->requireSync('\OC\Command\FileAccess'); + $this->bus->push(new FilesystemCommand()); + $this->assertEquals('FileAccess', self::$lastCommand); + self::$lastCommand = ''; + $this->runJobs(); + $this->assertEquals('', self::$lastCommand); + } + private function runJobs() { $jobs = $this->jobList->getAll(); From 27d047979d2fd5e77ef14386dd575607c4041990 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 23 Feb 2015 15:27:47 +0100 Subject: [PATCH 07/11] require command that do file access to be run sync when encryption is enabled --- apps/files_encryption/appinfo/app.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index 7cc42916282..c547a0c5e19 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -50,6 +50,8 @@ if (!OC_Config::getValue('maintenance', false)) { OCP\User::logout(); } +\OC::$server->getAsyncCommandBus()->requireSync('\OC\Command\FileAccess'); + // Register settings scripts OCP\App::registerAdmin('files_encryption', 'settings-admin'); OCP\App::registerPersonal('files_encryption', 'settings-personal'); From 9873ab20afde7def037dcee2e00921d01e52ae82 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 23 Feb 2015 15:42:18 +0100 Subject: [PATCH 08/11] prevent phpunit from messing with the bound $this --- tests/lib/command/asyncbus.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/lib/command/asyncbus.php b/tests/lib/command/asyncbus.php index d22ce34d839..183eaa29c37 100644 --- a/tests/lib/command/asyncbus.php +++ b/tests/lib/command/asyncbus.php @@ -10,6 +10,7 @@ namespace Test\Command; use OC\Command\FileAccess; +use OCP\Command\IBus; use OCP\Command\ICommand; use Test\BackgroundJob\DummyJobList; use Test\TestCase; @@ -44,6 +45,19 @@ function basicFunction() { AsyncBus::$lastCommand = 'function'; } +// clean class to prevent phpunit putting closure in $this +class ThisClosureTest { + private function privateMethod() { + AsyncBus::$lastCommand = 'closure-this'; + } + + public function test(IBus $bus) { + $bus->push(function () { + $this->privateMethod(); + }); + } +} + class AsyncBus extends TestCase { /** * Basic way to check output from a command @@ -121,14 +135,11 @@ class AsyncBus extends TestCase { $this->assertEquals('closure-self', self::$lastCommand); } - private function privateMethod() { - self::$lastCommand = 'closure-this'; - } public function testClosureThis() { - $this->bus->push(function () { - $this->privateMethod(); - }); + // clean class to prevent phpunit putting closure in $this + $test = new ThisClosureTest(); + $test->test($this->bus); $this->runJobs(); $this->assertEquals('closure-this', self::$lastCommand); } From bf65b1f18b4737f02b1f55e923b718a10851d5cf Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 23 Feb 2015 17:54:32 +0100 Subject: [PATCH 09/11] Rename getAsyncCommandBus to getCommandBus --- apps/files_encryption/appinfo/app.php | 2 +- lib/private/server.php | 2 +- lib/public/iservercontainer.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index c547a0c5e19..440f5cf78e0 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -50,7 +50,7 @@ if (!OC_Config::getValue('maintenance', false)) { OCP\User::logout(); } -\OC::$server->getAsyncCommandBus()->requireSync('\OC\Command\FileAccess'); +\OC::$server->getCommandBus()->requireSync('\OC\Command\FileAccess'); // Register settings scripts OCP\App::registerAdmin('files_encryption', 'settings-admin'); diff --git a/lib/private/server.php b/lib/private/server.php index ca3a17451ac..8b6a0874ab8 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -785,7 +785,7 @@ class Server extends SimpleContainer implements IServerContainer { /** * @return \OCP\Command\IBus */ - function getAsyncCommandBus(){ + function getCommandBus(){ return $this->query('AsyncCommandBus'); } diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 3b73426d9fb..6714a5265f7 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -321,5 +321,5 @@ interface IServerContainer { /** * @return \OCP\Command\IBus */ - function getAsyncCommandBus(); + function getCommandBus(); } From 3cf237df67008da8878fff28a2d6b4ad77288ad9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 23 Feb 2015 18:07:13 +0100 Subject: [PATCH 10/11] set max argument length to 4000 --- db_structure.xml | 2 +- lib/private/backgroundjob/joblist.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db_structure.xml b/db_structure.xml index 9f8cfdce4c5..142661ba427 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -979,7 +979,7 @@ text true - 2048 + 4000 diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php index 95a7b125801..ded269dfe59 100644 --- a/lib/private/backgroundjob/joblist.php +++ b/lib/private/backgroundjob/joblist.php @@ -57,7 +57,7 @@ class JobList implements IJobList { $class = $job; } $argument = json_encode($argument); - if (strlen($argument) > 2048) { + if (strlen($argument) > 4000) { throw new \InvalidArgumentException('Background job arguments cant exceed 2048 characters (json encoded'); } $query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)'); From 27fde80ee6bb88fcf4a1c8943829fe6360a12575 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 26 Feb 2015 15:07:51 +0100 Subject: [PATCH 11/11] fix exception message --- lib/private/backgroundjob/joblist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php index ded269dfe59..f7cc24217e6 100644 --- a/lib/private/backgroundjob/joblist.php +++ b/lib/private/backgroundjob/joblist.php @@ -58,7 +58,7 @@ class JobList implements IJobList { } $argument = json_encode($argument); if (strlen($argument) > 4000) { - throw new \InvalidArgumentException('Background job arguments cant exceed 2048 characters (json encoded'); + throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)'); } $query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)'); $query->execute(array($class, $argument));