Blogger As Developer

Warning: this will be a very geeky post about WordPress internals and a bug I just fixed in the current version. Feel free to skip this if that stuff isn’t up your alley.

So, this PHP stuff is pretty easy to figure out compared to the stuff I do every day at the day job.

I had been unable to use the Profile tab in the admin UI of WordPress to edit information about myself. Every time I tried to enter it I got the message:

Fatal error: Cannot redeclare veriflog() (previously declared in ./auth.php:7) in ..//wp-admin/auth.php on line 6

Searching the WordPress Support Forum I found a thread on this problem, and the answer was basically “You are hosed, switch to the experimental version”.

So, I believed that I was hosed, and popped into MySql to directly alter my settings (which is why these posts look like they are from ‘Mr. McLaren’ rather than ‘admin’) and resigned myself to not being able to edit my profile.

Today I invited some friends to check out the blog, and naturally they Registered. And then when attempting to actually log in, they got that same error.

So now it wasn’t just a problem with administration, it was a problem with the user experience. So I had to fix it.

If you followed the link to that thread on the support forums you will see that I have solved the problem, but I’ll include the details here for my records:

Essentially the problem was a “double include” issue that will be familiar to anyone who has ever written C or C++ code that has to integrate with other people’s modules. Essentially PHP seems to have a require_once call that is equivalent to using #include with the whole #ifndef _unique_token_ wrapper in C. I.e. it includes a header if it already wasn’t included in this file.

However, the details of how the auth.php module was being included confused this “one time only” engine, so I had to alter the code so that it would recognize the different inclusions of this file as being inclusions of the same file.

First, in profile.php find the section near the top that looks like this:

require_once(‘../wp-config.php’);
require_once(‘auth.php’);
switch($action) {

and make it look like this:

require_once(‘../wp-config.php’);
require_once(ABSPATH . ‘wp-admin/auth.php’);
switch($action) {

This means that the inclusion of auth.php is now keyed to the full path to that file.

Then, in admin-headers.php find the section near the top that looks like this:

require_once(‘../wp-config.php’);
require_once(ABSPATH.’/wp-admin/auth.php’);
require(ABSPATH.’/wp-admin/admin-functions.php’);

and make it look like this:

require_once(‘../wp-config.php’);
require_once(ABSPATH.’wp-admin/auth.php’);
require(ABSPATH.’wp-admin/admin-functions.php’);

This change is necessay since ABSPATH has a trailing slash, so before the change the code was including http://site/url//wp-admin/auth.php instead of http://site/url/wp-admin/auth.php. We need to get rid of that double slash so that the full path here will match the full path elsewhere.

And presto, profile will work for you.

  3 comments for “Blogger As Developer

Comments are closed.

Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Canada
This work by Chris McLaren is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Canada.