Skip to content

Commit

Permalink
Merge pull request #10851 from seamuslee001/CRM-20941
Browse files Browse the repository at this point in the history
CRM-20941 Bump Minimum PHP Version to 5.6, Add in pre-upgrade message…
  • Loading branch information
eileenmcnaughton authored Aug 16, 2017
2 parents 46bba86 + ba71cae commit bb03830
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
35 changes: 28 additions & 7 deletions CRM/Upgrade/Incremental/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class CRM_Upgrade_Incremental_General {
/**
* The recommended PHP version.
*/
const MIN_RECOMMENDED_PHP_VER = '5.5';
const MIN_RECOMMENDED_PHP_VER = '5.6';

/**
* The previous recommended PHP version.
*/
const PREVIOUS_MIN_RECOMMENDED_PHP_VER = '5.5';

/**
* The minimum PHP version required to install Civi.
Expand All @@ -65,13 +70,29 @@ class CRM_Upgrade_Incremental_General {
* @param $latestVer
*/
public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
$dateFormat = Civi::Settings()->get('dateformatshortdate');
if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) {
$preUpgradeMessage .= '<p>' .
ts('This webserver is running an outdated version of PHP (%1). It is strongly recommended to upgrade to PHP %2 or later, as older versions can present a security risk.', array(
1 => phpversion(),
2 => self::MIN_RECOMMENDED_PHP_VER,
)) .
'</p>';
$preUpgradeMessage .= '<p>';
// CRM-20941 PHP 5.3 end date of End of 2017, PHP 5.4 End date End of Feb 2018 Recommend anyone on PHP 5.5 to move up to 5.6 or later e.g. 7.0
if (version_compare(phpversion(), self::PREVIOUS_MIN_RECOMMENDED_PHP_VER) >= 0) {
$preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but future releases will require PHP %2 or above. We recommend you use the most recent php version you can', array(
1 => $currentVer,
2 => self::MIN_RECOMMENDED_PHP_VER,
));
}
elseif (version_compare(phpversion(), 5.5) < 0) {
$date = CRM_Utils_Date::customFormat('2018-02-28', $dateFormat);
if (version_compare(phpversion(), 5.4) < 0) {
$date = CRM_Utils_Date::customFormat('2017-12-31', $dateFormat);
}
$preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but PHP %2 will not work in releases published after %3. We recommend you use the most recent php version you can. For more explanation see <a href="%4">the announcement</a>', array(
1 => $currentVer,
2 => phpversion(),
3 => $date,
4 => 'https://civicrm.org/blog/totten/end-of-zombies-php-53-and-54',
));
}
$preUpgradeMessage .= '</p>';
}

// http://issues.civicrm.org/jira/browse/CRM-13572
Expand Down
17 changes: 13 additions & 4 deletions CRM/Utils/Check/Component/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function checkPhpVersion() {
'fa-server'
);
}
elseif (version_compare(phpversion(), CRM_Upgrade_Incremental_General::MIN_DEFECT_PHP_VER) >= 0) {
elseif (version_compare(phpversion(), CRM_Upgrade_Incremental_General::PREVIOUS_MIN_RECOMMENDED_PHP_VER) >= 0) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts('This system uses PHP version %1. While this meets the minimum requirements for CiviCRM to function, upgrading to PHP version %2 or newer is recommended for maximum compatibility.',
Expand All @@ -66,13 +66,22 @@ public function checkPhpVersion() {
);
}
else {
$date = '';
$dateFormat = Civi::Settings()->get('dateformatshortdate');
if (version_compare(phpversion(), 5.4) < 0) {
$date = CRM_Utils_Date::customFormat('2017-12-31', $dateFormat);
}
elseif (version_compare(phpversion(), 5.5) < 0) {
$date = CRM_Utils_Date::customFormat('2018-02-28', $dateFormat);
}
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts('This system uses PHP version %1. CiviCRM can be installed on this version, but some specific features are known to fail or degrade. Version %3 is the bare minimum to avoid known issues, and version %2 is recommended.',
ts('This system uses PHP version %1. CiviCRM can be installed on this version. However PHP version %1 will not work in releases published after %2, and version %3 is recommended. For more explanation see <a href="%4"> the announcement</a>',
array(
1 => phpversion(),
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
3 => CRM_Upgrade_Incremental_General::MIN_DEFECT_PHP_VER,
2 => $date,
3 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
4 => 'https://civicrm.org/blog/totten/end-of-zombies-php-53-and-54',
)),
ts('PHP Out-of-Date'),
\Psr\Log\LogLevel::WARNING,
Expand Down

0 comments on commit bb03830

Please sign in to comment.