Attempting to install the latest D8 version on PHP 5.2 (5.2.10 in my case) does not give the notice that "Your PHP installation is too old. Drupal requires at least PHP 5.3.3. See the system requirements page for more information."

However, invoking /core/install.php directly does.

Adding the PHP 5.3 detection to the top of index.php does not work either as the USE statements seem to kill the page immediately. I could not find a way to stop this from happening.

Comments

gtoffoli’s picture

The problem is that index.php contains 5.3 syntax (use keyword), the solution could be to make index.php 5.2.x compatible and isolate the 5.3 code in a different file eventually included but not immediately parsed, something like:

// 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;
}
else {
    

include("index2.php");

}

index2.php (terrible name, I know) would contain what index.php was containing:

<?php


use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

// Bootstrap all of Drupal's subsystems, but do not initialize anything that
// depends on the fully resolved Drupal path, because path resolution happens
// during the REQUEST event of the kernel.
// @see Drupal\Core\EventSubscriber\PathSubscriber;
// @see Drupal\Core\EventSubscriber\LegacyRequestSubscriber;
require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);

// @todo Figure out how best to handle the Kernel constructor parameters.
$kernel = new DrupalKernel('prod', FALSE);

// Create a request object from the HTTPFoundation.
$request = Request::createFromGlobals();
$response = $kernel->handle($request)->prepare($request)->send();

$kernel->terminate($request, $response);
ken hawkins’s picture

I can't think of any other workaround, and I'm sure a lot of folks will hit this screen as they try to put D8 on servers they've been using for 6 and 7.

Going with your method, perhaps it would be cleaner looking to isolate only the offending selectors.

So, index.php:

<?php

// 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;
}
else {
  include("core/usefunctions.php");
}

/**
 * Root directory of Drupal installation.
 */

define('DRUPAL_ROOT', getcwd());

// Bootstrap all of Drupal's subsystems, but do not initialize anything that
// depends on the fully resolved Drupal path, because path resolution happens
// during the REQUEST event of the kernel.
// @see Drupal\Core\EventSubscriber\PathSubscriber;
// @see Drupal\Core\EventSubscriber\LegacyRequestSubscriber;
require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);

// @todo Figure out how best to handle the Kernel constructor parameters.
$kernel = new DrupalKernel('prod', FALSE);

// Create a request object from the HTTPFoundation.
$request = Request::createFromGlobals();
$response = $kernel->handle($request)->prepare($request)->send();

$kernel->terminate($request, $response);


And then usefunctions.php is only

<?php

/**
 * Isolate php 5.3 functions that break 5.2 dection
 **/

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

Just to confirm, this method works as expected reporting PHP 5.3 failure — example: http://allaboutken.com/d8/

valthebald’s picture

Status: Active » Needs review
StatusFileSize
new3.05 KB

Attached is a proof of concept
1. index.php moved to core/index.php
2. definition of DRUPAL_ROOT moved to the newly created index.php
3. index.php contains PHP5.2-compatible version check, then includes core/index.php

ken hawkins’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new114.68 KB
new68.22 KB

Looks good to me.

Works fine with 5.3+, fails with 5.2.

I might be a bit a bold in marking this as tested ... but somewhere I think it says to be bold on d.o ...

chx’s picture

Status: Reviewed & tested by the community » Needs work

PHP 5.2 is EOL. Dead. It has ceased to be. Bereft of life. If you were to patch install.php, I could see the merits of doing that, but adding more to early bootstrap to every single Drupal page load on millions of sites just because there are a few slackers who run PHP 5.2 in 2013 (when we release)? We have debated hard adding a filemtime call, not to mention adding a full new file and including that.

valthebald’s picture

Then why "needs work" instead of "won't fix"?

chx’s picture

Because we can patch install.php. The issue is titled "PHP 5.3 detection fails on install" and THAT is something we can fix. You can add an install.php to sit besides index.php to do this detection and instruct people to visit it. For non-documentation-reading people with 5.3 , just going to index.php will stay working.

valthebald’s picture

core/install.php already contains this check, which happens before install_drupal() call,

install.php is redirected to core/install.php by .htacess, no matter if it exists (which is a separate issue - do we need
RewriteCond %{REQUEST_FILENAME} !-f
while making install/update.php redirects? But this is, in any case, a separate issue)

If making index.php PHP5.2-compatible is not an option, then all other ingredients are in place.

ken hawkins’s picture

Two pieces of food for thought:

  1. A big part of Drupal 8 is pushing hard for usability and a faceless WSOD is not very usable to a would-b Drupal convert.
  2. According to W3Techs, 5% of sites are still PHP 4.X and 64% are 5.1 or 5.2. 8% of PHP 5.3 installs are less than 5.3.3. More will undoubtedly move towards 5.3.3 over the next 12 months, but it will still be a huge chunk of the potential user base that might be confounded with this.

So that's something around 70% or more of websites that would see a WSOD when trying to upgrade to D8 today. And in mid-2013 it could easily be around 35%.

This is also a documentation issue as INSTALL.txt does not tell users to load install.php but rather the document root:

