WordPress: Cannot redeclare class problem

Wired, wired bug. It happens with Sashin, it happens with phpMailer class, it happens everywhere. As three plugins crashed after each other with the same reason on my brand-new WordPress installation, I’ve decided to invest an evening to find out the reason.

Let us localize the problem at first:

1) It happens only on Win32 installations.

2) It happens only in WordPress 2.1 or earlier.

After debugging a code for a couple of hours, I’ve found a bug with processing a win32 path in plugin_basename() function located in wp-includes/plugin.php.

Now skip the next two paragraphs if you are not a “techi” geek and simply scroll down to the solution.

This bug indirectly leads to the construction of a wrong hookname and to the missing page hook as the result. Missing page hook drives the process in the admin.php on line 44 (release 2.1) to the totally wrong if-branch. Finally this ends up with the attempt to include a plugin file once again.

Solution

Two minutes later I was reading the bug report #4408 which fixed the plugin_basename() in the version 2.2. So there are two options:

1) Upgrade your WordPress to version 2.2. or higher

2) Implement a fix from the bug report.

It is always good to have a choice. Enjoy it.

Leave a Reply