(dev/drupal#79) Fail more gracefully when upgrading on PHP 5.x #584
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This version requirement officially went up to PHP 7.0 circa Civi 5.14.
However, at that time, the upgrade metadata was kept at PHP 5.6 to allow
somewhat softer landing for stragglers. That's no longer possible in Civi
5.16+,
This just gives a clearer error when someone tries to upgrade with PHP 5.x.
Before
When upgrading via drush or Drupal web UI on PHP 5.6, the Civi class-loader fails to initialize.
(Approximate call-path:
civicrm.drush.inc | civicrm.module
=>civicrm.settings.php
=>CRM_Core_ClassLoader
=>vendor/autoload.php
=>vendor/league/csv/src/functions.php
)After
When upgrading via drush on PHP 5.6, the error points to the actual problem.
When upgrading via web UI on PHP 5.6, the error message is similar:
(Note: I tweaked the text to emphasize that the PHP version is determined by
the "drush" or "web server" environment - in some systems, these are
different environments with different PHP versions. A phrase like "your
version" can be confusing/misleading in those cases.)
Comments
The canonical representation of the minimum PHP version is in
$civicrm_root/CRM/Upgrade/Form.php
. However, correctly reading thatmetadata requires loading
civicrm.settings.php
, which triggers the crash.To work around this, we reproduce the constant and use a unit-test to ensure
its continued accuracy.
Also, it seems useful to put the same metadata in
civicrm.info
. I'm notsure if D7 uses this in a meaningful way, but it's good to be accurate.