Opened 10 years ago
Last modified 5 years ago
#31515 new defect (bug)
Cannot enable plugins with protected function redeclarations (PHP Fatal Error)
Reported by: | brokentone | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.3 |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
I'm working on a codebase where the theme or plugins concurrently declare the same function inside a function_exists() however the original plugin defines the function without a function_exists check. In this situation, all the declarations can live together at runtime, but attempting to activate (or reactivate) the original plugin causes an error.
Since the plugin initialization sandbox occurs after wp is loaded, the other plugins (with their checks) will have filled the function, any additional function declarations will fail. However this is merely an artifact of the initialization system -- as this plugin is being artificially run much later than it will be regularly running.
A usecase -- perhaps you are trying to wean yourself off the Advanced Custom Fields plugin so you've implemented the get_field function in the theme's functions file in a function_exists check. After disabling the ACF plugin, you decided to reenable it to adjust a field. Game over, Fatal Error.
This seems to be caused by the order that the plugins are tested on activation. The order in testing is different from the order that the plugins are loaded on the page.