roboform


Spam: Don't buy it!

Bloggers' Rights at EFF

WordPress 2.0 Fix


Published Monday, December 26th, 2005 at 9:24 pm

Ok, so after my last post on my WordPress 2.0 upgrade issues I started hacking around and discovered a fix but not exactly what it is on my setup that causes this problem while others are ok. If you are experencing this problem modify the wp-admin/plugins.php file to include an exit; after the header("Location: XXX"); commands. Just replace the first 25 lines of code with this:

<?php
require_once('admin.php');
 
if ( isset($_GET['action']) ) {
	check_admin_referer();
 
	if ('activate' == $_GET['action']) {
		$current = get_settings('active_plugins');
		if (!in_array($_GET['plugin'], $current)) {
			$current[] = trim( $_GET['plugin'] );
			sort($current);
			update_option('active_plugins', $current);
			include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
			do_action('activate_' . trim( $_GET['plugin'] ));
		}
        header('Location: plugins.php?activate=true');
	} else if ('deactivate' == $_GET['action']) {
		$current = get_settings('active_plugins');
		array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
		update_option('active_plugins', $current);
		do_action('deactivate_' . trim( $_GET['plugin'] ));
		header('Location: plugins.php?deactivate=true');
	}
	exit;  // This is the fix
}

* Edit *
This fix has been included in WordPress 2.0.1.

14 Responses to “WordPress 2.0 Fix”

  1. Fix for the wordpress plugins problem people have been having

    http://blog.hypercubed.com/index.php/archives/2005/12/26/wordpress-20-fix/
    Adding the exit fixes something don’t know what it does as i’m not a php guru at all

  2. When the php code calls header(‘Location: plugins.php?activate=true’); it is telling php to stop executing the page and go to the plugins.php?activate=true page.  For some reason on some sites setup (mine is Windows NT with PHP Version 4.3.11) the execution does not stop and some code further down the page prevents the plugin from activating.

  3. This is exactly what I’m searching about! Thanks and Happy New Year :)!

  4. I was hoping that it would save some headache for others.

    I should mention that this turned out to be a bug reported in Nov but because it is not reproducible (still don’t know why it happens) it was closed as a anomaly of the reporters system. Thanks to my reopening the bug it is now fixed in the WordPress trunk and will not be an issue in future releases.  Feels good to give back to a program I appreciate so much.

  5. Thanks so much for this!  It was exactly what I needed to get my upgrade working!!!  Strong work!!

  6. I forgot to deactive my plugins before upgrade to wp2.0 so now plugins are not working. Like you said, the message says plugin activated but not working at all. But for you is you did deactive all your plugins before the upgrade rite? I really missed that part and now i’m in trouble.

    What about I deactive the plugins and run the upgrade.php file again? will that work or try ur code above will solve my plugin issue…I just dont want to mess up again. So i’m making sure your code will not cause anymore damage.

    Please don’t take me wrong, seems like others working fine with your code. Should I deactive plugins before I do changes to plugins.php page?

    Appreciate ur help. Thanks.

  7. I don’t think you need to worry about implementing this code.  All I’m doing is making the code work the way it was intended.  I suspect that on most systems the exit command is not needed because the header commands effectively do the same thing by directing the server to another page.  Give it a try.  I don’t think it could cause any harm. 

  8. Hey it’s working!!!! THANK YOU SOOOO MUCH! :D

    Your one line does really make an effect. Thanks again.

    Regards,
    May

  9. Just started the upgrade process – first issue found and now fixed.  Many thanks. 

  10. thanks for this post, it worked perfectly

  11. you’re my hero!

  12. Thanks, Dude! Very much appreciated.

  13. You can now also download a copy of plugins.php from the wordpress source website which already has the patch applied:

    http://trac.wordpress.org/file/trunk/wp-admin/plugins.php?rev=3365&format=raw

  14. [...] My favorite are the hacks, fixes and tips. The posts are where something wasn’t working or wasn’t working the way I wanted so I fixed it.  I’ve always been doing these type of things but finally I found a medium to share my experences.   I feel quite satisfied being able to share these with others. These also end up being my most popular posts. Some examples are a fix for a WordPress 2.0 bug that prevented WP from running on windows machines (fixed in WP 2.0.1 version thanks to my bug report).  I shared my method for hiding the WordPress post preview. I fixing a problem debugging Visual Studio applications with .NET 2.0 runtime installed. I also used my blog to spread the word of my first Firefox extension. [...]

Leave a Reply