Seeing as D8 now requires php 5.3, Dries noted that we are only checking for php vers on install, and it does not check on upgrade.

This issue is to put a check in one of the instances of hook_update_N to require php 5.3.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cameron Tod’s picture

Is this check intended to be included as a hook_update_N implementation in an install profile, or would it be better as a fatal error in update.php?

steve.colson’s picture

I would think it should be a fatal error. How or where it is thrown I suppose is certainly up for discussion.

catch’s picture

We have a nice requirement check screen the first page of install.php (if there are environment errors), it'd be good to have the same on update.php. I thought we did at one point but perhaps not.

kotnik’s picture

Actually, install.php exits immediately if PHP requirement isn't met. Should it be implemented in update.php in the same manner?

marcingy’s picture

Status: Active » Needs review
FileSize
1.76 KB

Basically a straight lift from install.php.

Status: Needs review » Needs work

The last submitted patch, empty-cache-1402962.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
FileSize
819 bytes

Meh

xjm’s picture

Status: Needs review » Reviewed & tested by the community

This seems like the right approach to me.

Dries’s picture

vortex:drupal-head dries$ grep -r "Your PHP" *
core/install.php:  print 'Your PHP installation is too old. Drupal requires at least PHP 5.3.2. See the <a href="http://drupal.org/requirements">system requirements</a> page for more information.';
core/modules/system/system.install:    $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));

It looks like system.install does a check as part of system_requirements().

Do we not run hook_requirements as part of the site installation or site upgrade process?

Cameron Tod’s picture

Hook requirements is definitely run as part of the site install and update procedure, so I guess this bug is moot.

A quick test:

██ cam8001 @ /var/www/drupal-8-trunk
██ 22:47:40 $ git diff core/modules/system/system.install 
diff --git a/core/modules/system/system.install b/core/modules/system/system.ins
index 7a275e8..3422056 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -54,7 +54,7 @@ function system_requirements($phase) {
   );
 
   // Test PHP version and show link to phpinfo() if it's available
-  $phpversion = phpversion();
+  $phpversion = 5.1;
   if (function_exists('phpinfo')) {
     $requirements['php'] = array(
       'title' => $t('PHP'),


██ cam8001 @ /var/www/drupal-8-trunk
██ 22:47:53 $ drush updb
Your PHP installation is too old. Drupal requires at least PHP 5.3.2.[warning]
(Currently using PHP 5.1)
No database updates required                                         [success]
Finished performing updates.                                         [ok]
xjm’s picture

Re: #10, I thought the issue was not that a message was not shown, but that errors appeared before the check?

Maybe someone should actually test it on 5.2. :)

xjm’s picture

FileSize
17.92 KB
10.78 KB

Okay, I just tested on 5.2, and yes, this issue is necessary. Here's why:

install.png

update.png

Cameron Tod’s picture

Quite right, confirmed here too under PHP 5.2.17.

Parse error: syntax error, unexpected T_CONST in /Users/cam8001/Sites/drupal-8-trunk/core/update.php on line 31

However, the patch doesn't appear to work. I assume the whole file is parsed before any code is run, which means that PHP < 5.3 will raise a fatal error as soon as it finds any unsupported syntax.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Mmm, but the patch does not actually resolve the issue. It still contains a const keyword, so it fails as the file is parsed.

We need to use define here as well:

const MAINTENANCE_MODE = 'update';
xjm’s picture

Status: Needs work » Needs review
FileSize
1.29 KB

Attached uses the same strategy as in install.php. This resolves the issue for me locally under 5.2.

Cameron Tod’s picture

Patch works well for me here too, tested with PHP 5.2.17.

catch’s picture

This looks good to me. The system_requirements() check works if we were to raise the minimum requirement to 5.3.4 or similar, we could leave this workaround as is at 5.3.2 in that case.

If we wanted to we could make the update.php/install.php check for 5.3.0 so there's a pretty error message between the syntax error and things working, but I don't think anyone runs > 5.3.0 and < 5.3.2 anyway so that's probably moot at the moment.

kotnik’s picture

Tested patch from #15. All OK.

xjm’s picture

Yeah, I think it's good to give folks with PHP 5.3.0 the workaround message as well.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

this looks good to go for me.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! Committed/pushed to 8.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

MD3’s picture

Category: task » bug

I ran into this issue when I went to: mydomain.com/drupal/
The error message when you go directly to your new Drupal install is (from the latest dev):
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/martindavisiii/d8.md3productions.com/drupal/core/includes/bootstrap.inc on line 3

However, the nicely formatted error message below does show up if you go to: mydomain.com/drupal/core/install.php
Your PHP installation is too old. Drupal requires at least PHP 5.3.3. See the system requirements page for more information.

For more information and discussion on this issue, please see:
#1463564: Drupal 8 does not work with PHP 5.3.2 (the version shipped with Ubuntu 10.04 LTS)