MediaWiki: Fix Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING Namespace.php

The following information will fix the NAMESPACE errors when upgrading to a newer version of MediaWiki
Backup your wiki file first.
Access your webserver and go to the MediaWiki/includes directory.
For example:

cd /usr/local/www/apache22/data/wiki/includes

Edit Namespace.php

nano Namespace.php

Go to line 44 or whichever line your error referenced, change the following from:

class Namespace {


class MWNamespace {

Save the file.
Now, let’s create a script (do this in the “includes” directory):


Copy and paste the following (You may need to correct the ‘ manually):

for fl in *.php; do
mv $fl $fl.old
sed ‘s/Namespace::/MWNamespace::/g’ $fl.old > $fl

Save the file.

Change the file to executable by:

chmod u+x

Search the keyword Namespace:: and replace it by MWNamespace:::


Warning: Don’t run the script twice!
Delete the script.


rm *.old

Try to access the MediaWiki again and the problem should be gone.

By: Derrick
Modified By: nighthawk