]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/DBSync.php
Merge pull request #12922 from annando/nomad-version
[friendica.git] / src / Module / Admin / DBSync.php
index 662fe08e27c5143199720d001c26da6adcffd847..942791887c180503db6806252c85156209a71fce 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -30,31 +30,31 @@ use Friendica\Module\BaseAdmin;
 
 class DBSync extends BaseAdmin
 {
-       public static function content(array $parameters = [])
+       protected function content(array $request = []): string
        {
-               parent::content($parameters);
+               parent::content();
 
                $a = DI::app();
 
-               $action = $parameters['action'] ?? '';
-               $update = $parameters['update'] ?? 0;
+               $action = $this->parameters['action'] ?? '';
+               $update = $this->parameters['update'] ?? 0;
 
                switch ($action) {
                        case 'mark':
                                if ($update) {
-                                       DI::config()->set('database', 'update_' . $update, 'success');
+                                       DI::keyValue()->set('database_update_' . $update, 'success');
                                        $curr = DI::config()->get('system', 'build');
                                        if (intval($curr) == $update) {
                                                DI::config()->set('system', 'build', intval($curr) + 1);
                                        }
 
-                                       info(DI::l10n()->t('Update has been marked successful'));
+                                       DI::sysmsg()->addInfo(DI::l10n()->t('Update has been marked successful'));
                                }
 
                                break;
                        case 'check':
                                // @TODO Seems like a similar logic like Update::check()
-                               $retval = DBStructure::update($a->getBasePath(), false, true);
+                               $retval = DBStructure::performUpdate();
                                if ($retval === '') {
                                        $o = DI::l10n()->t("Database structure update %s was successfully applied.", DB_UPDATE_VERSION) . "<br />";
                                } else {
@@ -76,13 +76,13 @@ class DBSync extends BaseAdmin
                                                        $o = DI::l10n()->t("Executing %s failed with error: %s", $func, $retval);
                                                } elseif ($retval === Update::SUCCESS) {
                                                        $o = DI::l10n()->t('Update %s was successfully applied.', $func);
-                                                       DI::config()->set('database', $func, 'success');
+                                                       DI::keyValue()->set(sprintf('database_%s', $func), 'success');
                                                } else {
                                                        $o = DI::l10n()->t('Update %s did not return a status. Unknown if it succeeded.', $func);
                                                }
                                        } else {
                                                $o = DI::l10n()->t('There was no additional update function %s that needed to be called.', $func) . "<br />";
-                                               DI::config()->set('database', $func, 'success');
+                                               DI::keyValue()->set(sprintf('database_%s', $func), 'success');
                                        }
 
                                        return $o;
@@ -102,13 +102,11 @@ class DBSync extends BaseAdmin
 
                                if (!count($failed)) {
                                        $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [
-                                               '$base' => DI::baseUrl()->get(true),
                                                '$banner' => DI::l10n()->t('No failed updates.'),
                                                '$check' => DI::l10n()->t('Check database structure'),
                                        ]);
                                } else {
                                        $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [
-                                               '$base' => DI::baseUrl()->get(true),
                                                '$banner' => DI::l10n()->t('Failed Updates'),
                                                '$desc' => DI::l10n()->t('This does not include updates prior to 1139, which did not return a status.'),
                                                '$mark' => DI::l10n()->t("Mark success \x28if update was manually applied\x29"),