On Tue, Apr 12, 2011 at 4:30 PM, Happy-melon <[email protected]> wrote:

> To add some context here, in r85918 I made some changes to our handling of
> old PHP versions.  Coaxing the PHP 4 parser to even get as far as letting
> us
> die() is quite a challenge, and just about every file in the codebase is
> incompatible with it (structures like wfFoo()->bar() are invalid, for
> instance).  However, PHP 5 versions are equally broken: no version of PHP <
> 5.2.3 that I tried (and I now have eight of them floating around :D) was
> able to load a page without a fatal error.
>
> What I have done is to move the PHP version check from WebStart.php (which
> was unparseable since Tim added a try/catch block in r85327) to the entry
> points index.php, api.php, load.php.  That way, only those files have to be
> PHP 4 compatible.


Do note though that there's no reason that all that PHP 5 code has to
actually be in the entry point and WebStart.php files.

They could simply look like:

  <?php
  // Check version compatibility; on PHP 4 try redirecting to index.php5, or
on old PHP 5 whinge about incompat.
  require './includes/MWVersionCheck.php';

  // The real code below may contain structures that can't be parsed by the
older code, so sits in another file.
  require './includes/do_index.php';

Then the version checks and redirection logic can all be encapsulated in one
place.

However it may be a reasonable simplification to drop the .php5 files and
magic redirection for PHP 4, and just worry about index.php and the
installer index.php detecting PHP 4 and throwing up an error message. Then
only index.php needs to be PHP4-parseable, and the rest need only parse on
PHP 5 and make it to the version check.

It should be a very rare case these days that .php files get run through PHP
4 by default with no way to change it; PHP 5 is many years old and very
standard.


-- brion
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to