]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(db)!: Remove private legacy event because we can not keep it 39487/head
authorJoas Schilling <coding@schilljs.com>
Wed, 19 Jul 2023 22:05:59 +0000 (00:05 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 24 Jul 2023 12:51:35 +0000 (14:51 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/settings/lib/Controller/CheckSetupController.php
apps/settings/tests/Controller/CheckSetupControllerTest.php
core/Command/Db/AddMissingColumns.php
core/Command/Db/AddMissingIndices.php
core/Command/Db/AddMissingPrimaryKeys.php
lib/public/IDBConnection.php

index 5d7989f02562c2f39075a3748c6dddb5247d07d1..4a1913cedfe2319be0255e33829615f56babc912 100644 (file)
@@ -92,8 +92,6 @@ use OCP\Lock\ILockingProvider;
 use OCP\Notification\IManager;
 use OCP\Security\ISecureRandom;
 use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
 
 #[IgnoreOpenAPI]
 class CheckSetupController extends Controller {
@@ -110,8 +108,6 @@ class CheckSetupController extends Controller {
        /** @var LoggerInterface */
        private $logger;
        /** @var IEventDispatcher */
-       private $eventDispatcher;
-       /** @var EventDispatcherInterface */
        private $dispatcher;
        /** @var Connection */
        private $db;
@@ -144,8 +140,7 @@ class CheckSetupController extends Controller {
                                                                IL10N $l10n,
                                                                Checker $checker,
                                                                LoggerInterface $logger,
-                                                               IEventDispatcher $eventDispatcher,
-                                                               EventDispatcherInterface $dispatcher,
+                                                               IEventDispatcher $dispatcher,
                                                                Connection $db,
                                                                ILockingProvider $lockingProvider,
                                                                IDateTimeFormatter $dateTimeFormatter,
@@ -165,7 +160,6 @@ class CheckSetupController extends Controller {
                $this->l10n = $l10n;
                $this->checker = $checker;
                $this->logger = $logger;
-               $this->eventDispatcher = $eventDispatcher;
                $this->dispatcher = $dispatcher;
                $this->db = $db;
                $this->lockingProvider = $lockingProvider;
@@ -553,11 +547,8 @@ Raw output
                $indexInfo = new MissingIndexInformation();
 
                // Dispatch event so apps can also hint for pending index updates if needed
-               $event = new GenericEvent($indexInfo);
-               $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
-
                $event = new AddMissingIndicesEvent();
-               $this->eventDispatcher->dispatchTyped($event);
+               $this->dispatcher->dispatchTyped($event);
                $missingIndices = $event->getMissingIndices();
 
                if ($missingIndices !== []) {
@@ -577,12 +568,9 @@ Raw output
 
        protected function hasMissingPrimaryKeys(): array {
                $info = new MissingPrimaryKeyInformation();
-               // Dispatch event so apps can also hint for pending index updates if needed
-               $event = new GenericEvent($info);
-               $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, $event);
-
+               // Dispatch event so apps can also hint for pending key updates if needed
                $event = new AddMissingPrimaryKeyEvent();
-               $this->eventDispatcher->dispatchTyped($event);
+               $this->dispatcher->dispatchTyped($event);
                $missingKeys = $event->getMissingPrimaryKeys();
 
                if (!empty($missingKeys)) {
@@ -602,12 +590,9 @@ Raw output
 
        protected function hasMissingColumns(): array {
                $columnInfo = new MissingColumnInformation();
-               // Dispatch event so apps can also hint for pending index updates if needed
-               $event = new GenericEvent($columnInfo);
-               $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
-
+               // Dispatch event so apps can also hint for pending column updates if needed
                $event = new AddMissingColumnsEvent();
-               $this->eventDispatcher->dispatchTyped($event);
+               $this->dispatcher->dispatchTyped($event);
                $missingColumns = $event->getMissingColumns();
 
                if (!empty($missingColumns)) {
index 3fc4f930321aadd5287496ca23325e25fcdb5c89..564c1cbb62d0c4ce6ecf94d0de6194a5107a212e 100644 (file)
@@ -62,7 +62,6 @@ use OCP\Notification\IManager;
 use PHPUnit\Framework\MockObject\MockObject;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Test\TestCase;
 
 /**
@@ -89,8 +88,6 @@ class CheckSetupControllerTest extends TestCase {
        /** @var Checker|\PHPUnit\Framework\MockObject\MockObject */
        private $checker;
        /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
-       private $eventDispatcher;
-       /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
        private $dispatcher;
        /** @var Connection|\PHPUnit\Framework\MockObject\MockObject */
        private $db;
@@ -140,9 +137,7 @@ class CheckSetupControllerTest extends TestCase {
                        ->willReturnCallback(function ($message, array $replace) {
                                return vsprintf($message, $replace);
                        });
-               $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
-               $this->dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)
-                       ->disableOriginalConstructor()->getMock();
+               $this->dispatcher = $this->createMock(IEventDispatcher::class);
                $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
                                ->disableOriginalConstructor()->getMock();
                $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
@@ -171,7 +166,6 @@ class CheckSetupControllerTest extends TestCase {
                                $this->l10n,
                                $this->checker,
                                $this->logger,
-                               $this->eventDispatcher,
                                $this->dispatcher,
                                $this->db,
                                $this->lockingProvider,
@@ -681,7 +675,6 @@ class CheckSetupControllerTest extends TestCase {
                                $this->l10n,
                                $this->checker,
                                $this->logger,
-                               $this->eventDispatcher,
                                $this->dispatcher,
                                $this->db,
                                $this->lockingProvider,
@@ -1409,7 +1402,6 @@ Array
                        $this->l10n,
                        $this->checker,
                        $this->logger,
-                       $this->eventDispatcher,
                        $this->dispatcher,
                        $this->db,
                        $this->lockingProvider,
@@ -1464,7 +1456,6 @@ Array
                        $this->l10n,
                        $this->checker,
                        $this->logger,
-                       $this->eventDispatcher,
                        $this->dispatcher,
                        $this->db,
                        $this->lockingProvider,
index 46642f7d0d4964b85d2c40428e4195a72323f81e..07763c661543be72a037e11345987defbd03d39d 100644 (file)
@@ -29,15 +29,11 @@ namespace OC\Core\Command\Db;
 use OC\DB\Connection;
 use OC\DB\SchemaWrapper;
 use OCP\DB\Events\AddMissingColumnsEvent;
-use OCP\DB\Types;
 use OCP\EventDispatcher\IEventDispatcher;
-use OCP\IDBConnection;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
 
 /**
  * Class AddMissingColumns
@@ -50,7 +46,6 @@ use Symfony\Component\EventDispatcher\GenericEvent;
 class AddMissingColumns extends Command {
        public function __construct(
                private Connection $connection,
-               private EventDispatcherInterface $legacyDispatcher,
                private IEventDispatcher $dispatcher,
        ) {
                parent::__construct();
@@ -67,9 +62,6 @@ class AddMissingColumns extends Command {
                $dryRun = $input->getOption('dry-run');
 
                // Dispatch event so apps can also update columns if needed
-               $event = new GenericEvent($output);
-               $this->legacyDispatcher->dispatch(IDBConnection::ADD_MISSING_COLUMNS_EVENT, $event);
-
                $event = new AddMissingColumnsEvent();
                $this->dispatcher->dispatchTyped($event);
                $missingColumns = $event->getMissingColumns();
index f05be314e08aff074a973e770accab7657ffaf39..56dbf8ce8d97accf4841ab58f33f64074012ce0b 100644 (file)
@@ -33,18 +33,14 @@ declare(strict_types=1);
  */
 namespace OC\Core\Command\Db;
 
-use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
 use OC\DB\Connection;
 use OC\DB\SchemaWrapper;
 use OCP\DB\Events\AddMissingIndicesEvent;
 use OCP\EventDispatcher\IEventDispatcher;
-use OCP\IDBConnection;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
 
 /**
  * Class AddMissingIndices
@@ -57,8 +53,7 @@ use Symfony\Component\EventDispatcher\GenericEvent;
 class AddMissingIndices extends Command {
        public function __construct(
                private Connection $connection,
-               private IEventDispatcher $eventDispatcher,
-               private EventDispatcherInterface $dispatcher,
+               private IEventDispatcher $dispatcher,
        ) {
                parent::__construct();
        }
@@ -74,11 +69,8 @@ class AddMissingIndices extends Command {
                $dryRun = $input->getOption('dry-run');
 
                // Dispatch event so apps can also update indexes if needed
-               $event = new GenericEvent($output);
-               $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
-
                $event = new AddMissingIndicesEvent();
-               $this->eventDispatcher->dispatchTyped($event);
+               $this->dispatcher->dispatchTyped($event);
 
                $missingIndices = $event->getMissingIndices();
                if ($missingIndices !== []) {
index b7435144933ad6c21d4e228a88a9a64b3d894181..658eb0b0f5a2c4b298d01653165a50cee822501e 100644 (file)
@@ -28,17 +28,12 @@ namespace OC\Core\Command\Db;
 
 use OC\DB\Connection;
 use OC\DB\SchemaWrapper;
-use OCP\DB\Events\AddMissingColumnsEvent;
 use OCP\DB\Events\AddMissingPrimaryKeyEvent;
 use OCP\EventDispatcher\IEventDispatcher;
-use OCP\IDBConnection;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
-use function Symfony\Component\Translation\t;
 
 /**
  * Class AddMissingPrimaryKeys
@@ -51,7 +46,6 @@ use function Symfony\Component\Translation\t;
 class AddMissingPrimaryKeys extends Command {
        public function __construct(
                private Connection $connection,
-               private EventDispatcherInterface $legacyDispatcher,
                private IEventDispatcher $dispatcher,
        ) {
                parent::__construct();
@@ -68,9 +62,6 @@ class AddMissingPrimaryKeys extends Command {
                $dryRun = $input->getOption('dry-run');
 
                // Dispatch event so apps can also update indexes if needed
-               $event = new GenericEvent($output);
-               $this->legacyDispatcher->dispatch(IDBConnection::ADD_MISSING_PRIMARY_KEYS_EVENT, $event);
-
                $event = new AddMissingPrimaryKeyEvent();
                $this->dispatcher->dispatchTyped($event);
                $missingKeys = $event->getMissingPrimaryKeys();
index 7ce2537cb65c61f7e11c56da73b9db1feae5cefc..fe0267facc53c7b1c9de237aa33dd644049c47f6 100644 (file)
@@ -34,9 +34,6 @@
 namespace OCP;
 
 use Doctrine\DBAL\Schema\Schema;
-use OCP\DB\Events\AddMissingColumnsEvent;
-use OCP\DB\Events\AddMissingIndicesEvent;
-use OCP\DB\Events\AddMissingPrimaryKeyEvent;
 use OCP\DB\Exception;
 use OCP\DB\IPreparedStatement;
 use OCP\DB\IResult;
@@ -48,36 +45,6 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
  * @since 6.0.0
  */
 interface IDBConnection {
-       /**
-        * @deprecated 22.0.0 this is an internal event, use {@see AddMissingIndicesEvent} instead
-        */
-       public const ADD_MISSING_INDEXES_EVENT = self::class . '::ADD_MISSING_INDEXES';
-
-       /**
-        * @deprecated 22.0.0 this is an internal event, use {@see AddMissingIndicesEvent} instead
-        */
-       public const CHECK_MISSING_INDEXES_EVENT = self::class . '::CHECK_MISSING_INDEXES';
-
-       /**
-        * @deprecated 22.0.0 this is an internal event, use {@see AddMissingPrimaryKeyEvent} instead
-        */
-       public const ADD_MISSING_PRIMARY_KEYS_EVENT = self::class . '::ADD_MISSING_PRIMARY_KEYS';
-
-       /**
-        * @deprecated 22.0.0 this is an internal event, use {@see AddMissingPrimaryKeyEvent} instead
-        */
-       public const CHECK_MISSING_PRIMARY_KEYS_EVENT = self::class . '::CHECK_MISSING_PRIMARY_KEYS';
-
-       /**
-        * @deprecated 22.0.0 this is an internal event, use {@see AddMissingColumnsEvent} instead
-        */
-       public const ADD_MISSING_COLUMNS_EVENT = self::class . '::ADD_MISSING_COLUMNS';
-
-       /**
-        * @deprecated 22.0.0 this is an internal event, use {@see AddMissingColumnsEvent} instead
-        */
-       public const CHECK_MISSING_COLUMNS_EVENT = self::class . '::CHECK_MISSING_COLUMNS';
-
        /**
         * Gets the QueryBuilder for the connection.
         *