0

I kinda did something stupid. To test something I created a couple of plugins and during testing I think I renamed the plugin. Now I deleted the plugins but I'm still getting an error message saying the plugin couldn't be found:

The plugin something else has been deactivated due to an error: Plugin file does not exist.

I searched the database and there's an activate_plugins entry in wp_options. It contains the following:

a:4:{i:0;s:23:"bandpress/bootstrap.php";i:3;s:56:"posts-from-single-category-widget/post_from_category.php";i:4;s:15:"something else ";i:5;s:68:"syntax-highlighter-with-add-button-in-editor/syntaxhighlighterpp.php";}

So, I think I need to remove the "something else " part of this field, but I don't know which parts I should (or shouldn't) remove. What part do I need to remove to get rid of the error message, without affecting the other plugins?

2 Answers 2

1

The approach in the answer by Scuba Kay is technically possible but easy to get wrong. Small mistakes will cause the data to fail to unserialize correctly. You are better off "editing" the serialized data with PHP:

$str = 'a:4:{i:0;s:23:"bandpress/bootstrap.php";i:3;s:56:"posts-from-single-category-widget/post_from_category.php";i:4;s:15:"something else ";i:5;s:68:"syntax-highlighter-with-add-button-in-editor/syntaxhighlighterpp.php";}'; // copies from database
$strar = unserialize($str);
var_dump($strar); // find the key in the var_dump
unset($strar[4]); // remove the key you need to remove
echo serialize($strar); // copy and paste this back into the database

It is possible to do the same thing a bit more "automated" by using get_option and update_option.

But there are other ways to remove a stubborn plugin. The first that comes to mind, and simplest, is to use (s)FTP to just physically delete (or rename) the plugin file/folder from the wp-content/plugins directory.

0

So I fixed my problem. Here's how:

a:4:{
    i:0;s:23:"bandpress/bootstrap.php";
    i:3;s:56:"posts-from-single-category-widget/post_from_category.php";
    i:4;s:15:"something else ";
    i:5;s:68:"syntax-highlighter-with-add-button-in-editor/syntaxhighlighterpp.php";
}

I figured out every activated plugin is defined between the i and the ;, so by removing the following my error message dissapeared:

i:4;s:15:"something else ";

[edit]

I should also have changed a:4 to a:3. I didn't and I ended up with a:0 { }. However, after reactivating my plugins I was back to the way it was.

5
  • You should also adjust the "count". Notice that the "4" in a:4 matches the number of lines-- aka the number of elements in the serialized array? Also, hand editing serialized data is a very good way to break things. It is easy to get wrong.
    – s_ha_dum
    Commented Dec 13, 2013 at 14:51
  • If this is a bad way to do this: What do you suggest? Commented Dec 13, 2013 at 14:54
  • You we're right about how easy it is to get wrong. I am now left with only a:0:{}. Commented Dec 13, 2013 at 14:57
  • Ok, but that's for next time. I only had to activate my plugins again and it works. Commented Dec 13, 2013 at 15:00
  • I broke that because I don't understand the mini markdown. Here: something in my theme's functions.php. $some_array = get_option( 'plugin_activate' ); $key = array_search( 'something else' ); if ( $key ) { unset( $some_array[$key] ); } update_option( 'plugin_activate', $some_array );
    – Will
    Commented Dec 13, 2013 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.