Skip to content

Commit

Permalink
Full PHP versions as recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
agh1 committed Mar 12, 2020
1 parent 243b25d commit 8e7be2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
15 changes: 10 additions & 5 deletions CRM/Upgrade/Incremental/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ class CRM_Upgrade_Incremental_General {

/**
* The recommended PHP version.
*
* The point release will be dropped in recommendations unless it's .1 or
* higher.
*/
const RECOMMENDED_PHP_VER = '7.3';
const RECOMMENDED_PHP_VER = '7.3.0';

/**
* The previous recommended PHP version.
* The minimum recommended PHP version.
*
* A site running an earlier version will be told to upgrade.
*/
const MIN_RECOMMENDED_PHP_VER = '7.2';
const MIN_RECOMMENDED_PHP_VER = '7.2.0';

/**
* The minimum PHP version required to install Civi.
*
* @see install/index.php
*/
const MIN_INSTALL_PHP_VER = '7.1';
const MIN_INSTALL_PHP_VER = '7.1.0';

/**
* Compute any messages which should be displayed before upgrade.
Expand All @@ -54,7 +59,7 @@ public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $l
$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 PHP version %3.', [
1 => $latestVer,
2 => self::MIN_RECOMMENDED_PHP_VER,
3 => self::RECOMMENDED_PHP_VER,
3 => preg_replace(';^(\d+\.\d+(?:\.[1-9]\d*)?).*$;', '\1', self::RECOMMENDED_PHP_VER)
]);
$preUpgradeMessage .= '</p>';
}
Expand Down
8 changes: 4 additions & 4 deletions CRM/Utils/Check/Component/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function checkPhpVersion() {
ts('This system uses PHP version %1 which meets or exceeds the recommendation of %2.',
[
1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER,
2 => preg_replace(';^(\d+\.\d+(?:\.[1-9]\d*)?).*$;', '\1', CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER),
]),
ts('PHP Up-to-Date'),
\Psr\Log\LogLevel::INFO,
Expand All @@ -56,7 +56,7 @@ public function checkPhpVersion() {
[
1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
3 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER,
3 => preg_replace(';^(\d+\.\d+(?:\.[1-9]\d*)?).*$;', '\1', CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER),
]),
ts('PHP Out-of-Date'),
\Psr\Log\LogLevel::WARNING,
Expand All @@ -66,11 +66,11 @@ public function checkPhpVersion() {
else {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts('This system uses PHP version %1. To ensure the continued operation of CiviCRM, upgrade your server now. At least PHP version %2 is recommended; the preferrred version is %3.',
ts('This system uses PHP version %1. To ensure the continued operation of CiviCRM, upgrade your server now. At least PHP version %2 is recommended; the preferred version is %3.',
[
1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
3 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER,
3 => preg_replace(';^(\d+\.\d+(?:\.[1-9]\d*)?).*$;', '\1', CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER),
]),
ts('PHP Out-of-Date'),
\Psr\Log\LogLevel::ERROR,
Expand Down
2 changes: 1 addition & 1 deletion install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ public function requirePHPVersion($testDetails) {
$testDetails[2] = 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. The preferred version is %3.', array(
1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
3 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER,
3 => preg_replace(';^(\d+\.\d+(?:\.[1-9]\d*)?).*$;', '\1', CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER),
));
$this->warning($testDetails);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Upgrade/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testComposerRequirementMatch() {
$composerJson = json_decode(file_get_contents($composerJsonPath), 1);
$composerJsonRequirePhp = preg_replace(';[~^];', '', $composerJson['require']['php']);
$actualMajorMinor = preg_replace(';^[\^]*(\d+\.\d+)\..*$;', '\1', $composerJsonRequirePhp);
$expectMajorMinor = preg_replace(';^[\^]*(\d+\.\d+)\..*$;', '\1', \CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER);
$expectMajorMinor = preg_replace(';^(\d+\.\d+)\..*$;', '\1', \CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER);
$this->assertEquals($expectMajorMinor, $actualMajorMinor, "The PHP version requirements in CRM_Upgrade_Form ($expectMajorMinor) and composer.json ($actualMajorMinor) should specify same major+minor versions.");
}

Expand Down

0 comments on commit 8e7be2a

Please sign in to comment.