“Plugin Does Not Have a Valid Header” on Activation
-
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_statusto get the main file. This defers toget_plugin_datawhich defers toget_plugins.get_pluginsdoes 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_pluginon “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_linksand correct the link used in wp-admin/includes/class-wp-plugin-install-list-table.php manually.Another alternative, since
get_pluginsuses 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.
The topic ‘“Plugin Does Not Have a Valid Header” on Activation’ is closed to new replies.