• Resolved JProffitt3G

    (@jproffitt3g)


    When I activate this directly from the plugin installation table I get the “The Plugin Does Not Have a Valid Header” error. I can activate it just fine from the Plugins page however.

    I dug in and figured out why this is. On the plugin install page, WordPress calls install_plugin_install_status to get the main file. This defers to get_plugin_data which defers to get_plugins. get_plugins does a depth-first recursive search on the plugin files for the first valid plugin header.

    Since you store the object-cache.php directly in includes and that gets searched before redis-cache.php, WordPress thinks redis-cache/includes/object-cache.php is the main file. It then runs function validate_plugin on “redis-cache/includes/object-cache.php”, and sees that its not installed and therefore cannot be activated and throws the “invalid header” error.

    You could get around this issue by either making sure redis-cache.php gets parsed first or that includes/object-cache.php does not have a plugin header before the plugin is activated.

    Alternatively, you could attach to the plugin_install_action_links and correct the link used in wp-admin/includes/class-wp-plugin-install-list-table.php manually.

    Another alternative, since get_plugins uses a strnatcasecmp at the end to sort the plugins by their basename, you could add a “_” to the beginning of of object-cache.php, so that when its sorted redis-cache.php comes first and gets chosen as the representative plugin.

    • This topic was modified 9 years, 8 months ago by JProffitt3G.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    Thanks for digging into this.

    The _ solution seems like the easiest, any objections?

    Thread Starter JProffitt3G

    (@jproffitt3g)

    Ah, I was incorrect about that last solution. I misread the sort command in get_plugins, it actually sorts by the plugin name. So you only need to change the “Plugin Name” field in the drop-in. I changed it to “Redis Object Cache Drop-In” and that worked fine.

    • This reply was modified 9 years, 8 months ago by JProffitt3G.
    Plugin Author Till Krüss

    (@tillkruess)

    Nice, thanks for that!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘“Plugin Does Not Have a Valid Header” on Activation’ is closed to new replies.