See xjm's comment in #1463564: Drupal 8 does not work with PHP 5.3.2 (the version shipped with Ubuntu 10.04 LTS). We should not use 'use' statements in install/update files, at least until we're able to display a decent fail message rather than a syntax error.

CommentFileSizeAuthor
#7 fresh-clone.png13.89 KBxjm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Title: No graceful fail on installer » Install/update has syntax error instead of graceful fail for < 5.3
David_Rothstein’s picture

I'm confused how this happens (but don't have PHP 5.2 handy to test). Stripped of code comments, install.php, for example, looks like this:

chdir('..');
define('DRUPAL_ROOT', getcwd());
define('MAINTENANCE_MODE', 'install');
if (version_compare(PHP_VERSION, '5.3.3') < 0) {
  print 'Your PHP installation is too old. Drupal requires at least PHP 5.3.3. See the <a href="http://drupal.org/requirements">system requirements</a> page for more information.';
  exit;
}

// Start the installer.
require_once DRUPAL_ROOT . '/core/includes/install.core.inc';
install_drupal();

There are no "use" statements in this file; those only happen once install.core.inc is loaded. So doesn't the script exit before there is ever a problem?

Crell’s picture

The use statement doesn't matter. As soon as we hit a namespaced class name instead, there will still be a parse error.

The only alternative would be to only use non-namespaced code in the installer, or portions of the installer, which strikes me as a foolish no-go. We syntax error on PHP 4. By the time Drupal 8 ships, PHP 5.3 will already be in security-only status. 5.2 will be dead dead dead.

(The PHP internals team is stepping up their release schedule, with plans for an actual schedule and scheduled deprecation of older releases rather than the long tail of support as in the past. See https://wiki.php.net/rfc/releaseprocess )

I say this is a won't fix.

catch’s picture

I'm not sure why it happens either, and also don't have 5.2 to test with, but let's see if there's a simple way to fix it (we already had the same thing with the define() -> const patch and worked around that without killing anyone).

If this is indeed won't fix, then we should remove the attempts to print an error message early altogether, since afaik it should be possible to print the requirements report with 5.3.0 - 5.3.2 without hitting a syntax error.

Crell’s picture

The only way to bypass those syntax errors, I think, would be for install.php to be something like:

if (version_compare(...)) {
  include('real_install.inc');
  drupal_install();
}
else {
  // Print error message that doesn't require the theme system.
}

We may be able to get away with that for install and update, but not for index.php since that would be hit on every request.

catch’s picture

Crell, if you look at install.php, that's more or less what we have already:


// Exit early if running an incompatible PHP version to avoid fatal errors.
// The minimum version is specified explicitly, as DRUPAL_MINIMUM_PHP is not
// yet available. It is defined in bootstrap.inc, but it is not possible to
// load that file yet as it would cause a fatal error on older versions of PHP.
if (version_compare(PHP_VERSION, '5.3.3') < 0) {
  print 'Your PHP installation is too old. Drupal requires at least PHP 5.3.3. See the <a href="http://drupal.org/requirements">system requirements</a> page for more information.';
  exit;
}

I'll ping xjm to see if she still has PHP 5.2 handy to test on.

xjm’s picture

FileSize
13.89 KB

Sorry, I garbled explaining Tim's testing. You get the "nice" error on update.php or install.php, but on 5.2 you get a syntax error before you can get redirected there, and on 5.3.2 (per timplunkett) you get a fatal. Who goes directly to install.php when they download Drupal for the first time? Not me. I just go to the folder where I put it.

On 5.2:
fresh-clone.png

It's perhaps not quite as bad for upgrading since a lot of people are used to navigating to update.php and that's in all our instructions. However, for those that don't, their site is suddenly toast with no feedback. (As above.)

That said, I just meant to post an FYI; I wasn't thinking of it as a critical. But if we really want to give people feedback on the version issue when they try to install D8 with old PHP, we'd need to handle index.php too.

xjm’s picture

Title: Install/update has syntax error instead of graceful fail for < 5.3 » index.php has syntax error instead of graceful fail for < 5.3
catch’s picture

Status: Active » Closed (won't fix)

Oh I see, if it's just index.php then this is indeed won't fix. Sorry folks.

klonos’s picture

...It's perhaps not quite as bad for upgrading since a lot of people are used to navigating to update.php and that's in all our instructions. ...

I still think we should fix this to present meaningful errors to users in all possible cases. We shouldn't close it, but rather downgrade its critical status instead. This feels like "sweeping under the carpet" to me. It is a reproducible WTF so if it can be fixed, then we should fix it.

xjm’s picture

Category: bug » task
Priority: Critical » Normal
Status: Closed (won't fix) » Active

Yeah, I'd agree. Reopening at normal. Maybe we can't fix it in a sane way, but I don't see the point of having special code in install.php and update.php than 90% of users won't see because index.php blows up on them first.

Edit: Especially since the fatal error on 5.3.2 impacts Lucid. (https://wiki.ubuntu.com/LTS)

David_Rothstein’s picture

So I agree it would be nice to fix, but it might very well be impossible to without adding code to the critical path that we don't really want there.

I'm pretty sure index.php in Drupal 7 has this problem also (though I can't remember exactly which PHP versions it has it for, maybe only PHP 4 in which case it would be less serious than the problem here).

xjm’s picture

Patch to fix this for update.php: #1749790: PHP 5.3 detection fails on update

mgifford’s picture

That looks like a huge chunk of the includes/update.core.inc just had to be re-written.

Crell’s picture

I'm going to vote we just won't-fix this issue again, esp. now that we're going all the way to 5.4. Any objections?

Crell’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

No objections, so closing.