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 {

    to:

    class MWNamespace {

    Save the file.

  5. 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.

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

    Warning: Don’t run the script twice!

  8. Delete the script.
    rm wikifix.sh

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

Enjoy Wiki.

–Derrick

Our sponsors:

How to free up space on your iPod?

I have a 30GB iPod and I am always running out of space. Recently I found that iTune 9.1.079 comes with a new feature. This features simply converts high quality music file to standard quality music. By doing this, which results in decreasing the file size and free up the space for other music.

To enable this feature, simply open your iTune –> iPod –> Summary tab –> Options section –> Check the option: “Convert higher bit rate songs to 128 kbps AAC”

Click below to enlarge the screenshot:

How to save space on your iPod?

How to save space on your iPod?

Before I enabled this option, there were only 2GB left on my iPod. Now I have 16.41GB free space, which is 8 times more than before!

Our sponsors:

ERROR 2006 (HY000) at line 172: MySQL server has gone away

Today I imported the MySQL database and I got the following error:

# mysql -u root -p db_test < test.db
Enter password:
ERROR 2006 (HY000) at line XX: MySQL server has gone away

It is because the data (SQL query) is too large to imported. To solve this problem, simply edit the MySQL configuration files: /etc/my.cnf

Replace the following from:

max_allowed_packet = 1M

To:

max_allowed_packet = 16M

Or something higher.

Restart the MySQL server again and the problem will be gone.

/usr/local/share/mysql/mysql.server restart

–Derrick

Our sponsors:

Thought on Opera Mini for iPhone

After trying the Opera Mini for iPhone, here is my comment:

  1. Zoom is missing. You can’t use finger to zoom in/out the page. It makes it very hard to browse the full-size page from the phone.
  2. Poor support on JavaScript. Website that works fine on Safari doesn’t mean they will do fine on Opera Mini.
  3. Lack of support. Many iPhone-friendly websites do not support Opera mini.

Suggested headline news for Opera.com:

  • There are over million of download of Opera Mini in 2 hours.

Suggested headline for Apple.com:

  • Safari is still the best iPhone browser on the planet.
  • 80% of the iPhone users remove the Opera Mini within 5 minutes.
  • Since Opera Mini cannot do the zoom and render JavaScript correctly, it should be recalled and removed from the iPhone App store.

Suggested response to Opera:

  • Opera Mini is still the 2nd best (and 2nd most popular) browser for iPhone on the planet.
  • (Keep in mind that  there are only two browsers for iPhone…)

Our sponsors:

Starting MySQL.. ERROR! The server quit without updating PID file

This article is a bit outdated. Please visit the following article instead. It includes a better discussion on how to solve this problem using different scenarios:

Thanks.

–Derrick

Our sponsors:

Weird PHP Error after FreeBSD port upgrade (PHP Warning: PHP Startup: Unable to load dynamic library)

Today I upgraded the port on my FreeBSD box using portmaster tools:

portmaster -Dai

After that, I found that the PHP gave the following weird error:

php -v

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/memcached.so' - /usr/local/lib/php/20060613/memcached.so: Undefined symbol " php_session_create_id" in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/mysql.so' - Cannot open "/usr/local/lib/php/20060613/mysql.so" in Unknown on line 0

PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Apr  6 2010 15:50:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

In order to solve this problem, you will need to rebuild the port. In my situation, I need to clean up, uninstall, rebuild and install the affected ports:

Memcached: /usr/ports/databases/pecl-memcached

MySQL: /usr/ports/databases/php5-mysql

——————————————————————————————
Update on 2010.04.13:
Your situation may be different from mine. The tricky part is to rebuild the port at the right location. For example, if your PHP complains about pdo.so, you can rebuild the port at the affected location:

/usr/ports/database/php5-pdo

If you are not sure where does the port locate, you can search it on Google or find it with the following command:

find /usr/ports/ -name "*pdo*"

——————————————————————————————

In each affected port, run the following commands:

make clean
make deinstall
make
make install && sync
make clean

After that, restart the PHP by restarting Apache:

sudo apachectl restart

and run the php command again:

php -v

The error should be gone:

PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Apr  6 2010 15:50:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Our sponsors:

Recharge the battery using Wi-Fi signal, does it worth it?

Today I read an article about Airnergy, a product developed by RCA to recharge the portable device using Wi-Fi signal. I think the idea is pretty interesting because wireless power(not battery power) is a main research area in the next 20 years.

Here is the link to the article:
RCA Airnergy claims to charge gadgets using ambient WiFi signals

I think the comment from Gruph Norgle is pretty interesting:

In the EU the maximum legal Wifi transmission power is 100 milliwatts, however, on average 802.11 devices transmit at 50mw. Now in accordance with the inverse square law, at a distance of 5 meters, the power is reduced to 1 / (5^2) * 50mw = 2mw. Two milliwatts at 5 meters. Assuming they have a respectable electrodynamic induction efficiency of 75%, they will be able to convert 75% of that 2 milliwatts back into electricity: 1.5 milliwatts.

It takes 50 times that to power a single LED. This means that if their internal battery is 3 volts, 3000mAh it will take about 5000 hours to charge it to full capacity.

So, how long does an iPhone battery(3.7V, 1400mAh) get fully charged from zero?

Required power = 3.7V * 1400mAh = 5.18Wh
Supplied power = 1.5mW = 0.0015W
Hour to get fully charged = 5.18 /0.0015 = 3453.33 hours = 4.72 months

4.72 months??!!

–Derrick

Our sponsors:

Enough “Rails Surprise”! Goodbye Ruby On Rails.

Couple months ago, I published an article about Ruby On Rails. I was wrong.

The idea of Ruby On Rails is really good. You can create a very simple database-driven web application (i.e., User can add, browse, remove and search records) in less than half an hour. There is no way to do something similar in such a short time using other programming languages. However – perhaps this is the tradition of the Rails development team, it comes with surprise (“Rails Surprise”) every time after upgrading the Ruby gems component. They either make your Rails application couldn’t start, or some features in your apps are not functioning after the upgrade.

What kind of people should stick with Ruby On Rails?

  • Someone is big fan of Ruby/Gems/Rails.
  • Someone has plenty of spare time.
  • Someone likes to sharpen his/her debugging skill – To debug the backward incompatibility mess introduced by the Ruby/Gems/Rails core development team.
  • Someone is patient and is willing to spend number of hours(could be days) to look for workaround.

I am neither. I think I already have enough “Rails Surprise”. And I will make my own web application framework from now on (The code name is called ICEPIZZA by the way). It will be simple, elegant and backward compatible.

–Derrick

Our sponsors:

iPhone or Google’s Nexus One?

I am thinking to get a smart phone and I am undecided whether I should get an iPhone or Google’s Nexus One. In general, I think Apple’s product is designed with fashion in mind while Google’s product is designed toward to programmers. I am okay with either one.

Today I read an article from Harvard Business Review. The author mentioned a feature that is missing on Google’s Nexus One. I think it is pretty important and it may change my mind to go with iPhone.

Here is the link.

Google’s Nexus One: Can Openness Win?

Our sponsors:

[Solved]Shared object “libtokyocabinet.so.8” not found

After upgrading the Tokyo Cabinet on my FreeBSD 8 system, I could not start Tokyo Cabinet:

ttserver
/libexec/ld-elf.so.1: Shared object "libtokyocabinet.so.8" not found, required by "ttserver"

After some investigations, I solved the problem.

1. First, go to the library directory. In my case, it is /usr/local/lib.

cd /usr/local/lib

2. Display all the libtokyocabinet.so:

ls libtokyocabinet.so*

which returns:

lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so -> libtokyocabinet.so.9.4.0
lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so.9 -> libtokyocabinet.so.9.4.0
-rwxr-xr-x  1 root  wheel   778K Jan  9 20:17 libtokyocabinet.so.9.4.0

So the solution to this problem is pretty obvious. The application is looking for libtokyocabinet.so.8 but a newer version of this library is available. A soft-link is good enough to solve this problem:

sudo ln -s libtokyocabinet.so libtokyocabinet.so.8

Here is the expected result:

ls libtokyocabinet.so*
lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so -> libtokyocabinet.so.9.4.0
lrwxr-xr-x  1 root  wheel    18B Jan  9 20:26 libtokyocabinet.so.8 -> libtokyocabinet.so
lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so.9 -> libtokyocabinet.so.9.4.0
-rwxr-xr-x  1 root  wheel   778K Jan  9 20:17 libtokyocabinet.so.9.4.0

Now I run the Tokyo Cabinet again, and the problem is gone!

ttserver
2010-01-09T20:26:12-06:00       SYSTEM  --------- logging started [13244] --------
2010-01-09T20:26:12-06:00       SYSTEM  server configuration: host=(any) port=1978
2010-01-09T20:26:12-06:00       SYSTEM  opening the database: *
2010-01-09T20:26:12-06:00       SYSTEM  service started: 13244
2010-01-09T20:26:12-06:00       INFO    timer thread 1 started
2010-01-09T20:26:12-06:00       INFO    worker thread 1 started
2010-01-09T20:26:12-06:00       INFO    worker thread 2 started
2010-01-09T20:26:12-06:00       INFO    worker thread 3 started
2010-01-09T20:26:12-06:00       INFO    worker thread 4 started
2010-01-09T20:26:12-06:00       INFO    worker thread 5 started
2010-01-09T20:26:12-06:00       INFO    worker thread 6 started
2010-01-09T20:26:12-06:00       INFO    worker thread 7 started
2010-01-09T20:26:12-06:00       INFO    worker thread 8 started
2010-01-09T20:26:12-06:00       SYSTEM  listening started

Our sponsors: