+
+ /**
+ * send the email and do what is needed to do on update fails
+ *
+ * @param int $update_id number of failed update
+ * @param string $error_message error message
+ */
+ private static function updateFailed($update_id, $error_message) {
+ //send the administrators an e-mail
+ $admin_mail_list = "'".implode("','", array_map(['Friendica\Database\DBA', 'escape'], explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'";
+ $adminlist = DBA::select('user', ['uid', 'language', 'email'], ['`email` IN (%s)', $admin_mail_list]);
+
+ // No valid result?
+ if (!DBA::isResult($adminlist)) {
+ Logger::log(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), Logger::INFO);
+
+ // Don't continue
+ return;
+ }
+
+ // every admin could had different language
+ foreach ($adminlist as $admin) {
+ $lang = (($admin['language'])?$admin['language']:'en');
+ L10n::pushLang($lang);
+
+ $preamble = Strings::deindent(L10n::t("
+ The friendica developers released update %s recently,
+ but when I tried to install it, something went terribly wrong.
+ This needs to be fixed soon and I can't do it alone. Please contact a
+ friendica developer if you can not help me on your own. My database might be invalid.",
+ $update_id));
+ $body = L10n::t("The error message is\n[pre]%s[/pre]", $error_message);
+
+ notification([
+ 'uid' => $admin['uid'],
+ 'type' => SYSTEM_EMAIL,
+ 'to_email' => $admin['email'],
+ 'preamble' => $preamble,
+ 'body' => $body,
+ 'language' => $lang]
+ );
+ L10n::popLang();
+ }
+
+ //try the logger
+ Logger::log("CRITICAL: Database structure update failed: " . $error_message);
+ }
+
+ private static function updateSuccessfull($from_build, $to_build)
+ {
+ //send the administrators an e-mail
+ $admin_mail_list = "'".implode("','", array_map(['Friendica\Database\DBA', 'escape'], explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'";
+ $adminlist = DBA::select('user', ['uid', 'language', 'email'], ['`email` IN (%s)', $admin_mail_list]);
+
+ if (DBA::isResult($adminlist)) {
+ // every admin could had different language
+ foreach ($adminlist as $admin) {
+ $lang = (($admin['language']) ? $admin['language'] : 'en');
+ L10n::pushLang($lang);
+
+ $preamble = Strings::deindent(L10n::t("
+ The friendica database was successfully updated from %s to %s.",
+ $from_build, $to_build));
+
+ notification([
+ 'uid' => $admin['uid'],
+ 'type' => SYSTEM_EMAIL,
+ 'to_email' => $admin['email'],
+ 'preamble' => $preamble,
+ 'body' => $preamble,
+ 'language' => $lang]
+ );
+ L10n::popLang();
+ }
+ }
+
+ //try the logger
+ Logger::log("Database structure update successful.", Logger::TRACE);
+ }