]> git.agnieray.net Git - galette.git/commitdiff
Fix web installer
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 9 May 2021 00:00:07 +0000 (02:00 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 9 May 2021 00:00:07 +0000 (02:00 +0200)
galette/install/steps/db_select_version.php
galette/lib/Galette/Core/Install.php
galette/lib/Galette/Core/Preferences.php

index 3a8a05bc4ad3cf7fb789c0e852de308d4b090f13..c753c7fb3685af921664b5f6a7967cdf3e9768b8 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2013-2014 The Galette Team
+ * Copyright © 2013-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2013-2014 The Galette Team
+ * @copyright 2013-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.8 - 2013-07-21
@@ -87,6 +87,7 @@ if (count($versions) == 0) {
                     <ul class="leaders">
     <?php
     $is_current = false;
+    $previous = null;
     foreach ($versions as $version) {
         ?>
                     <li>
@@ -115,7 +116,7 @@ if (count($versions) == 0) {
                             </label>
                         </span>
                         <span>
-                        <input type="radio" name="previous_version" value="<?php echo $version; ?>" id="upgrade-<?php echo $version; ?>"<?php if ($is_current) { echo ' checked="checked"'; }; ?> required/>
+                        <input type="radio" name="previous_version" value="<?php echo $previous ?? $version; ?>" id="upgrade-<?php echo $version; ?>"<?php if ($is_current) { echo ' checked="checked"'; }; ?> required/>
                         </span>
         <?php
         if ($is_current) {
@@ -126,6 +127,7 @@ if (count($versions) == 0) {
 
                     </li>
     <?php
+        $previous = $version;
     }
     ?>
                     </ul>
index da143c87b898f4208a642990e3115dbb64ae0ccb..bc16b85ae3bd969c56d0d594df9c17ed637a297c 100644 (file)
@@ -635,7 +635,6 @@ class Install
         $scripts_path = ($spath ?? GALETTE_ROOT . '/install') . '/scripts/';
 
         foreach ($update_scripts as $key => $val) {
-            $sql_query = '';
             if (substr($val, -strlen('.sql')) === '.sql') {
                 //just a SQL script, run it
                 $script = fopen($scripts_path . $val, 'r');
@@ -646,10 +645,15 @@ class Install
                     );
                 }
 
-                $sql_query .= @fread(
+                $sql_query = @fread(
                     $script,
                     @filesize($scripts_path . $val)
                 ) . "\n";
+
+                $sql_res = $this->executeSql($zdb, $sql_query);
+                if (!$sql_res) {
+                    $fatal_error = true;
+                }
             } else {
                 //we got an update class
                 include_once $scripts_path . $val;
@@ -695,13 +699,10 @@ class Install
                 }
             }
 
-            if ($sql_query !== '') {
-                $sql_res = $this->executeSql($zdb, $sql_query);
-                $fatal_error = !$sql_res;
-                if ($fatal_error) {
-                    break;
-                }
-            }
+            Analog::log(
+                str_replace('%s', $key, 'Upgrade to %s complete'),
+                Analog::INFO
+            );
         }
 
         return !$fatal_error;
index 8b53e5bd038ba2546829b015fc99e83c8d3428a5..6d707f738879458b0ba93e996b2b909338030935 100644 (file)
@@ -324,6 +324,9 @@ class Preferences
         $params = array();
         foreach (self::$defaults as $k => $v) {
             if (!isset($this->prefs[$k])) {
+                if ($k == 'pref_admin_pass' && $v == 'admin') {
+                    $v = password_hash($v, PASSWORD_BCRYPT);
+                }
                 $this->prefs[$k] = $v;
                 Analog::log(
                     'The field `' . $k . '` does not exists, Galette will attempt to create it.',