As I recall, the last few times we discussed MediaWiki's PHP version requirements, the consensus was that targeting a newer version of PHP would be desirable, but unfeasible so long as the Wikimedia Foundation still had servers running PHP 5.3 in production.
We are now down to just one host that is running PHP 5.3 (tin, the deployment host), and it is slotted for re-imaging some time next week. It is a good time to resurrect this discussion and reach consensus on a few practical matters. We should choose which version we want to target (5.4 stopped receiving security updates last September; 5.5 is no longer in active support, but will continue to receive security updates for another seven months) and update our PHP coding standards accordingly.
I propose that we permit the use of features provided that they do not introduce new programming paradigms. Immature developers are often attracted to new language constructs and fail to anticipate the costs of introducing them to a mature system with well-established programming patterns.
Requirements
- Assess the impact of a PHP requirement bump.
- Some statistics available at https://wikiapiary.com/wiki/PHP_versions based on Nikerabbit's query. Half of the known wikis running on the latest release use 5.3 or 5.4, as well as 2/3 of wikis on LTS.
- On public, known wikis "5.3 used on 7,870 wikis" according to https://wikiapiary.com/wiki/PHP_Versions , need to refine the queries to find out how many and which kind of wikis would be broken. Filter out wikifarms.
- Estimates for private or unknown wikis based on external data. (No internal data without site registration.)
- Define what impact is acceptable.
- Reach out to the affected sysadmins.
- Documentation of the requirements on wiki.
- Announcements to mailing lists.
- Other?
Statistics
Archived from https://wikiapiary.com/wiki/PHP_versions
Active non-farm wikis PHP versions | |||||
PHP version | 1.23.x | 1.24.x | 1.25.x | 1.26.x | 1.27.x |
---|---|---|---|---|---|
5.3 | 572 | 321 | 269 | 2 | 0 |
5.4 | 625 | 367 | 406 | 5 | 0 |
5.5 | 439 | 489 | 346 | 10 | 8 |
5.6 | 202 | 341 | 413 | 16 | 7 |
Active farm wikis PHP versions | |||||
PHP version | 1.23.x | 1.24.x | 1.25.x | 1.26.x | 1.27.x |
---|---|---|---|---|---|
5.3 | 55 | 30 | 5 | 1 | 1 |
5.4 | 524 | 39 | 45 | 3 | 3 |
5.5 | 85 | 106 | 79 | 9 | 6 |
5.6 | 43 | 31 | 1241 | 1 | 869 |
Proposed conventions
Here is how I apply this principle to the list of major new features in PHP 5.4:
Encouraged:
- Use of $this in closures. The fact that this didn't work prior to PHP 5.4 is a language defect, in my opinion. We've usually marked instances of this by using $that = $this: P2331.
- Class::{expr}(). Clearer than the alternatives.
Tolerated:
- Short array syntax. It appears to be the preferred syntax for PHP code written in the last couple of years. It is both more concise and more consistent with other programming languages in our ecosystem (JavaScript, Python, etc.) Updating usage should be permitted in the context of changes that have some other, independent motivation behind them (like fixing a bug or adding a feature), but please let's not destroy our git history with changes that do nothing but update the syntax.
- Function array dereferencing (e.g., foo()[0]). This was a rather bizarre limitation that tripped up a lot of developers. But veteran developers are accustomed to this limitation, and there seems to be no real benefit in forcing them to change.
- Class member access on instantiation (e.g., (new Foo)->bar()). This seems like a misfeature to me but giving someone a -1 for it seems a bit harsh.
- Traits. Discouraged, but careful experiments are permitted.
Minutes
Meetbot:
In the IRC meeting it was approved that our minimum version will be the common subset of features supported by PHP 5.5 and HHVM 3.1. However, this decision was suspended for review when objections were raised after the meeting. It was confirmed in a second RFC meeting on January 27th 2016.