From 3ed6ed3c3674bfc60bcd2fc64edea1820f1be9d0 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 24 Mar 2015 10:02:48 +0100 Subject: Force test cases using background commands to handle setting up the filesystem --- lib/private/command/fileaccess.php | 6 +++++- lib/private/command/queuebus.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/private/command') diff --git a/lib/private/command/fileaccess.php b/lib/private/command/fileaccess.php index 5de00862fac..b08fb1825ea 100644 --- a/lib/private/command/fileaccess.php +++ b/lib/private/command/fileaccess.php @@ -11,8 +11,12 @@ namespace OC\Command; use OCP\IUser; trait FileAccess { - protected function getUserFolder(IUser $user) { + protected function setupFS(IUser $user){ \OC_Util::setupFS($user->getUID()); + } + + protected function getUserFolder(IUser $user) { + $this->setupFS($user); return \OC::$server->getUserFolder($user->getUID()); } } diff --git a/lib/private/command/queuebus.php b/lib/private/command/queuebus.php index 29c769e0107..953479086ca 100644 --- a/lib/private/command/queuebus.php +++ b/lib/private/command/queuebus.php @@ -15,7 +15,7 @@ class QueueBus implements IBus { /** * @var (ICommand|callable)[] */ - private $queue; + private $queue = []; /** * Schedule a command to be fired -- cgit v1.2.3 From 268f249e8d98e8b91f51f4d39cfc060efbd5caab Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 24 Mar 2015 10:46:29 +0100 Subject: ensure commands can be serialized in unit tests --- lib/private/command/queuebus.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/private/command') diff --git a/lib/private/command/queuebus.php b/lib/private/command/queuebus.php index 953479086ca..e5604eb1fef 100644 --- a/lib/private/command/queuebus.php +++ b/lib/private/command/queuebus.php @@ -39,7 +39,10 @@ class QueueBus implements IBus { */ private function runCommand($command) { if ($command instanceof ICommand) { - $command->handle(); + // ensure the command can be serialized + $serialized = serialize($command); + $unserialized = unserialize($serialized); + $unserialized->handle(); } else { $command(); } -- cgit v1.2.3 From 8c903c100ff6517806e5328ef56d615f5c93490b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 24 Mar 2015 10:48:21 +0100 Subject: check limit of serialized command in unit tests --- lib/private/command/queuebus.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/private/command') diff --git a/lib/private/command/queuebus.php b/lib/private/command/queuebus.php index e5604eb1fef..78712ebd9cd 100644 --- a/lib/private/command/queuebus.php +++ b/lib/private/command/queuebus.php @@ -41,6 +41,9 @@ class QueueBus implements IBus { if ($command instanceof ICommand) { // ensure the command can be serialized $serialized = serialize($command); + if(strlen($serialized) > 4000) { + throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)'); + } $unserialized = unserialize($serialized); $unserialized->handle(); } else { -- cgit v1.2.3