]> source.dussan.org Git - nextcloud-server.git/commitdiff
techdebt(workflowengine): Remove transition event classes 37040/head
authorJoas Schilling <coding@schilljs.com>
Fri, 3 Mar 2023 11:48:14 +0000 (12:48 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 3 Mar 2023 14:33:17 +0000 (15:33 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/workflowengine/lib/AppInfo/Application.php
lib/composer/composer/ClassLoader.php
lib/composer/composer/autoload_classmap.php
lib/composer/composer/autoload_real.php
lib/composer/composer/autoload_static.php
lib/public/WorkflowEngine/IEntityCompat.php [deleted file]
lib/public/WorkflowEngine/IOperationCompat.php [deleted file]

index fb5514fecef08b0ca9e92b6193e52170f0768ca6..19ff530f2aec277384b489f4c9e14eaeecdf2338 100644 (file)
@@ -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
                                                        }
                                                }
                                        );
index fd56bd7d8405f77f925373bdd46cd8cce93137af..a72151c77c8eb0c43635bfb2ac1ca2d834ac01a7 100644 (file)
@@ -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);
     }
 }
index 080bde6071545c21711203cbd117272a37cd904e..57a828dbefb723e2c52733a3d8dca5d2f525dbf1 100644 (file)
@@ -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',
index 9e054bba0be482006c3a1f98d7af43efda36e35b..ca3361d7202e48e4b38d67549fd478131ee6a5ea 100644 (file)
@@ -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;
index 2ec47c2b842aa181b22f8596e4f0494880dfb7c8..e9d1ba500240308241dc1d0cbb1a69b4dec85bf1 100644 (file)
@@ -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 (file)
index a1c6d20..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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 <http://www.gnu.org/licenses/>.
- *
- */
-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 (file)
index 3e5f58a..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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 <http://www.gnu.org/licenses/>.
- *
- */
-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;
-}