Merge pull request #24429 from nextcloud/3rdparty/closure

[3rdparty] Migrate to Opis/Closure
This commit is contained in:
Christoph Wurst 2020-12-03 08:44:53 +01:00 committed by GitHub
commit fbc06d39c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 9 deletions

@ -1 +1 @@
Subproject commit 8d7a96cde06a0357ce5805e00773b576d7595ef8 Subproject commit 8f03ccac97331ff781340d76a3f4a49a017d6ae1

View File

@ -3281,6 +3281,21 @@
<code>''</code> <code>''</code>
</TypeDoesNotContainType> </TypeDoesNotContainType>
</file> </file>
<file src="lib/private/Command/ClosureJob.php">
<UndefinedFunction occurrences="1">
<code>\Opis\Closure\unserialize($serializedCallable)</code>
</UndefinedFunction>
</file>
<file src="lib/private/Command/CommandJob.php">
<UndefinedFunction occurrences="1">
<code>\Opis\Closure\unserialize($serializedCommand)</code>
</UndefinedFunction>
</file>
<file src="lib/private/Command/CronBus.php">
<UndefinedFunction occurrences="1">
<code>\Opis\Closure\serialize($command)</code>
</UndefinedFunction>
</file>
<file src="lib/private/Comments/Comment.php"> <file src="lib/private/Comments/Comment.php">
<ImplementedReturnTypeMismatch occurrences="1"> <ImplementedReturnTypeMismatch occurrences="1">
<code>\DateTime|null</code> <code>\DateTime|null</code>

View File

@ -23,12 +23,10 @@
namespace OC\Command; namespace OC\Command;
use OC\BackgroundJob\QueuedJob; use OC\BackgroundJob\QueuedJob;
use SuperClosure\Serializer;
class ClosureJob extends QueuedJob { class ClosureJob extends QueuedJob {
protected function run($serializedCallable) { protected function run($serializedCallable) {
$serializer = new Serializer(); $callable = \Opis\Closure\unserialize($serializedCallable);
$callable = $serializer->unserialize($serializedCallable);
if (is_callable($callable)) { if (is_callable($callable)) {
$callable(); $callable();
} else { } else {

View File

@ -30,7 +30,7 @@ use OCP\Command\ICommand;
*/ */
class CommandJob extends QueuedJob { class CommandJob extends QueuedJob {
protected function run($serializedCommand) { protected function run($serializedCommand) {
$command = unserialize($serializedCommand); $command = \Opis\Closure\unserialize($serializedCommand);
if ($command instanceof ICommand) { if ($command instanceof ICommand) {
$command->handle(); $command->handle();
} else { } else {

View File

@ -26,7 +26,6 @@
namespace OC\Command; namespace OC\Command;
use OCP\Command\ICommand; use OCP\Command\ICommand;
use SuperClosure\Serializer;
class CronBus extends AsyncBus { class CronBus extends AsyncBus {
/** /**
@ -68,10 +67,9 @@ class CronBus extends AsyncBus {
*/ */
private function serializeCommand($command) { private function serializeCommand($command) {
if ($command instanceof \Closure) { if ($command instanceof \Closure) {
$serializer = new Serializer(); return \Opis\Closure\serialize($command);
return $serializer->serialize($command);
} elseif (is_callable($command) or $command instanceof ICommand) { } elseif (is_callable($command) or $command instanceof ICommand) {
return serialize($command); return \Opis\Closure\serialize($command);
} else { } else {
throw new \InvalidArgumentException('Invalid command'); throw new \InvalidArgumentException('Invalid command');
} }