"Krinkle" <krinklemail(a)gmail.com> wrote in message
news:E4C549E9-A115-4AFE-B030-3F57F2F9BB6B@gmail.com...
Right now there's a few points:
* Minimum php versions are all over the source code, putting it in
DefaultSettings.php or Defines.php would make be a good start, that
way all hardcoded uses of the versions after those are loaded can be
centralized.
However there are many php-versions compared before those are included
as well ( all (web) entry points and other files parsed before the
inclusion of DefaultSettings and/or Defines).
So a better solution would be to get those versions available right at
the beginning of the web entry points.
Possible solutions:
1) Instead of putting the define() or $wg...= in DefaultSettings.php /
Defines.php, create namethisfile.php and put them in there and include
it in the all entry points.
This seems like a simple and quick solution but introduces yet another
always-included file and puts them far away from other global
variables and defines.
2) Put it in Defines.php
* make it independant (ie. only defines(), nothing else, as the
filename suggests)
* and move it up the call stack
Things like inclusion of UtfNormalDefines could be put in the places
where Defines.php is currenty included[1] and assignment of the
$wgFeedClasses variable shouldn't be in Defines.php anyway.
3) Just put them in DefaultSettings.php and Defines.php and replace
all uses with the globals where they are hardcoded and available. Any
uses before this file is loaded (entry points) can hard code it
The third solution is basically what I was going to do, and can be
safely done. But before I do so I'd like to know if the solutions that
cover all scenarios are do-able.
--
Krinkle
[1] UtfNormalDefines.php may not have to be moved though, looks good
on second thought. It's included everywhere anyway so it doesn't save
load by loading it later or earlier.
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. It is definitely worth doing this despite the age of PHP
4, because the error message that previously resulted ("Parse error:
unexpected T_CONST_FOOBAR" or somesuch) is so spectacularly unhelpful that
people are far more likely to just give up in disgust than actually realise
even what the problem is.
The issue this raises is that we now have the minimum supported PHP version
hardcoded in at least six different places in the codebase. It would be
nice to have it centralised in a define() constant, but any file that it's
put in then needs to be kept PHP 4 compatible. The two options which stand
out are either creating a new file for it, or putting it in Defines.php and
moving that file to be included directly from the entry points, rather than
from WebStart.php. The question is: are there any gotchas associated with
moving that up the call stack?
--HM