Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1528 - Consolidate to single constant for minimum PHP version #16753

Merged
merged 2 commits into from
Apr 2, 2020

Conversation

agh1
Copy link
Contributor

@agh1 agh1 commented Mar 11, 2020

Overview

There have been two constants that handle the minimum PHP version: CRM_Upgrade_Form::MINIMUM_PHP_VERSION (for upgrades) and CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER (for new installs). They were allowed to deviate in #14437 with the intention of making a softer transition to PHP 7. However, dev/drupal#79 illustrated a situation where sites with PHP 5.6 would be allowed to upgrade and immediately run into a fatal error.

Since then, tests have been added to enforce constants in civicrm-drupal, civicrm-wordpress, civicrm-backdrop, and composer.json being equal to CRM_Upgrade_Form::MINIMUM_PHP_VERSION. In discussion on dev/core#1528 @totten indicated that there's little need or desire for there to be different minimums for upgrades and new installs.

In that case, there's no reason for separate constants: all they'll do is confuse everyone. This PR consolidates the two into CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER since it sits alongside the constants for the recommended PHP version and the minimum-recommended PHP version.

Before

Upgrades and tests in other repos look to one constant, while new installs and the system check look to another.

After

There is a single constant for the minimum allowable PHP version: CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER. The minimum PHP version for upgrades may never deviate from the minimum PHP version for new installations.

Comments

PRs forthcoming for civicrm-drupal, civicrm-wordpress, and civicrm-backdrop since they look to CRM_Upgrade_Form::MINIMUM_PHP_VERSION.

@civibot
Copy link

civibot bot commented Mar 11, 2020

(Standard links)

* Tip: Keep in sync with composer.json ("config => platform => php")
*/
const MINIMUM_PHP_VERSION = '7.1.0';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For removing MINIMUM_PHP_VERSION, we'd probably want to sequence the merges s.t. references are first removed from civicrm-{backdrop,wordpress,drupal}.git and lastly civicrm-core.git.

Or if you go the other way (replacing MIN_INSTALL_PHP_VER), then I think it only needs one patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about merging the other repos first. I think it belongs in CRM_Upgrade_Incremental_General both because the other PHP versions are defined there and because that class is intended as a general utility class rather than a form class.

agh1 added a commit to agh1/civicrm-wordpress that referenced this pull request Mar 12, 2020
@agh1
Copy link
Contributor Author

agh1 commented Mar 12, 2020

I updated the other repos because they were running into test failures along the lines that 7.1 doesn't equal 7.1.0 (including using version_compare(), interestingly enough). Anyway, I updated and standardized regex along the lines that CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER can be major.minor or major.minor.point without causing problems. If the point release is .0, it's treated as if it isn't there: 7.1 and 7.1.0 both resolve to 7.1, even as 7.1.9 will be considered as all three parts. This isn't necessary now, but theoretically CiviCRM could require a point release as a minimum.

@eileenmcnaughton
Copy link
Contributor

@agh1 there is a style issue

@seamuslee001
Copy link
Contributor

I agree with this I don't know which define is better but this at least migrates to just one

@agh1 agh1 force-pushed the consolidated-php-version branch from 8e7be2a to f955c30 Compare March 12, 2020 14:18
@agh1
Copy link
Contributor Author

agh1 commented Mar 12, 2020

@eileenmcnaughton i updated the missing comma--thanks

@totten
Copy link
Member

totten commented Mar 13, 2020

The related PRs for civicrm-wordpress@master, civicrm-backdrop@1.x-master, and civicrm-drupal@7.x-master have all been merged. :)

I also double-checked that civicrm-drupal@6.x-master, civicrm-drupal-8@master, and civicrm-joomla@master do not use MINIMUM_PHP_VERSION. That's maybe a hint that they merit some kind of update (to show better errors on incompatible deployments), but it's not a prerequisite for this PR.

@totten totten changed the title Consolidate to single constant for minimum PHP version dev/core#1528 - Consolidate to single constant for minimum PHP version Mar 20, 2020
@totten
Copy link
Member

totten commented Apr 2, 2020

I've done some r-run on D7 with alternating PHP versions (7.0 and 7.1). Confirmed that the install screen, status-check, and upgrade screen all continue to report a sensible error on the unsupported PHP version - while also giving gentler warnings on 7.1.

Looks good to merge.

@totten totten merged commit 8ca9526 into civicrm:master Apr 2, 2020
bastienho pushed a commit to bastienho/civicrm-wordpress that referenced this pull request Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants