summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-26 19:55:13 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-26 19:55:13 +0100
commitc8c722bc6de3a58e10ba42a55a178d3ba9308bae (patch)
tree6d62aa73cc72596b1bf385cca20e4d8bd9563525 /lib
parent3e57e9d3e557100ba0b51f08a3de7a7e8f79f4bd (diff)
parent6447962f2a3bd845be9ee494f400958371f6e2f9 (diff)
downloadnextcloud-server-c8c722bc6de3a58e10ba42a55a178d3ba9308bae.tar.gz
nextcloud-server-c8c722bc6de3a58e10ba42a55a178d3ba9308bae.zip
Merge pull request #15129 from owncloud/version-command-bus
expire versions in a background command
Diffstat (limited to 'lib')
-rw-r--r--lib/private/command/fileaccess.php6
-rw-r--r--lib/private/command/queuebus.php10
-rw-r--r--lib/private/hook.php3
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/private/command/fileaccess.php b/lib/private/command/fileaccess.php
index 10fd00fb243..b4af557153e 100644
--- a/lib/private/command/fileaccess.php
+++ b/lib/private/command/fileaccess.php
@@ -24,8 +24,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 ac69f8b0d55..76caf76a575 100644
--- a/lib/private/command/queuebus.php
+++ b/lib/private/command/queuebus.php
@@ -28,7 +28,7 @@ class QueueBus implements IBus {
/**
* @var (ICommand|callable)[]
*/
- private $queue;
+ private $queue = [];
/**
* Schedule a command to be fired
@@ -52,7 +52,13 @@ class QueueBus implements IBus {
*/
private function runCommand($command) {
if ($command instanceof ICommand) {
- $command->handle();
+ // 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 {
$command();
}
diff --git a/lib/private/hook.php b/lib/private/hook.php
index 0ede125d64b..d2a0fa898dd 100644
--- a/lib/private/hook.php
+++ b/lib/private/hook.php
@@ -26,6 +26,8 @@
*
*/
class OC_Hook{
+ public static $thrownExceptions = [];
+
static private $registered = array();
/**
@@ -98,6 +100,7 @@ class OC_Hook{
try {
call_user_func( array( $i["class"], $i["name"] ), $params );
} catch (Exception $e){
+ self::$thrownExceptions[] = $e;
OC_Log::write('hook',
'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(),
OC_Log::ERROR);