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:
- Downgrade your PHP from 5.3 back to 5.2
- Upgrade your MediaWiki to a newer version.
- Fix the codes.
In my case, the first couple solutions do not work for me, and therefore I choose 3.
- 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 46, change the following from:
class Namespace {
to:
class MWNamespace {
Save the file.
- Now, let’s create a script:
nano wikifix.sh
Copy and paste the following:
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
Try to access the MediaWiki again and the problem should be gone.
Enjoy Wiki.
–Derrick
Our sponsors:
thanks, worked for a recently upgrade lucid lynx (php 5.3.x and mediawiki 1.15.1)
Good to know that it works for you.
Nice article. Thank you for this info
I’ve found this to be very helpful when migrating from an older mediawiki version!
Thanx a million!
This helped me too.
This command does the same as your script, but can be run twice safely, and doesn’t make temporary files:
find -name “*.php” | xargs sed -i ‘s/\<Namespace::/WikiNamespace::/g'^C
That’s cool, thanks!
Thanks !!!!!
Cool, have not been able to find the information I was looking for before now, thanks to the blog owners for this master piece workβ¦
Pingback: Carra Dio
Thanks ! Supper Post !!
Pingback: carra dio
I love your website! did you create this yourself or did you outsource it? I’m looking for a blog design that similar so that the only reason I’m asking. Either way keep up the nice work I was impressed π
I love your website! did you create this yourself or did you outsource it? Im looking for a blog design thats similar so thats the only reason I’m asking. Either way keep up the nice work I was impressed π
Please, can you PM me and tell me few more thinks about this, I am really fan of your blog…
This is just the sort of info I was looking for! Thanks π
Thank you very much.
Interesting read, thanks! I finally see the larger picture π
This is just the sort of info I was looking for! Thanks π
What a great resource!
Thanks a lot friend,it’s helped me a lot .
Great hint! Very cool!
Worked Great! Get “flattr” and I’ll “flattr” you.
Using an old version of MediaWiki on a just upgraded server only noticed this error. Many thanks for the patch, a lot simpler than upgrading MediaWiki.
Great post, and a super easy fix. Got it to work on my wiki straight away
Thanks a lot. Now my mediawiki 1.9 works with one exception, the google calendar!
I obtain
{{#widget:Google Calendar |[email protected] |color=B1440E |height=400 |width=80% |title=Seminarios de Cadedif }}
do you have any idea what that could be?
Uwe Brauer
Can you show me your website? Thanks!
–Derrick
Pingback: Wordpresswindow » Ugly bug in mediawiki after php 5.3 upgrade
This is obviously a syntax error in the source code. Can you show me the link?
Dear gods that is so much easier than I thought it would be! Thank you for finding that.
Works great! Thank you!
Thanks!
Thanks, Thanks, Thanks and more Thanks!!!!!!!!!!!!!
Thanks for this information, came in very handy as I was moving a site from a Linux server into a local windows setup. I had to use notepad++’s “find in files” capability to accomplish the same thing. However, you might want to make clearer that the replace functionality has to be run on the wiki root directory, not just in the includes directory. I got that wrong on the first try and had to backtrack and try it again. It works now, thanks again.
Hi Greg,
I only ran the script in the “include” directory and everything worked fine. I didn’t run the script in the root directory.
–Derrick
SUPREME POST!
Excellent ! Merci beaucoup.
it was awsum for me π
Great recovery doc
Thank you for this nice help!
Terrific work! This is the kind of info that are supposed to be shared across the web. Disgrace on the search engines for no longer positioning this submit upper! Come on over and discuss with my website . Thanks =)
It works, great!!!
TextCrawler which is freeware will let you do the “Namespace::” to “MWNamespace::” search and replace over all the PHP files under Windows.
Great article, saved me a lot of time!!!
Pingback: MAMP und MediaWiki laufen endlich nach Update auf Mac OS X Lion Β» Pottblog
Thanks a lot!!! Safed me from jumping out of the window after upgrading my little server. π
Formerly:
MediaWiki: 1.5.8
PHP: 5.2.14 (apache2handler)
MySQL: 5.0.90-community
Now:
MediaWiki: 1.5.8
PHP: 5.3.10 (apache2handler)
MySQL: 5.1.61
Also, I needed to run your script in the languages directory.
Thanks!
Very nice site. I like it very much. Good work !
Pingback: Altes MediaWiki und PHP 5.3
thanks, worked wonderfully!
Thanks man!
I must say Thank you.
I didn’t have access to the terminal but I have manually replaced all Namespace:: to MWNamespace:: in all files under include folder.
I have also replaced
class Namespace {
to
class MWNamespace {
Thanks again
You, sir, are a genius. Many thanks!
Thanks……
Thanks for this, solved the problem with my MediaWiki 1.6.8 after upgrading to PHP 5.3.18. For those that are not using a script, the following description helps:
1. In the file Namespace.php, change “class Namespace” to “class MWNamespace”
2. Then change all occurrences of “Namespace::” to “MWNamespace::” in these files:
includes\Export.php
includes\ImageGallery.php
includes\Namespace.php
includes\Parser.php
includes\RecentChange.php
includes\SkinTemplate.php
includes\SpecialWatchlist.php
includes\Title.php
maintenance\generateSitemap.php
After making your suggested changes the error is gone, but when I try to access the wiki, I get a message “Waiting for byc.org…” and it never loads the page. This site is not yet live so if you try it you will be directed to our old site where the wiki is working. I had to include the ip address of our new provider in my hosts file in order to test my new site. Any ideas as to why this might be happening?
Thanks… This nasty little hack helped restore my old MediaWiki backup.
Works out perfectly.
Just restore my 1.8.13 mediawiki backup.
Thanks a lot,