From: Joas Schilling Date: Fri, 3 Mar 2023 11:48:14 +0000 (+0100) Subject: techdebt(workflowengine): Remove transition event classes X-Git-Tag: v27.0.0beta1~380^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5bc86dd6acf3ab5f8f166f079ae78879da93a353;p=nextcloud-server.git techdebt(workflowengine): Remove transition event classes Signed-off-by: Joas Schilling --- diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php index fb5514fecef..19ff530f2ae 100644 --- a/apps/workflowengine/lib/AppInfo/Application.php +++ b/apps/workflowengine/lib/AppInfo/Application.php @@ -36,16 +36,14 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; -use OCP\AppFramework\QueryException; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; -use OCP\IServerContainer; use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent; use OCP\WorkflowEngine\IEntity; -use OCP\WorkflowEngine\IEntityCompat; use OCP\WorkflowEngine\IOperation; -use OCP\WorkflowEngine\IOperationCompat; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\ContainerInterface; +use Psr\Log\LoggerInterface; class Application extends App implements IBootstrap { public const APP_ID = 'workflowengine'; @@ -68,10 +66,10 @@ class Application extends App implements IBootstrap { } private function registerRuleListeners(IEventDispatcher $dispatcher, - IServerContainer $container, - ILogger $logger): void { + ContainerInterface $container, + LoggerInterface $logger): void { /** @var Manager $manager */ - $manager = $container->query(Manager::class); + $manager = $container->get(Manager::class); $configuredEvents = $manager->getAllConfiguredEvents(); foreach ($configuredEvents as $operationClass => $events) { @@ -83,9 +81,9 @@ class Application extends App implements IBootstrap { $ruleMatcher = $manager->getRuleMatcher(); try { /** @var IEntity $entity */ - $entity = $container->query($entityClass); + $entity = $container->get($entityClass); /** @var IOperation $operation */ - $operation = $container->query($operationClass); + $operation = $container->get($operationClass); $ruleMatcher->setEventName($eventName); $ruleMatcher->setEntity($entity); @@ -98,16 +96,12 @@ class Application extends App implements IBootstrap { ->setEventName($eventName); /** @var Logger $flowLogger */ - $flowLogger = $container->query(Logger::class); + $flowLogger = $container->get(Logger::class); $flowLogger->logEventInit($ctx); if ($event instanceof Event) { $entity->prepareRuleMatcher($ruleMatcher, $eventName, $event); $operation->onEvent($eventName, $event, $ruleMatcher); - } elseif ($entity instanceof IEntityCompat && $operation instanceof IOperationCompat) { - // TODO: Remove this block (and the compat classes) in the first major release in 2023 - $entity->prepareRuleMatcherCompat($ruleMatcher, $eventName, $event); - $operation->onEventCompat($eventName, $event, $ruleMatcher); } else { $logger->debug( 'Cannot handle event {name} of {event} against entity {entity} and operation {operation}', @@ -121,8 +115,8 @@ class Application extends App implements IBootstrap { ); } $flowLogger->logEventDone($ctx); - } catch (QueryException $e) { - // Ignore query exceptions since they might occur when an entity/operation were setup before by an app that is disabled now + } catch (ContainerExceptionInterface $e) { + // Ignore query exceptions since they might occur when an entity/operation were set up before by an app that is disabled now } } ); diff --git a/lib/composer/composer/ClassLoader.php b/lib/composer/composer/ClassLoader.php index fd56bd7d840..a72151c77c8 100644 --- a/lib/composer/composer/ClassLoader.php +++ b/lib/composer/composer/ClassLoader.php @@ -429,7 +429,8 @@ class ClassLoader public function loadClass($class) { if ($file = $this->findFile($class)) { - (self::$includeFile)($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -560,7 +561,10 @@ class ClassLoader return false; } - private static function initializeIncludeClosure(): void + /** + * @return void + */ + private static function initializeIncludeClosure() { if (self::$includeFile !== null) { return; @@ -574,8 +578,8 @@ class ClassLoader * @param string $file * @return void */ - self::$includeFile = static function($file) { + self::$includeFile = \Closure::bind(static function($file) { include $file; - }; + }, null, null); } } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 080bde60715..57a828dbefb 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -649,12 +649,10 @@ return array( 'OCP\\WorkflowEngine\\IComplexOperation' => $baseDir . '/lib/public/WorkflowEngine/IComplexOperation.php', 'OCP\\WorkflowEngine\\IEntity' => $baseDir . '/lib/public/WorkflowEngine/IEntity.php', 'OCP\\WorkflowEngine\\IEntityCheck' => $baseDir . '/lib/public/WorkflowEngine/IEntityCheck.php', - 'OCP\\WorkflowEngine\\IEntityCompat' => $baseDir . '/lib/public/WorkflowEngine/IEntityCompat.php', 'OCP\\WorkflowEngine\\IEntityEvent' => $baseDir . '/lib/public/WorkflowEngine/IEntityEvent.php', 'OCP\\WorkflowEngine\\IFileCheck' => $baseDir . '/lib/public/WorkflowEngine/IFileCheck.php', 'OCP\\WorkflowEngine\\IManager' => $baseDir . '/lib/public/WorkflowEngine/IManager.php', 'OCP\\WorkflowEngine\\IOperation' => $baseDir . '/lib/public/WorkflowEngine/IOperation.php', - 'OCP\\WorkflowEngine\\IOperationCompat' => $baseDir . '/lib/public/WorkflowEngine/IOperationCompat.php', 'OCP\\WorkflowEngine\\IRuleMatcher' => $baseDir . '/lib/public/WorkflowEngine/IRuleMatcher.php', 'OCP\\WorkflowEngine\\ISpecificOperation' => $baseDir . '/lib/public/WorkflowEngine/ISpecificOperation.php', 'OC\\Accounts\\Account' => $baseDir . '/lib/private/Accounts/Account.php', diff --git a/lib/composer/composer/autoload_real.php b/lib/composer/composer/autoload_real.php index 9e054bba0be..ca3361d7202 100644 --- a/lib/composer/composer/autoload_real.php +++ b/lib/composer/composer/autoload_real.php @@ -34,15 +34,15 @@ class ComposerAutoloaderInit749170dad3f5e7f9ca158f5a9f04f6a2 $loader->register(true); $filesToLoad = \Composer\Autoload\ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2::$files; - $requireFile = static function ($fileIdentifier, $file) { + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; require $file; } - }; + }, null, null); foreach ($filesToLoad as $fileIdentifier => $file) { - ($requireFile)($fileIdentifier, $file); + $requireFile($fileIdentifier, $file); } return $loader; diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 2ec47c2b842..e9d1ba50024 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -682,12 +682,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\WorkflowEngine\\IComplexOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IComplexOperation.php', 'OCP\\WorkflowEngine\\IEntity' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntity.php', 'OCP\\WorkflowEngine\\IEntityCheck' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityCheck.php', - 'OCP\\WorkflowEngine\\IEntityCompat' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityCompat.php', 'OCP\\WorkflowEngine\\IEntityEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityEvent.php', 'OCP\\WorkflowEngine\\IFileCheck' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IFileCheck.php', 'OCP\\WorkflowEngine\\IManager' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IManager.php', 'OCP\\WorkflowEngine\\IOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IOperation.php', - 'OCP\\WorkflowEngine\\IOperationCompat' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IOperationCompat.php', 'OCP\\WorkflowEngine\\IRuleMatcher' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IRuleMatcher.php', 'OCP\\WorkflowEngine\\ISpecificOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/ISpecificOperation.php', 'OC\\Accounts\\Account' => __DIR__ . '/../../..' . '/lib/private/Accounts/Account.php', diff --git a/lib/public/WorkflowEngine/IEntityCompat.php b/lib/public/WorkflowEngine/IEntityCompat.php deleted file mode 100644 index a1c6d20c034..00000000000 --- a/lib/public/WorkflowEngine/IEntityCompat.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * @author Arthur Schiwon - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ -namespace OCP\WorkflowEngine; - -/** - * Interface IEntityCompat - * - * This interface extends IEntity to provide compatibility with old style - * Event classes. It is only present for a transition period and will be - * removed in 2023 again. - * - * @since 18.0.0 - * @deprecated - */ -interface IEntityCompat extends IEntity { - /** - * Like prepareRuleMatcherCompat, but works with events that are not based - * on \OCP\EventDispatcher\Event. - * - * @since 18.0.0 - * @deprecated - */ - public function prepareRuleMatcherCompat(IRuleMatcher $ruleMatcher, string $eventName, $event): void; -} diff --git a/lib/public/WorkflowEngine/IOperationCompat.php b/lib/public/WorkflowEngine/IOperationCompat.php deleted file mode 100644 index 3e5f58a2867..00000000000 --- a/lib/public/WorkflowEngine/IOperationCompat.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * @author Arthur Schiwon - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ -namespace OCP\WorkflowEngine; - -/** - * Interface IOperationCompat - * - * This interface extends IOperation to provide compatibility with old style - * Event classes. It is only present for a transition period and will be - * removed in 2023 again. - * - * @since 18.0.0 - * @deprecated - */ -interface IOperationCompat { - /** - * Like onEvent, but used with events that are not based on - * \OCP\EventDispatcher\Event. - * - * This method is introduced for compatibility reasons and will be removed - * in 2023 again. - * - * @since 18.0.0 - * @deprecated - */ - public function onEventCompat(string $eventName, $event, IRuleMatcher $ruleMatcher): void; -}