]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Update.php
Merge pull request #9039 from MrPetovan/task/frio-accent-scheme
[friendica.git] / src / Core / Update.php
index 7a03b3769513a3cc200b43a6fbd3ff3897f8ce7a..827029d50e184a52a5f93468cb0409d8242f657d 100644 (file)
@@ -127,7 +127,7 @@ class Update
 
                                        // run the pre_update_nnnn functions in update.php
                                        for ($x = $stored + 1; $x <= $current; $x++) {
-                                               $r = self::runUpdateFunction($x, 'pre_update');
+                                               $r = self::runUpdateFunction($x, 'pre_update', $sendMail);
                                                if (!$r) {
                                                        DI::config()->set('system', 'update', Update::FAILED);
                                                        DI::lock()->release('dbupdate');
@@ -156,7 +156,7 @@ class Update
 
                                        // run the update_nnnn functions in update.php
                                        for ($x = $stored + 1; $x <= $current; $x++) {
-                                               $r = self::runUpdateFunction($x, 'update');
+                                               $r = self::runUpdateFunction($x, 'update', $sendMail);
                                                if (!$r) {
                                                        DI::config()->set('system', 'update', Update::FAILED);
                                                        DI::lock()->release('dbupdate');
@@ -181,13 +181,14 @@ class Update
        /**
         * Executes a specific update function
         *
-        * @param int    $x      the DB version number of the function
-        * @param string $prefix the prefix of the function (update, pre_update)
-        *
+        * @param int    $x        the DB version number of the function
+        * @param string $prefix   the prefix of the function (update, pre_update)
+        * @param bool   $sendMail whether to send emails on success/failure
+
         * @return bool true, if the update function worked
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function runUpdateFunction($x, $prefix)
+       public static function runUpdateFunction($x, $prefix, bool $sendMail = true)
        {
                $funcname = $prefix . '_' . $x;
 
@@ -207,11 +208,13 @@ class Update
                                $retval = $funcname();
 
                                if ($retval) {
-                                       //send the administrator an e-mail
-                                       self::updateFailed(
-                                               $x,
-                                               DI::l10n()->t('Update %s failed. See error logs.', $x)
-                                       );
+                                       if ($sendMail) {
+                                               //send the administrator an e-mail
+                                               self::updateFailed(
+                                                       $x,
+                                                       DI::l10n()->t('Update %s failed. See error logs.', $x)
+                                               );
+                                       }
                                        Logger::error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
                                        DI::lock()->release('dbupdate_function');
                                        return false;