Added check for insufficient PHP version during upgrade
authorAlexander Ebert <ebert@woltlab.com>
Thu, 23 Feb 2017 12:24:00 +0000 (13:24 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 23 Feb 2017 12:24:00 +0000 (13:24 +0100)
wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_pre_sql.php

index 10af0fc76920ef5ba07444356bafb2fd53aa9f36..89beb3bda8bcdd84ab3626a98ec8526287932099 100644 (file)
@@ -1,6 +1,19 @@
 <?php
+use wcf\system\exception\SystemException;
 use wcf\system\WCF;
 
+$phpVersion = phpversion();
+$comparePhpVersion = preg_replace('/^(\d+\.\d+\.\d+).*$/', '\\1', $phpVersion);
+$neededPhpVersion = '5.5.4';
+if (!(version_compare($comparePhpVersion, $neededPhpVersion) >= 0)) {
+       $message = "Your PHP version '{$phpVersion}' is insufficient for installation of this software. PHP version {$neededPhpVersion} or greater is required.";
+       if (WCF::getLanguage()->getFixedLanguageCode() === 'de') {
+               $message = "Ihre PHP Version '{$phpVersion}' ist unzureichend f&uuml;r die Installation dieser Software. PHP Version {$neededPhpVersion} oder h&ouml;her wird ben&ouml;tigt.";
+       }
+       
+       throw new SystemException($message);
+}
+
 // change encoding of wcf1_acp_session; necessary for foreign key in wcf1_acp_session_virtual
 $sql = "ALTER TABLE wcf".WCF_N."_acp_session CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
 $statement = WCF::getDB()->prepareStatement($sql);
@@ -24,7 +37,8 @@ $statement->execute();
 // create virtual session for current user
 $sql = "INSERT INTO wcf".WCF_N."_acp_session_virtual (sessionID, ipAddress, userAgent, lastActivityTime) SELECT sessionID, ipAddress, userAgent, lastActivityTime FROM wcf".WCF_N."_acp_session WHERE sessionID = ?";
 $statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
-$statement->execute([WCF::getSession()->sessionID]);
+// WARNING: do not use [...] array syntax here, as this file is also used to check for PHP 5.5+
+$statement->execute(array(WCF::getSession()->sessionID));
 
 // create session cookie
 @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX . 'cookieHash_acp').'='.rawurlencode(WCF::getSession()->sessionID).'; path=/'.(\wcf\system\request\RouteHandler::secureConnection() ? '; secure' : '').'; HttpOnly', false);