]> git.mxchange.org Git - friendica.git/commitdiff
Possible fix issue 4611: Don't write to database before it is created
authorMichael <heluecht@pirati.ca>
Sat, 17 Mar 2018 09:04:38 +0000 (09:04 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 17 Mar 2018 09:04:38 +0000 (09:04 +0000)
mod/install.php
src/Database/DBStructure.php

index 3adcb75aa45b007ab234fd6418bbccb8769cb3f8..4b4940d2777e27ec1a4ef33b6317fe4f1c41e820 100644 (file)
@@ -540,7 +540,7 @@ function load_database_rem($v, $i) {
 }
 
 function load_database() {
-       $errors = DBStructure::update(false, true);
+       $errors = DBStructure::update(false, true, true);
 
        return $errors;
 }
index a1ef3374f9d6833ae41c103c61d99047522a307c..b8eea03e1121f001438d98bf1005b5f90913a4c6 100644 (file)
@@ -203,8 +203,8 @@ class DBStructure
         * @param array $definition An array of the definition tables
         * @return string Empty string if the update is successful, error messages otherwise
         */
-       public static function update($verbose, $action, array $tables = null, array $definition = null) {
-               if ($action) {
+       public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
+               if ($action && !$install) {
                        Config::set('system', 'maintenance', 1);
                        Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e')));
                }
@@ -455,7 +455,9 @@ class DBStructure
                                }
 
                                if ($action) {
-                                       Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
+                                       if (!$install) {
+                                               Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
+                                       }
 
                                        // Ensure index conversion to unique removes duplicates
                                        if ($is_unique && ($temp_name != $name)) {
@@ -505,15 +507,15 @@ class DBStructure
                        }
                }
 
-               if ($action) {
+               if ($action && !$install) {
                        Config::set('system', 'maintenance', 0);
                        Config::set('system', 'maintenance_reason', '');
-               }
 
-               if ($errors) {
-                       Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
-               } else {
-                       Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
+                       if ($errors) {
+                               Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
+                       } else {
+                               Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
+                       }
                }
 
                return $errors;