Drupal's update.php script redirecting to homepage and not updating

18 comments

While upgrading a couple of different Drupal (5.x) sites, I ran into an annoying issue where the update.php script just redirected to the sites homepage after the "Select Version" page. The server in question has PHP's mod_security enabled which has caused some problems with other sites in the past, so I think it's related to that, but I'm not totally sure.

Any way, the fix is to add the following line of code to your update.php script before line 794

if ($_POST['op']) $_REQUEST['op'] = $_POST['op'];

The finished product should look something like:

update_fix_schema_version();
update_fix_watchdog_115();
update_fix_watchdog();
update_fix_sessions();

//start new code
if ($_POST['op']) $_REQUEST['op'] = $_POST['op'];
//end new code

$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
switch ($op) {
        case 'Update':
                $output = update_update_page();
                break;

Have you had the same problem? Do you know what is causing it? Did the above code work for you?