Bug: Fatal error: Cannot redeclare wp_check_password() (../wp-password-bcrypt/wp-password-bcrypt.php on line 29
jontejo opened this issue · 5 comments
Terms
- I have read the guidelines for Contributing to Roots Projects
- This request is not a duplicate of an existing issue
- I have read the docs and followed them (if applicable)
- I have seached the Roots Discourse for answers and followed them (if applicable)
- This is not a personal support request that should be posted on the Roots Discourse community
Description
What's wrong?
Fatal error: Cannot redeclare wp_check_password() (../wp-password-bcrypt/wp-password-bcrypt.php on line 29
Cant get it to work, I have had no problems either adding it in Code Snippets, or as a regular plugin.
I have built myself a solution to prevent deleting, and deactivating selected plugins so I dont need to have this as a mu-plugin. This let me update the plugin at scale through wp managing solution.
Still doesnt work though
I took the wp-password-bcrypt.php file and pack it down to a zip file and uploaded as a plugin, and it wont activate due to the error above.
It is simply not fun to update client site one by one in case it updates in the future. Uploading a plugin for bulk update across all sites is such a time saver.
And yes, I've seen that the problem have occured before in this Github rep and in the forum, but isn't there a solution available?
Thank you for reading!
Steps To Reproduce
See earlier field.
Expected Behavior
See earlier field.
Actual Behavior
See earlier field.
Relevant Log Output
No response
Versions
Latest on everything (PHP, bcrypt and wp)
This is likely an issue with your WP setup which was usually the case with the other issues about this. Have you tried disabling other plugins? Or trying it without your custom plugin solution?
The code is very simple and there's nothing else beyond this going on within the plugin.
Same issue even with a clean wp install. Fatal error.
I would not say this is fixed actually.. can you try on your end, please? Because I've tried for 2 hours here and its still not working as a regular plugin
You'll need to do some extra debugging to try on your own server since there's not much else we can do. Things I can suggest:
- grepping/searching through your webroot folder for
wp_check_password
to see if there's any other occurrences - determine the location of whatever
wp_check_password
was previously defined. Here's a possible solution: https://stackoverflow.com/a/2222404
Maybe add that to L28 on this plugin:
$reflFunc = new ReflectionFunction('wp_check_password');
print $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
Also, is that error message complete? Usually for these errors it shows where it was previously defined like this:
PHP Fatal error: Cannot redeclare wp_check_password() (previously declared in /xxxxx/xxxxx/xxxxx/wp-includes/pluggable.php:2126) in /xxxxx/xxxxx/xxxxx/wp-content/mu-plugins/wp-password-bcrypt.php on line 24
I gave this another try and wrapping the code with this solved the issue, seems like activation of a plugin run the wp_check_password after Wordpress have declared. And the plugin works too. So maybe it would be a great idea to add this to the next update, would help prevent fatal errors.
if(!function_exists('wp_check_password')){
// Entire plugin code here
}