From 6a7bf2f8e09d3b26d15d2185001a05b067298466 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 11 Apr 2020 17:50:45 +0545 Subject: [PATCH] Replace jeremeamia/superclosure with opis/closure --- changelog/unreleased/37238 | 6 + composer.json | 2 +- composer.lock | 230 ++++++++--------------------- lib/private/Command/AsyncBus.php | 5 +- lib/private/Command/ClosureJob.php | 5 +- 5 files changed, 73 insertions(+), 175 deletions(-) create mode 100644 changelog/unreleased/37238 diff --git a/changelog/unreleased/37238 b/changelog/unreleased/37238 new file mode 100644 index 000000000000..6c13eff0b42a --- /dev/null +++ b/changelog/unreleased/37238 @@ -0,0 +1,6 @@ +Change: Replace jeremeamia/superclosure with opis/closure + +jeremeamia/superclosure library is no longer maintained. +Replace it with the recommended opis/closure library. + +https://github.com/owncloud/core/pull/37238 diff --git a/composer.json b/composer.json index 947952055fb5..896c4346f5f1 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "php": ">=7.1", "doctrine/dbal": "^2.8", "phpseclib/phpseclib": "^2.0", - "jeremeamia/superclosure": "^2.4", + "opis/closure": "^3.5", "bantu/ini-get-wrapper": "v1.0.1", "punic/punic": "^3.1", "pear/archive_tar": "1.4.9", diff --git a/composer.lock b/composer.lock index 7ca0622114a8..7b21dd4b9131 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "989e0282c0e4298cf81e8e83a6162c3f", + "content-hash": "abdbc1bba21813fbb74c0414126d18ef", "packages": [ { "name": "bantu/ini-get-wrapper", @@ -926,65 +926,6 @@ ], "time": "2015-08-01T16:27:37+00:00" }, - { - "name": "jeremeamia/superclosure", - "version": "2.4.0", - "source": { - "type": "git", - "url": "https://github.com/jeremeamia/super_closure.git", - "reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/5707d5821b30b9a07acfb4d76949784aaa0e9ce9", - "reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^1.2|^2.0|^3.0|^4.0", - "php": ">=5.4", - "symfony/polyfill-php56": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - }, - "autoload": { - "psr-4": { - "SuperClosure\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia", - "role": "Developer" - } - ], - "description": "Serialize Closure objects, including their context and binding", - "homepage": "https://github.com/jeremeamia/super_closure", - "keywords": [ - "closure", - "function", - "lambda", - "parser", - "serializable", - "serialize", - "tokenizer" - ], - "abandoned": "opis/closure", - "time": "2018-03-21T22:21:57+00:00" - }, { "name": "laminas/laminas-filter", "version": "2.9.4", @@ -1504,6 +1445,67 @@ ], "time": "2020-04-10T16:34:50+00:00" }, + { + "name": "opis/closure", + "version": "3.5.1", + "source": { + "type": "git", + "url": "https://github.com/opis/closure.git", + "reference": "93ebc5712cdad8d5f489b500c59d122df2e53969" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opis/closure/zipball/93ebc5712cdad8d5f489b500c59d122df2e53969", + "reference": "93ebc5712cdad8d5f489b500c59d122df2e53969", + "shasum": "" + }, + "require": { + "php": "^5.4 || ^7.0" + }, + "require-dev": { + "jeremeamia/superclosure": "^2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.5.x-dev" + } + }, + "autoload": { + "psr-4": { + "Opis\\Closure\\": "src/" + }, + "files": [ + "functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marius Sarca", + "email": "marius.sarca@gmail.com" + }, + { + "name": "Sorin Sarca", + "email": "sarca_sorin@hotmail.com" + } + ], + "description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.", + "homepage": "https://opis.io/closure", + "keywords": [ + "anonymous functions", + "closure", + "function", + "serializable", + "serialization", + "serialize" + ], + "time": "2019-11-29T22:36:02+00:00" + }, { "name": "patchwork/jsqueeze", "version": "v2.0.5", @@ -3038,62 +3040,6 @@ ], "time": "2020-03-09T19:04:49+00:00" }, - { - "name": "symfony/polyfill-php56", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "d51ec491c8ddceae7dca8dd6c7e30428f543f37d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/d51ec491c8ddceae7dca8dd6c7e30428f543f37d", - "reference": "d51ec491c8ddceae7dca8dd6c7e30428f543f37d", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/polyfill-util": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php56\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2020-03-09T19:04:49+00:00" - }, { "name": "symfony/polyfill-php72", "version": "v1.15.0", @@ -3207,58 +3153,6 @@ ], "time": "2020-02-27T09:26:54+00:00" }, - { - "name": "symfony/polyfill-util", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-util.git", - "reference": "d8e76c104127675d0ea3df3be0f2ae24a8619027" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/d8e76c104127675d0ea3df3be0f2ae24a8619027", - "reference": "d8e76c104127675d0ea3df3be0f2ae24a8619027", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Util\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony utilities for portability of PHP codes", - "homepage": "https://symfony.com", - "keywords": [ - "compat", - "compatibility", - "polyfill", - "shim" - ], - "time": "2020-03-02T11:55:35+00:00" - }, { "name": "symfony/process", "version": "v4.4.7", diff --git a/lib/private/Command/AsyncBus.php b/lib/private/Command/AsyncBus.php index 8cd72a15c430..366f69d8aa3d 100644 --- a/lib/private/Command/AsyncBus.php +++ b/lib/private/Command/AsyncBus.php @@ -23,7 +23,7 @@ use OCP\Command\IBus; use OCP\Command\ICommand; -use SuperClosure\Serializer; +use Opis\Closure\SerializableClosure; /** * Asynchronous command bus that uses the background job system as backend @@ -103,8 +103,7 @@ private function getJobClass($command) { */ private function serializeCommand($command) { if ($command instanceof \Closure) { - $serializer = new Serializer(); - return $serializer->serialize($command); + return \serialize(new SerializableClosure($command)); } elseif (\is_callable($command) or $command instanceof ICommand) { return \serialize($command); } else { diff --git a/lib/private/Command/ClosureJob.php b/lib/private/Command/ClosureJob.php index 30ae8eb79dc9..921e7db20efb 100644 --- a/lib/private/Command/ClosureJob.php +++ b/lib/private/Command/ClosureJob.php @@ -22,12 +22,11 @@ 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); + $serializedClosure = \unserialize($serializedCallable); + $callable = $serializedClosure->getClosure(); if (\is_callable($callable)) { $callable(); } else {