4. Run the install script.

   To run the install script, point your browser to the base URL of your
   website (e.g., http://www.example.com).

   You will be guided through several screens to set up the database, add the
   site maintenance account (the first user, also known as user/1), and provide
   basic web site settings.

I think it's reasonable to expect that most users will read some documentation, but those users must first open readme.txt, that then refers them to install.txt to even see that PHP 5.3.3 is required.

chx’s picture

So that's something around 70% or more of websites that would see a WSOD when trying to upgrade to D8 today.

I would suspect that number is misleading -- HostGator for example (I refuse to even research godaddy) has 5.2 and 5.3 both and so you'd see a huge number of 5.2 sites while your host already has 5.3. Also, don't forget that 06-Jan-2011 was the last ever 5.2 release.

On the other hand, the second half of your claim makes me wonder -- why don't we patch update.php? That would not be on a performance critical path and would work just fine.

Also, I see people are really passoinate about this, so I have thought on this more and here is an idea: move the contents of index.php into bootstrap.inc into a function and call that as appropriate. This will allow you to run a version check in index.php -- I am not against that; I am against a new file include. But bootstrap.inc is already loaded so why not?

chx’s picture

Also (maybe in a separate issue?) https://www.google.com/search?complete=0&q=AddHandler+application%2Fx-ht... we should add AddHandler application/x-httpd-php53 .php to .htaccess and also AddHandler x-httpd-php5-3 .php and it'll help a real lot of shared hosts.

catch’s picture

I'm not prepared to put PHP version checks in index.php, fine with doing that for update.php though if it's not there already.

chx’s picture

Why not...? a version compare is very very minimal, it wont make Drupal slowre.

catch’s picture

It's not about the performance, it'd be about a 10% increase in the lines of code in index.php (or nearly all of index.php if we moved the rest to a function), and there's still likely a year before Drupal 8 actually releases, by which time we have no idea how many hosts will still be on PHP 5.2.

chx’s picture

Title: PHP 5.3 detection fails on install » PHP 5.3 detection fails on update

Well, then I propose to fix update and someone should file another issue with those htaccess lines I found which should solve this problem for most shared hosts.

-enzo-’s picture

Status: Needs work » Needs review
StatusFileSize
new39.05 KB

Hello folks

I just did an implementation to enable run the update.php using prior version of PHP 5.3 , without get a horrible message.

Basically I just move all functions and references to namespaces function to a new file core/includes/update.core.inc and then simplify the core/update.php.

Tested with PHP 5.2 and PHP 5.3.

But at the end I got this error:

Thu Sep 13 22:17:03 2012] [error] [client 127.0.0.1] File does not exist: /Users/enzo/www/drupal8/favicon.ico
[Thu Sep 13 22:17:03 2012] [error] [client 127.0.0.1] Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException: "No route found for "GET /favicon.ico"" at /Users/enzo/www/drupal8/core/lib/Drupal/Core/EventSubscriber/RouterListener.php line 88

Reported in issue http://drupal.org/node/1464554#comment-6204906

As chx mentioned, a change is required in .htacess file, but maybe this change must be addressed in other issue.

valthebald’s picture

Status: Needs review » Needs work

.htaccess change is a separate issue

-enzo-’s picture

Status: Needs work » Needs review

Valthebald if is a separate issue why you set the status to needs works? I need to know just to understand what is the criteria.

chx’s picture

Status: Needs review » Reviewed & tested by the community

This is just moving code around, the error mentioned is a separate error, and this is good.

xjm’s picture

Status: Reviewed & tested by the community » Needs review

There's an older issue about this: #1468340: index.php has syntax error instead of graceful fail for < 5.3 (It was originally about all three entry points).

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Sorry, xpost.

-enzo-’s picture

Maybe you can put the other issue as resolved by this ticket?

xjm’s picture

Well, the other issue has broader scope, so no. :) But I did reference this issue there.

-enzo-’s picture

If the patch in comment 16 is consider to apply in drupal 8 core, I will really appretiate if you use my git authoring information for attribution.

--author="enzo <enzo@294937.no-reply.drupal.org>"

catch’s picture

catch’s picture

Status: Reviewed & tested by the community » Needs work

@-enzo- we don't use --author for core commits for various reasons, some of this is discussed at #1717676: Core commit credit and log messages are inconsistent between patches and merges. Patch no longer applies and could use a re-roll.

-enzo-’s picture

Just let me know when you applied the patch, If you apply the patch, is enough for me known I contribute with a small piece of code to Drupal 8.

I understand the current process to provide credits needs some improvements.

About the test, can you give any guidance to understand why the test fail? I don't understand why now fail last week the test pass all checks.

catch’s picture

The test fails because since the patch was created, the code it touches no longer applies. If you apply the patch locally with p1, or git pull --rebase on your git branch you'll see the conflicts.

-enzo-’s picture

Status: Needs work » Needs review
StatusFileSize
new20.49 KB

Hey guys I did a re-roll of patch #16.

-enzo-’s picture

Hey guys I did a re-roll of patch #16. Patch re-uploaded, last one had an error.

mgifford’s picture

Status: Needs review » Needs work
tstoeckler’s picture

DRUPAL_MINIMUM_PHP is 5.3.10 by now.

valthebald’s picture

#33: this issue is about detecting incompatible PHP version during install/upgrade, not on every request

tstoeckler’s picture

Sorry for not explaining that comment properly. I meant that the patch still uses 5.3.3 as the version to compare against. (It cannot use DRUPAL_MINIMUM_PHP directly per the comment in the patch.)

+++ b/core/update.php
@@ -14,8 +14,14 @@
+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.';

This is what I meant.

berdir’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)

I think this is no longer relevant as we no longer support major upgrades.

klonos’s picture

Status: Closed (duplicate) » Closed (works as designed)

...actually.