aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-03 15:13:13 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-03 15:13:13 +0200
commit1da46025676d2aae84e4f90e8f6fef733ff156eb (patch)
treebc114b2a58f10ebf3422bfa297bfe135bbc9a896
parent98b6362c075167eb2260b8b07d7f5e5a56ab8601 (diff)
downloadvolse-hubzilla-1da46025676d2aae84e4f90e8f6fef733ff156eb.tar.gz
volse-hubzilla-1da46025676d2aae84e4f90e8f6fef733ff156eb.tar.bz2
volse-hubzilla-1da46025676d2aae84e4f90e8f6fef733ff156eb.zip
port db update improvements from zap
-rw-r--r--Zotlabs/Lib/DB_Upgrade.php9
-rw-r--r--Zotlabs/Module/Admin/Dbsync.php45
-rw-r--r--view/en/update_fail_eml.tpl21
-rwxr-xr-xview/tpl/failed_updates.tpl1
4 files changed, 67 insertions, 9 deletions
diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php
index 4038a2d53..b6e3f7b7b 100644
--- a/Zotlabs/Lib/DB_Upgrade.php
+++ b/Zotlabs/Lib/DB_Upgrade.php
@@ -58,10 +58,15 @@ class DB_Upgrade {
$c = new $cls();
+
$retval = $c->run();
if($retval != UPDATE_SUCCESS) {
+
+ $source = t('Source code of failed update: ') . "\n\n" . @file_get_contents('Zotlabs/Update/' . $s . '.php');
+
+
// Prevent sending hundreds of thousands of emails by creating
// a lockfile.
@@ -86,7 +91,9 @@ class DB_Upgrade {
'$sitename' => \App::$config['system']['sitename'],
'$siteurl' => z_root(),
'$update' => $x,
- '$error' => sprintf( t('Update %s failed. See error logs.'), $x)
+ '$error' => sprintf( t('Update %s failed. See error logs.'), $x),
+ '$baseurl' => z_root(),
+ '$source' => $source
]
)
]
diff --git a/Zotlabs/Module/Admin/Dbsync.php b/Zotlabs/Module/Admin/Dbsync.php
index 469af2aa5..183834301 100644
--- a/Zotlabs/Module/Admin/Dbsync.php
+++ b/Zotlabs/Module/Admin/Dbsync.php
@@ -19,7 +19,47 @@ class Dbsync {
info( t('Update has been marked successful') . EOL);
goaway(z_root() . '/admin/dbsync');
}
+
+ if(argc() > 3 && intval(argv(3)) && argv(2) === 'verify') {
+
+ $s = '_' . intval(argv(3));
+ $cls = '\\Zotlabs\Update\\' . $s ;
+ if(class_exists($cls)) {
+ $c = new $cls();
+ if(method_exists($c,'verify')) {
+ $retval = $c->verify();
+ if($retval === UPDATE_FAILED) {
+ $o .= sprintf( t('Verification of update %s failed. Check system logs.'), $s);
+ }
+ elseif($retval === UPDATE_SUCCESS) {
+ $o .= sprintf( t('Update %s was successfully applied.'), $s);
+ set_config('database',$s, 'success');
+ }
+ else
+ $o .= sprintf( t('Verifying update %s did not return a status. Unknown if it succeeded.'), $s);
+ }
+ else {
+ $o .= sprintf( t('Update %s does not contain a verification function.'), $s );
+ }
+ }
+ else
+ $o .= sprintf( t('Update function %s could not be found.'), $s);
+ return $o;
+
+
+
+
+
+ // remove the old style config if it exists
+ del_config('database', 'update_r' . intval(argv(3)));
+ set_config('database', '_' . intval(argv(3)), 'success');
+ if(intval(get_config('system','db_version')) < intval(argv(3)))
+ set_config('system','db_version',intval(argv(3)));
+ info( t('Update has been marked successful') . EOL);
+ goaway(z_root() . '/admin/dbsync');
+ }
+
if(argc() > 2 && intval(argv(2))) {
$x = intval(argv(2));
$s = '_' . $x;
@@ -28,14 +68,14 @@ class Dbsync {
$c = new $cls();
$retval = $c->run();
if($retval === UPDATE_FAILED) {
- $o .= sprintf( t('Executing %s failed. Check system logs.'), $s);
+ $o .= sprintf( t('Executing update procedure %s failed. Check system logs.'), $s);
}
elseif($retval === UPDATE_SUCCESS) {
$o .= sprintf( t('Update %s was successfully applied.'), $s);
set_config('database',$s, 'success');
}
else
- $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $s);
+ $o .= sprintf( t('Update %s did not return a status. It cannot be determined if it was successful.'), $s);
}
else
$o .= sprintf( t('Update function %s could not be found.'), $s);
@@ -59,6 +99,7 @@ class Dbsync {
'$banner' => t('Failed Updates'),
'$desc' => '',
'$mark' => t('Mark success (if update was manually applied)'),
+ '$verify' => t('Attempt to verify this update if a verification procedure exists'),
'$apply' => t('Attempt to execute this update step automatically'),
'$failed' => $failed
));
diff --git a/view/en/update_fail_eml.tpl b/view/en/update_fail_eml.tpl
index 86bb61aaa..c42ea90c4 100644
--- a/view/en/update_fail_eml.tpl
+++ b/view/en/update_fail_eml.tpl
@@ -1,13 +1,22 @@
-Hey,
-I'm the web server at {{$sitename}};
+Apologies but this may be urgent.
+
+This is the web server at {{$sitename}};
-The Hubzilla developers released update {{$update}} recently,
-but when I tried to install it, something went terribly wrong.
+The project developers released update {{$update}} recently,
+but during the attempt to automatically install it, something went terribly wrong.
This needs to be fixed soon and it requires human intervention.
Please contact a project developer if you can not figure out how to
-fix it on your own. My database might be invalid.
+fix it on your own. Your web server database configuration might be invalid.
The error message is '{{$error}}'.
+You may attempt to re-apply this update by visiting
+
+{{$baseurl}}/admin/dbsync
+
+while logged into the admin account.
+
+{{$source}}
+
Apologies for the inconvenience,
- your web server at {{$siteurl}} \ No newline at end of file
+ your web server at {{$siteurl}}
diff --git a/view/tpl/failed_updates.tpl b/view/tpl/failed_updates.tpl
index f53f1f478..598171b87 100755
--- a/view/tpl/failed_updates.tpl
+++ b/view/tpl/failed_updates.tpl
@@ -9,6 +9,7 @@
<h4>{{$f}}</h4>
<ul>
<li><a href="{{$base}}/admin/dbsync/mark/{{$f}}">{{$mark}}</a></li>
+<li><a href="{{$base}}/admin/dbsync/verify/{{$f}}">{{$verify}}</a></li>
<li><a href="{{$base}}/admin/dbsync/{{$f}}">{{$apply}}</a></li>
</ul>