Can no longer install WordPress on MAMP- "Fatal error: Cannot redeclare class wpdb"
I've been developing WordPress sites for a long time on my local MAMP server. Now all of a sudden, it won't let me create any n开发者_StackOverflow社区ew sites. Whenever I set up a new one, instead of running the install script I get:
Fatal error: Cannot redeclare class wpdb in /Applications/MAMP/htdocs/[my_site]/wp-includes/wp-db.php on line 52
This happens with all WordPress versions. I cannot thing of anything that would have caused this. I've done everything short of re-install MAMP. Does anyone have any ideas? I'm desperate at this point..
Check out the include path for php. It's likely that a second instance of wordpress is on the include path and is therefore conflicting with the one you're trying to load. It's also possible that a different package on the include path has a class called wpdb and is therefore causing a conflict.
wpdb
is being created again some where, if this happened all of a sudden i suggest that you disable any plugins you've recently added. Or even better do a global find for the term class wpdb
and see if that appears within more than 1 file. Also, check your functions.php file for a loop that might be loading wp-db.php
more than once.
A workaround fix is to wrap the wpdp class in wp-includes/wp-db.php
in the following:
Line 52:
if(class_exists('wpdb') != true)
{
class wpdb {
...
}
}
This solved the install issue- You could probably remove it after that, although it can't hurt to leave it I guess.
Still don't understand why this problem has popped up- If someone has an explanation I'd be eager to hear it.
精彩评论