]> git.agnieray.net Git - galette.git/commitdiff
Chekc PHP version before trying to load 3rd party deps
authorJohan Cwiklinski <johan@x-tnd.be>
Fri, 12 Jan 2024 15:29:29 +0000 (16:29 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sat, 13 Jan 2024 11:19:57 +0000 (12:19 +0100)
closes #1768

galette/webroot/compat_test.php
galette/webroot/index.php

index fab2d8c9b5a6910067122bb10bba51fc36d2fcc1..ac33426b487a37c0bf02b84c2b960771707c960d 100644 (file)
@@ -35,7 +35,6 @@
  */
 
 define('GALETTE_ROOT', __DIR__ . '/../');
-require_once GALETTE_ROOT . '/vendor/autoload.php';
 require_once GALETTE_ROOT . 'config/versions.inc.php';
 require_once GALETTE_ROOT . 'config/paths.inc.php';
 
@@ -43,9 +42,11 @@ $phpok = !version_compare(PHP_VERSION, GALETTE_PHP_MIN, '<');
 $php_message = PHP_VERSION;
 if (!$phpok) {
     $php_message .= sprintf(' (%s minimum required)', GALETTE_PHP_MIN);
+} else {
+    require_once GALETTE_ROOT . '/vendor/autoload.php';
+    $cm = new Galette\Core\CheckModules(false);
+    $cm->doCheck(false); //do not load with translations!
 }
-$cm = new Galette\Core\CheckModules(false);
-$cm->doCheck(false); //do not load with translations!
 ?>
 <html>
     <head>
@@ -66,6 +67,7 @@ $cm->doCheck(false); //do not load with translations!
                         <div id="main" class="text ui container">
                 <?php
                 if (!$phpok
+                    || !isset($cm)
                     || !$cm->isValid()
                 ) {
                     echo '<p class="ui red center aligned message">Something is wrong :(</p>';
@@ -79,11 +81,13 @@ $cm->doCheck(false); //do not load with translations!
                                     <span><i class="ui <?php echo ($phpok) ? 'green check' : 'red times'; ?> icon"></i></span>
                                 </li>
                 <?php
-                echo $cm->toHtml(false);
+                if (isset($cm)) {
+                    echo $cm->toHtml(false);
+                }
                 ?>
                             </ul>
                 <?php
-                if ($cm->isValid() && $phpok) {
+                if ($phpok && isset($cm) && $cm->isValid()) {
                     echo '<p class="ui center aligned message">You can now <a href="./installer.php">install Galette</a></p>';
                 }
                 ?>
index d9e4d79ebbd0133d70edb48dfeafea0371bf03b7..b5964172b90f5ba76493351c0e60022350d67eb9 100644 (file)
@@ -41,14 +41,20 @@ if (!defined('GALETTE_BASE_PATH')) {
 
 define('GALETTE_ROOT', __DIR__ . '/../');
 
+// check PHP version
+require_once GALETTE_ROOT . 'config/versions.inc.php';
+if (version_compare(PHP_VERSION, GALETTE_PHP_MIN, '<')) {
+    header('location: ' . GALETTE_BASE_PATH . 'compat_test.php');
+    die(1);
+}
+
 // check PHP modules
 require_once GALETTE_ROOT . '/vendor/autoload.php';
-require_once GALETTE_ROOT . 'config/versions.inc.php';
 
 $cm = new Galette\Core\CheckModules(false);
 $cm->doCheck(false); //do not load with translations!
 
-if (version_compare(PHP_VERSION, GALETTE_PHP_MIN, '<') || !$cm->isValid()) {
+if (!$cm->isValid()) {
     header('location: ' . GALETTE_BASE_PATH . 'compat_test.php');
     die(1);
 }