summaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-08-22 16:56:01 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-08-25 16:13:47 +0200
commita83a8f0dde07bff67e0ceb7008cc26b3fad32516 (patch)
treea1dcc3e67eab7f2ff56a0fc60aa3f19387b943cd /core/Command
parent5aac997d448da55f1c43648b1e5cf1a9c1360d6c (diff)
downloadnextcloud-server-a83a8f0dde07bff67e0ceb7008cc26b3fad32516.tar.gz
nextcloud-server-a83a8f0dde07bff67e0ceb7008cc26b3fad32516.zip
Migrate Migrator::executeSql to OCP\EventDispatcher\Event
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Upgrade.php48
1 files changed, 25 insertions, 23 deletions
diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php
index e4b831835d4..3a45c53f6b2 100644
--- a/core/Command/Upgrade.php
+++ b/core/Command/Upgrade.php
@@ -33,11 +33,13 @@
*/
namespace OC\Core\Command;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IConfig;
+use OCP\Util;
use OC\Console\TimestampFormatter;
+use OC\DB\MigratorExecuteSqlEvent;
use OC\Installer;
use OC\Updater;
-use OCP\IConfig;
-use OCP\Util;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
@@ -93,28 +95,28 @@ class Upgrade extends Command {
);
$dispatcher = \OC::$server->getEventDispatcher();
+ /** @var IEventDispatcher $newDispatcher */
+ $newDispatcher = \OC::$server->get(IEventDispatcher::class);
$progress = new ProgressBar($output);
$progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%");
- $listener = function ($event) use ($progress, $output) {
- if ($event instanceof GenericEvent) {
- $message = $event->getSubject();
- if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
- $output->writeln(' Checking table ' . $message);
- } else {
- if (strlen($message) > 60) {
- $message = substr($message, 0, 57) . '...';
- }
- $progress->setMessage($message);
- if ($event['step'] === 1) {
- $output->writeln('');
- $progress->start($event['max']);
- }
- $progress->setProgress($event['step']);
- if ($event['step'] === $event['max']) {
- $progress->setMessage('Done');
- $progress->finish();
- $output->writeln('');
- }
+ $listener = function (MigratorExecuteSqlEvent $event) use ($progress, $output) {
+ $message = $event->getSql();
+ if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
+ $output->writeln(' Executing SQL ' . $message);
+ } else {
+ if (strlen($message) > 60) {
+ $message = substr($message, 0, 57) . '...';
+ }
+ $progress->setMessage($message);
+ if ($event->getCurrentStep() === 1) {
+ $output->writeln('');
+ $progress->start($event->getMaxStep());
+ }
+ $progress->setProgress($event->getCurrentStep());
+ if ($event->getCurrentStep() === $event->getMaxStep()) {
+ $progress->setMessage('Done');
+ $progress->finish();
+ $output->writeln('');
}
}
};
@@ -161,7 +163,7 @@ class Upgrade extends Command {
}
};
- $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener);
+ $newDispatcher->addListener(MigratorExecuteSqlEvent::class, $listener);
$dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
$dispatcher->addListener('\OC\Repair::advance', $repairListener);
$dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);