MediaWiki Error: “Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING in /usr/local/www/apache22/data/wiki/includes/Namespace.php on line 46”

After upgrading my PHP to 5.3.2, I received the following error when accessing MediaWiki (1.6.12):

Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING in /usr/local/www/apache22/data/wiki/includes/Namespace.php  on line 46

There are three solutions:

  1. Downgrade your PHP from 5.3 back to 5.2
  2. Upgrade your MediaWiki to a newer version.
  3. Fix the codes.

In my case, the first couple solutions do not work for me, and therefore I choose 3.

  1. Backup your wiki file first.
  2. Access your webserver and go to the MediaWiki/includes directory.
    For example:

    cd /usr/local/www/apache22/data/wiki/includes
  3. Edit Namespace.php
    nano Namespace.php
  4. Go to line 46, change the following from:
    class Namespace {


    class MWNamespace {

    Save the file.

  5. Now, let’s create a script:

    Copy and paste the following:

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

    Save the file.

  6. Change the file to executable by:
    chmod u+x
  7. Search the keyword Namespace:: and replace it by MWNamespace:::

    Warning: Don’t run the script twice!

  8. Delete the script.

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

Enjoy Wiki.


Our sponsors:


  1. Worked like a charm – thanks! I did the manual find-and-replace using Notepad++ rather than the script, but worked just as well once I found the language.php file needed to be updated too.

  2. Thanks a lot!!

    I’d like to sugest a better fix:

    for file in `grep -R Namespace:: * | awk -F”:” ‘{ print $1 }’ | sort | uniq ` ; do sed -i ‘s/Namespace::/MWNamespace::/g’ ./$file ; done

    Best regards

  3. I get a different error now!

    PHP Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_NS_SEPARATOR in /usr/share/mediawiki1.10/languages/Language.php on line 254

  4. Too quick to post that comment … solved it by adding MW to the Namespace as below:

    if( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;

  5. Handle sensory integration problems, particularly those including
    the individual’s ability to feel and be aware of his body in space and physical therapy is used to enhance gross motor skills.
    Physical therapy is used to increase the person ‘s ability to take part
    in everyday tasks. Enhance and PT works to educate abilities like sitting
    walking, coordination, and balance. Physical therapy is
    best when incorporated within an early intervention program.

Leave a Reply

Your email address will not be published. Required fields are marked *