Bladeren bron

fix(db)!: Remove private legacy event because we can not keep it

Signed-off-by: Joas Schilling <coding@schilljs.com>
Joas Schilling 10 maanden geleden
bovenliggende
commit
ab70bbd3ff

+ 6 - 21
apps/settings/lib/Controller/CheckSetupController.php

@@ -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)) {

+ 1 - 10
apps/settings/tests/Controller/CheckSetupControllerTest.php

@@ -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,

+ 0 - 8
core/Command/Db/AddMissingColumns.php

@@ -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();

+ 2 - 10
core/Command/Db/AddMissingIndices.php

@@ -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 !== []) {

+ 0 - 9
core/Command/Db/AddMissingPrimaryKeys.php

@@ -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();

+ 0 - 33
lib/public/IDBConnection.php

@@ -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.
 	 *