April 12

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):

nano wikifix.sh

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 wikifix.sh

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


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

rm wikifix.sh

rm *.old

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

By: Derrick
Modified By: nighthawk

Copyright 2021. All rights reserved.

Posted April 12, 2012 by Timothy Conrad in category "Websites

About the Author

If I were to describe myself with one word it would be, creative. I am interested in almost everything which keeps me rather busy. Here you will find some of my technical musings. Securely email me using - PGP: 4CB8 91EB 0C0A A530 3BE9 6D76 B076 96F1 6135 0A1B