From 5037f9c4601bc1ccbf9368d47a98214b581bc498 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Aug 2018 21:20:25 +0000 Subject: [PATCH] Console script to ensure that all post updates are finished --- src/Core/Console.php | 2 ++ src/Core/Console/PostUpdate.php | 42 +++++++++++++++++++++++++++++++++ src/Database/PostUpdate.php | 12 ++++++---- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/Core/Console/PostUpdate.php diff --git a/src/Core/Console.php b/src/Core/Console.php index a5aff4ae80..63af50ee22 100644 --- a/src/Core/Console.php +++ b/src/Core/Console.php @@ -28,6 +28,7 @@ class Console extends \Asika\SimpleConsole\Console 'php2po' => __NAMESPACE__ . '\Console\PhpToPo', 'po2php' => __NAMESPACE__ . '\Console\PoToPhp', 'typo' => __NAMESPACE__ . '\Console\Typo', + 'postupdate' => __NAMESPACE__ . '\Console\PostUpdate', ]; protected function getHelp() @@ -51,6 +52,7 @@ Commands: php2po Generate a messages.po file from a strings.php file po2php Generate a strings.php file from a messages.po file typo Checks for parse errors in Friendica files + postupdate Execute pending post update scripts (can last days) Options: -h|--help|-? Show help information diff --git a/src/Core/Console/PostUpdate.php b/src/Core/Console/PostUpdate.php new file mode 100644 index 0000000000..97c19b0c1e --- /dev/null +++ b/src/Core/Console/PostUpdate.php @@ -0,0 +1,42 @@ + + * @author Hypolite Petovan + */ +class PostUpdate extends \Asika\SimpleConsole\Console +{ + protected function doExecute() + { + $a = get_app(); + + if (count($this->args) > 0) { + throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); + } + + if ($a->isInstallMode()) { + throw new \RuntimeException('Database isn\'t ready or populated yet'); + } + + echo L10n::t('Execute pending post updates.') . "\n"; + + while (!\Friendica\Database\PostUpdate::update()) { + echo '.'; + } + + echo "\n" . L10n::t('All pending post updates are done.') . "\n"; + + return 0; + } +} diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 8805961153..b7c69668e0 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -24,20 +24,22 @@ class PostUpdate public static function update() { if (!self::update1194()) { - return; + return false; } if (!self::update1198()) { - return; + return false; } if (!self::update1206()) { - return; + return false; } if (!self::update1279()) { - return; + return false; } if (!self::update1281()) { - return; + return false; } + + return true; } /** -- 2.39.5