{"id":61,"date":"2004-11-23T11:43:44","date_gmt":"2004-11-23T15:43:44","guid":{"rendered":"http:\/\/www.chrismclaren.com\/blog\/archives\/2004\/11\/23\/blogger-as-developer\/"},"modified":"2004-11-23T11:49:18","modified_gmt":"2004-11-23T15:49:18","slug":"blogger-as-developer","status":"publish","type":"post","link":"http:\/\/www.chrismclaren.com\/blog\/2004\/11\/23\/blogger-as-developer\/","title":{"rendered":"Blogger As Developer"},"content":{"rendered":"<p><strong>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&#8217;t up your alley.<\/strong><\/p>\n<p>So, this PHP stuff is pretty easy to figure out compared to the stuff I do every day at the day job.<\/p>\n<p>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:<\/p>\n<p>Fatal error: Cannot redeclare veriflog() (previously declared in .\/auth.php:7) in ..\/\/wp-admin\/auth.php on line 6<\/p>\n<p>Searching the <a href=\"http:\/\/wordpress.org\/support\/\">WordPress Support Forum<\/a> I found <a href=\"http:\/\/wordpress.org\/support\/index.php?action=vthread&#038;forum=2&#038;topic=4960&#038;page=-1#12\">a thread on this problem<\/a>, and the answer was basically &#8220;You are hosed, switch to the experimental version&#8221;.<\/p>\n<p>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 &#8216;Mr. McLaren&#8217; rather than &#8216;admin&#8217;)  and resigned myself to not being able to edit my profile.<\/p>\n<p>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.<\/p>\n<p>So now it wasn&#8217;t just a problem with administration, it was a problem with the user experience. So I had to fix it.<\/p>\n<p>If you followed the link to that thread on the support forums you will see that I have solved the problem, but I&#8217;ll include the details here for my records:<\/p>\n<p>Essentially the problem was a &#8220;double include&#8221; issue that will be familiar to anyone who has ever written C or C++ code that has to integrate with other people&#8217;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&#8217;t included in this file.<\/p>\n<p>However, the details of how the auth.php module was being included confused this &#8220;one time only&#8221; 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.<\/p>\n<p>First, in profile.php find the section near the top that looks like this:<\/p>\n<p>require_once(&#8216;..\/wp-config.php&#8217;);<br \/>\nrequire_once(&#8216;auth.php&#8217;);<br \/>\nswitch($action) {<\/p>\n<p>and make it look like this:<\/p>\n<p>require_once(&#8216;..\/wp-config.php&#8217;);<br \/>\nrequire_once(ABSPATH . &#8216;wp-admin\/auth.php&#8217;);<br \/>\nswitch($action) {<\/p>\n<p>This means that the inclusion of auth.php is now keyed to the full path to that file.<\/p>\n<p>Then, in admin-headers.php find the section near the top that looks like this:<\/p>\n<p>require_once(&#8216;..\/wp-config.php&#8217;);<br \/>\nrequire_once(ABSPATH.&#8217;\/wp-admin\/auth.php&#8217;);<br \/>\nrequire(ABSPATH.&#8217;\/wp-admin\/admin-functions.php&#8217;);<\/p>\n<p>and make it look like this:<\/p>\n<p>require_once(&#8216;..\/wp-config.php&#8217;);<br \/>\nrequire_once(ABSPATH.&#8217;wp-admin\/auth.php&#8217;);<br \/>\nrequire(ABSPATH.&#8217;wp-admin\/admin-functions.php&#8217;);<\/p>\n<p>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.<\/p>\n<p>And presto, profile will work for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">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&#8217;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&hellip; <a href=\"http:\/\/www.chrismclaren.com\/blog\/2004\/11\/23\/blogger-as-developer\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-technology","xfolkentry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5UQvw-Z","_links":{"self":[{"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":0,"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.chrismclaren.com\/blog\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}