Page MenuHomePhabricator

Use of 'class Namespace' in Namespace.php conflicts with reserved word
Closed, ResolvedPublic


Per user complaint on MediaWiki-General. It appears that "namespace" is a reserved word on some versions of PHP 5 (even though it should not yet be). In any case, it will officially be at some point, so the use of the class named "Namespace" needs to be changed, as this causes "unexpected T_NAMESPACE" errors when Namespace.php is loaded on those versions of PHP. Rather than attach a large patch to do this, which may get out of date, here's some code to make the needed change from "Namespace" to MWNamespace":

mv includes/Namespace.php includes/MWNamespace.php

find . \( -name "*.php" -o -name "*.inc" \) -exec grep -l Namespace {} \; | \

xargs perl -pi -e 's/\bNamespace(\.php|::)/MWNamespace$1/'

Obviously, I'm not going to commit such a large change without discussion, hence this bug.

Version: 1.12.x
Severity: major



Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 10:00 PM
bzimport set Reference to bz12294.
bzimport added a subscriber: Unknown Object (MLST).

i.r.wezeman wrote:

The needed change don't fix the bug when using php6.0.0.

crrodriguez wrote:

This is now clearly reproducible when running PHP 5.3 s the namespace patch has been merged.

r32309, r32310 replace Namespace with MWNamespace class in trunk (for 1.13).

A compat 'Namespace' class is retained for compatibility with unchanged extensions when running on PHP < 5.3.