X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FAdmin%2FDBSync.php;h=4c29eea34f550e15bb64c72dcc457096dc93c054;hb=3c7e4b474b8f219b7ddacfd2c948d49628aafa81;hp=69001b9ce4640ce29dd236b794499a14250204a9;hpb=6df37afb828f4deb5397d512d801427f24a068c9;p=friendica.git
diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php
index 69001b9ce4..4c29eea34f 100644
--- a/src/Module/Admin/DBSync.php
+++ b/src/Module/Admin/DBSync.php
@@ -1,107 +1,107 @@
-argc > 3 && $a->argv[2] === 'mark') {
- // @TODO: Replace with parameter from router
- $update = intval($a->argv[3]);
- if ($update) {
- Config::set('database', 'update_' . $update, 'success');
- $curr = Config::get('system', 'build');
- if (intval($curr) == $update) {
- Config::set('system', 'build', intval($curr) + 1);
- }
- info(L10n::t('Update has been marked successful') . EOL);
- }
- $a->internalRedirect('admin/dbsync');
- }
-
- if ($a->argc > 2) {
- if ($a->argv[2] === 'check') {
- // @TODO Seems like a similar logic like Update::check()
- $retval = DBStructure::update($a->getBasePath(), false, true);
- if ($retval === '') {
- $o .= L10n::t("Database structure update %s was successfully applied.", DB_UPDATE_VERSION) . "
";
- Config::set('database', 'last_successful_update', DB_UPDATE_VERSION);
- Config::set('database', 'last_successful_update_time', time());
- } else {
- $o .= L10n::t("Executing of database structure update %s failed with error: %s", DB_UPDATE_VERSION, $retval) . "
";
- }
- if ($a->argv[2] === 'check') {
- return $o;
- }
- } elseif (intval($a->argv[2])) {
- require_once 'update.php';
-
- // @TODO: Replace with parameter from router
- $update = intval($a->argv[2]);
-
- $func = 'update_' . $update;
-
- if (function_exists($func)) {
- $retval = $func();
-
- if ($retval === Update::FAILED) {
- $o .= L10n::t("Executing %s failed with error: %s", $func, $retval);
- } elseif ($retval === Update::SUCCESS) {
- $o .= L10n::t('Update %s was successfully applied.', $func);
- Config::set('database', $func, 'success');
- } else {
- $o .= L10n::t('Update %s did not return a status. Unknown if it succeeded.', $func);
- }
- } else {
- $o .= L10n::t('There was no additional update function %s that needed to be called.', $func) . "
";
- Config::set('database', $func, 'success');
- }
-
- return $o;
- }
- }
-
- $failed = [];
- $configStmt = DBA::select('config', ['k', 'v'], ['cat' => 'database']);
- while ($config = DBA::fetch($configStmt)) {
- $upd = intval(substr($config['k'], 7));
- if ($upd >= 1139 && $config['v'] != 'success') {
- $failed[] = $upd;
- }
- }
-
- if (!count($failed)) {
- $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [
- '$base' => $a->getBaseURL(true),
- '$banner' => L10n::t('No failed updates.'),
- '$check' => L10n::t('Check database structure'),
- ]);
- } else {
- $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [
- '$base' => $a->getBaseURL(true),
- '$banner' => L10n::t('Failed Updates'),
- '$desc' => L10n::t('This does not include updates prior to 1139, which did not return a status.'),
- '$mark' => L10n::t("Mark success \x28if update was manually applied\x29"),
- '$apply' => L10n::t('Attempt to execute this update step automatically'),
- '$failed' => $failed
- ]);
- }
-
- return $o;
- }
-}
+argc > 3 && $a->argv[2] === 'mark') {
+ // @TODO: Replace with parameter from router
+ $update = intval($a->argv[3]);
+ if ($update) {
+ Config::set('database', 'update_' . $update, 'success');
+ $curr = Config::get('system', 'build');
+ if (intval($curr) == $update) {
+ Config::set('system', 'build', intval($curr) + 1);
+ }
+ info(L10n::t('Update has been marked successful') . EOL);
+ }
+ $a->internalRedirect('admin/dbsync');
+ }
+
+ if ($a->argc > 2) {
+ if ($a->argv[2] === 'check') {
+ // @TODO Seems like a similar logic like Update::check()
+ $retval = DBStructure::update($a->getBasePath(), false, true);
+ if ($retval === '') {
+ $o .= L10n::t("Database structure update %s was successfully applied.", DB_UPDATE_VERSION) . "
";
+ Config::set('database', 'last_successful_update', DB_UPDATE_VERSION);
+ Config::set('database', 'last_successful_update_time', time());
+ } else {
+ $o .= L10n::t("Executing of database structure update %s failed with error: %s", DB_UPDATE_VERSION, $retval) . "
";
+ }
+ if ($a->argv[2] === 'check') {
+ return $o;
+ }
+ } elseif (intval($a->argv[2])) {
+ require_once 'update.php';
+
+ // @TODO: Replace with parameter from router
+ $update = intval($a->argv[2]);
+
+ $func = 'update_' . $update;
+
+ if (function_exists($func)) {
+ $retval = $func();
+
+ if ($retval === Update::FAILED) {
+ $o .= L10n::t("Executing %s failed with error: %s", $func, $retval);
+ } elseif ($retval === Update::SUCCESS) {
+ $o .= L10n::t('Update %s was successfully applied.', $func);
+ Config::set('database', $func, 'success');
+ } else {
+ $o .= L10n::t('Update %s did not return a status. Unknown if it succeeded.', $func);
+ }
+ } else {
+ $o .= L10n::t('There was no additional update function %s that needed to be called.', $func) . "
";
+ Config::set('database', $func, 'success');
+ }
+
+ return $o;
+ }
+ }
+
+ $failed = [];
+ $configStmt = DBA::select('config', ['k', 'v'], ['cat' => 'database']);
+ while ($config = DBA::fetch($configStmt)) {
+ $upd = intval(substr($config['k'], 7));
+ if ($upd >= 1139 && $config['v'] != 'success') {
+ $failed[] = $upd;
+ }
+ }
+
+ if (!count($failed)) {
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [
+ '$base' => $a->getBaseURL(true),
+ '$banner' => L10n::t('No failed updates.'),
+ '$check' => L10n::t('Check database structure'),
+ ]);
+ } else {
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [
+ '$base' => $a->getBaseURL(true),
+ '$banner' => L10n::t('Failed Updates'),
+ '$desc' => L10n::t('This does not include updates prior to 1139, which did not return a status.'),
+ '$mark' => L10n::t("Mark success \x28if update was manually applied\x29"),
+ '$apply' => L10n::t('Attempt to execute this update step automatically'),
+ '$failed' => $failed
+ ]);
+ }
+
+ return $o;
+ }
+}