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 {

to:

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
done

Save the file.

Change the file to executable by:

chmod u+x wikifix.sh

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

./wikifix.sh

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