From 334461e1a0fbab563ae9dd0ab1bef18730aff018 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 12 Dec 2013 09:06:10 -0600
Subject: [PATCH] setup: Make mysqli extension requirement clearer

---
 include/class.setup.php          |  4 ++++
 include/class.upgrader.php       | 23 +++++++++++------------
 include/upgrader/prereq.inc.php  |  4 +++-
 setup/inc/install-prereq.inc.php |  2 +-
 4 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/include/class.setup.php b/include/class.setup.php
index f281da61b..cc13fe2f5 100644
--- a/include/class.setup.php
+++ b/include/class.setup.php
@@ -93,6 +93,10 @@ Class SetupWizard {
         return (extension_loaded('mysqli'));
     }
 
+    function check_mysql_version() {
+        return (version_compare(db_version(), $this->getMySQLVersion())>=0);
+    }
+
     function check_prereq() {
         return ($this->check_php() && $this->check_mysql());
     }
diff --git a/include/class.upgrader.php b/include/class.upgrader.php
index 69af4dfde..c08ff6c43 100644
--- a/include/class.upgrader.php
+++ b/include/class.upgrader.php
@@ -103,20 +103,16 @@ class Upgrader {
         return $this->getCurrentStream()->upgrade();
     }
 
-    function check_prereq() {
-        if ($this->getCurrentStream())
-            return $this->getCurrentStream()->check_prereq();
-    }
-    function check_php() {
-        if ($this->getCurrentStream())
-            return $this->getCurrentStream()->check_php();
-    }
-    function check_mysql() {
-        if ($this->getCurrentStream())
-            return $this->getCurrentStream()->check_mysql();
+    function __call($what, $args) {
+        if ($this->getCurrentStream()) {
+            $callable = array($this->getCurrentStream(), $what);
+            if (!is_callable($callable))
+                throw new Exception('InternalError: Upgrader method not callable: '
+                    . $what);
+            return call_user_func_array($callable, $args);
+        }
     }
 
-
     function getTask() {
         if($this->getCurrentStream())
             return $this->getCurrentStream()->getTask();
@@ -213,6 +209,9 @@ class StreamUpgrader extends SetupWizard {
         $this->migrater = null;
     }
 
+    function check_prereq() {
+        return (parent::check_prereq() && $this->check_mysql_version());
+    }
     function onError($error) {
         global $ost, $thisstaff;
 
diff --git a/include/upgrader/prereq.inc.php b/include/upgrader/prereq.inc.php
index ac2b0b2fe..98665cbc9 100644
--- a/include/upgrader/prereq.inc.php
+++ b/include/upgrader/prereq.inc.php
@@ -17,7 +17,9 @@ if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access D
                 <li class="<?php echo $upgrader->check_php()?'yes':'no'; ?>">
                 PHP v5.3 or greater - (<small><b><?php echo PHP_VERSION; ?></b></small>)</li>
                 <li class="<?php echo $upgrader->check_mysql()?'yes':'no'; ?>">
-                MySQL v5.0 or greater - (<small><b><?php echo extension_loaded('mysql')?'module loaded':'missing!'; ?></b></small>)</li>
+                MySQLi extension for PHP - (<small><b><?php echo extension_loaded('mysqli')?'module loaded':'missing!'; ?></b></small>)</li>
+                <li class="<?php echo $upgrader->check_mysql_version()?'yes':'no'; ?>">
+                MySQL v5.0 or greater - (<small><b><?php echo db_version(); ?></b></small>)</li>
             </ul>
             <h3>Highly Recommended:</h3>
             We highly recommend that you follow the steps below.
diff --git a/setup/inc/install-prereq.inc.php b/setup/inc/install-prereq.inc.php
index 37579a32a..90e0f176a 100644
--- a/setup/inc/install-prereq.inc.php
+++ b/setup/inc/install-prereq.inc.php
@@ -17,7 +17,7 @@ if(!defined('SETUPINC')) die('Kwaheri!');
                 <li class="<?php echo $installer->check_php()?'yes':'no'; ?>">
                 PHP v5.3 or greater - (<small><b><?php echo PHP_VERSION; ?></b></small>)</li>
                 <li class="<?php echo $installer->check_mysql()?'yes':'no'; ?>">
-                MySQL v5.0 or greater - (<small><b><?php echo extension_loaded('mysql')?'module loaded':'missing!'; ?></b></small>)</li>
+                MySQLi extension for PHP - (<small><b><?php echo extension_loaded('mysqli')?'module loaded':'missing!'; ?></b></small>)</li>
             </ul>
             <h3>Recommended:</h3>
             You can use osTicket without these, but you may not be able to use all features.
-- 
GitLab