Monday, February 9, 2009

Cannot enter Site Admin after installing WordPress 2.7 (1 post)

My problem is that I can't get into my Site Admin after installing the newest version of wordpress 2.7, Let me give you a little over view of my setup.

OS: Windows Vista
IIS: Version 7
PHP: 4.3 (Installed on IIS)
Browser: Firefox 3.06
Cookies: Enabled
Firewall: Enabled
Server: Localhost
Database: MySQL 4.0.20a-nt

After exploring a lot of resources and trying out a million things I just couldn't find out why it is not allowing me to get into site admin. I tried out things like these and nothing worked...

- Enabling Cookies, Clearing etc
- Restarting browsers
- Trying multiple browsers
- Making sure sessions are enabled
- Enabling / Disabling firewalls
- resetting password manually from database (after md5-hashing)
- Adding values to wp-config files
- Making sure ABSPATH was set, ech-ing it
- Even reinstalling the whole PHP, mySQL and wordpress a number of times

Problem Elaborated:

When I installed the complete blog locally, everything went well, but as soon as it comes to the login screen, and I enter the username and the random password it generated. It redirects me back to the login page without any error messages. If I am in http://localhost/mynewblog/wp-login.php and enter the admin username and password, as soon as I press the enter button, it goes to http://localhost/nadir/wp-admin/login.php and then suddenly it returns to the same page with something like this in the address bar http://localhost/mynewblog/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%2mynewblog%2Fwp-admin%2Findex.php

Also when I get redirected back to the login page, it has already registered the user at this point, because if I go back to the main page of the blog http://localhost/mynewblog/ it shows me the LOGOUT link at the lower right corner of the right panel. This means that the user is already authenticated but it’s just not going into the site admin.

Temporary Solution:
After digging a little deeper and debugging the whole thing by putting echo “I’m now here”; after each line I would try to figure out at which step it has a problem, I followed every ‘include’ and ‘require’ in each file in the process and then suddenly I found the step where it just allowed me to login.

The file is => /admin/admin.php
Line Number 28 or around
Function: auth_redirect();
I comment this and voila! I’m in the site admin!
Now I searched out what this function did… I found the above function defined in the following file
File: /wp-includes/pluggable.php
Line: 721 or around:
The function is this;

function auth_redirect() {
// Checks if a user is logged in, if not redirects them to the login page

if ( is_ssl() || force_ssl_admin() )
$secure = true;
else
$secure = false;

// If https is required and request is http, redirect
if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
exit();
} else {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
}

I have skipped this step and have no absolute idea what this function does that caused it to take me back to the login page again and again. I’m guessing by the comments in the code that it has something to do with the http / https request!? I’ve been using a normal http connection throughout everything.

Guys all of you out there let me know what this function does as I have already spend a whole day figuring this out its 2:30 in the morning and my head is spinning. I can’t do more searching on this. If the function was there it was there for a reason. We need to know what reason was it.