Notice: register_uninstall_hook was called incorrectly - wordpress

I automatically updated my wordpress installation to the latest version. Everything looked normal unit "updating database..." where it got stuck. I waited for a long while and then closed the page, since nothing was happening.
Then I got a error message saying something about maintenance, which I got rid of after deleting the maintenance file.
Wordpress displays that it runs the latest version, but when I try to reinstall I get the same errror. I've tried disabling all plugins and switch to the default theme, but no luck.
I set the debug to true and I got this message:
Notice: register_uninstall_hook was called incorrectly. Only a static class method or function can be used in an uninstall hook. Please see Debugging in WordPress for more information.
Everything looks normal except a image on the front page is breaking the layout.
Any tips?

The way I fixed this type of problem, was to do a global search in my project for the function call.
Some plugins had been installed which had calls such as this:
register_uninstall_hook(__FILE__, array($this,'uninstall_removedata'));
but it should be this:
register_uninstall_hook( __FILE__, 'uninstall_removedata');
If you see a message that something is called incorrectly, the Codex can be very helpful to make sure you use the correct syntax.
In this case it is here:
http://codex.wordpress.org/Function_Reference/register_uninstall_hook

Some WordPress Plugin which you have installed is firing the uninstall hook and is not setup properly.
Can you find the path to the file from the error message?

Related

My Wordpress is showing a blank page in the editor, how can I fix this?

I manage a Wordpress site for a client, after trying to resolve some updates I cannot seem to edit anything inside the editor anymore. Everything is blank (see image). The site itself is still up and working fine. Has anyone ever encountered this?
There are tons of reasons, why this could be happened. Like #jiali sent you a very helpful link, I would say to try and open the debugger: inside wp-config.php file search for define('WP_DEBUG', false); and change the value to true. Then, you propably would see what causing the error and where (either plugin or custom code, or maybe plugins conflict)
Okay so in this case the problem was (when I checked the error log) that the update was not properly installed. Deactivated the plugins inside PHP MyAdmin and then reinstalled Wordpress manually onto site.

Getting "An active PHP session was detected" critical warning in wordpress

A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.
In most cases, the real reason of the above errors is the incorrect mechanism for using PHP sessions within plugins or themes when they are using the session_start() function.
Now you need to identify what plugin cause this issue by deactive your plugin one by one.
Then in that plugin, you need to find a piece of code similar to this:
if ( !session_id() ) {
session_start();
}
then change it to:
if ( !session_id() ) {
session_start( [
'read_and_close' => true,
] );
}
Then you are done. In most cases, this will fix the issue. Good luck!
Had the same issue due to WP Hotel Booking plugin use. I fixed it! Took me a while to find a plugin it caused and editing the plugin .php didn’t help. But I fixed it adding a snippet of code to functions.php of the CHILD theme:
function mymodule_curl_before_request($curlhandle){
session_write_close();
}
add_action( ‘requests-curl.before_request’,’mymodule_curl_before_request’, 9999 );
There's a background to this solution at: Make WordPress Core, Loopback request fails if headers set in curl
(Original link in German doesn't exist anymore and was referring to this other related discussion.)
Often this critical issue is caused by conflict in SESSION when using the PHP session_start() function.
For example I have used a Calculation plugin in Wordpress and after Wordpress version update this error occured.
So I detected the plugin which causes this issue as activated/deactivated plugins one by one.
SOLVING these errors: In File manager of my site I got the .php files of the plugin and searched for session_start() function. Where it was used after it I used this function in a row session_write_close();
Source of the function
Regards!
To chime in with my own experience here, this very issue was resolved by turning off the “cross sell pop up” module of Shopengine Pro. Indeed there’s a session start in the php. I have notified them about this today. Maybe it’ll help someone else meantime!
I found out that you get these critical health warnings when you install a plugin or a plugin Adon and fail to complete its setup to the end. So the simplest solution is to deactivate the plugin or complete the plugin set-up. My errors were caused by a Woocommerce Adon which I deactivated and when I refreshed the health status the two issues were gone. I hope this helps.
#David M., If the issue is specifically happening with the Cross-Sell Popup Module of the ShopEngine PRO plugin, then it can be fixed by adding a small piece of code on the cross-sell-popup.php file that will read and close the session of the Cross Sale Popup module immediately.
Big Thanks to #thống nguyễn for the solution.
On the line 18th, from where the session starts, replace the session_start() with the following code:
session_start([
'read_and_close' => true
]);
Hope it will help.
If you tried the above and it's not working try to change the php version from your hosting's CPanel
I had the same error ande i changed the php version from 7.4 to 7.3 and it all went well

Fatal error: Call to undefined function wp_get_active_and_valid_themes() on wp-settings.php on line 477

I have this error and I seems can't get any decent answer on the web. Your answers will be much appreciated.
Thanks
Take a look at the documentation for wp_get_active_and_valid_themes(). You'll see that it's a private core function, which means plugins and themes aren't supposed to use it. It's also defined on wp-load.php. This most likely indicates one of two things.
1) Your WP Installation isn't valid. Reinstall the most recent version of WordPress and it should fix itself.
2) If you're attempting to use WordPress functions outside of WordPress (for example, in a custom PHP file), you're not properly loading in wp-load.php with require_once( 'path/to/your/wp-load.php' );
this just happened to several sites for me as well that were using WP Super Cache. i just deactivated all plugins and the theme (via wp_options db table) and reactivated them and it was fixed. strange

WordPress - Code Snippet plugin

I am working on a new Wordpress blog and it's very important to have code snippets in it.
So to highlight the code snippet I downloaded a Code Snippet plugin from https://wordpress.org/plugins/codesnippet-20/
Now, everything is screwed up. Below is the error when I access the site.
Warning: require_once(geshi.php): failed to open stream:
No such file or directory in /home1/jamburster/public_html/wp-content/plugins/codesnippet-20/codesnippet.php on line 126
Fatal error: require_once(): Failed opening required 'geshi.php'
(include_path='.:/opt/php56/lib/php:/home1/jamburster/public_html//wp-content/plugins/codesnippet/lib:/home1/jamburster/public_html//wp-content/plugins/codesnippet/lib/PEAR')
in /home1/jamburster/public_html/wp-content/plugins/codesnippet-20/codesnippet.php on line 126
Here is what I did.
1. Downloaded the archive from https://wordpress.org/plugins/codesnippet-20/
2. Uploaded the plugin WordPress -> Plugins -> Add Plugin. Browsed the downloaded one and clicked on upload.
3. Activated the plugin.
Can anyone please help.
i suggest you, using crayon syntax highlighter instead of current plugin
Ok, so it looks to me like the plugin is having trouble finding a file called geshi.php. I just downloaded the plugin and activated it in my WordPress admin dashboard and I got the same error. So this isn't specific to you. One thing to note is that this plugin is not currently being maintained.
"This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used
with more recent versions of WordPress."
However, I believe I have a fix for you. Go into your plugin and open the codesnippet.php file. Go to line 126 and replace that line with this:
require_once('/lib/geshi.php');
It looks like the directory structure of the plugin got changed without the necessary changes being made in the code base. I just tried this change on my machine and I am now able to activate the plugin without WordPress crashing. I haven't tried to use it, though.

Wordpress HTTP 500 on theme change

i just:
moved a remote wp network installation to local (mamp). everything fine.
installed a new theme. everything fine.
activated the new theme. doh!
i started going through the code and i found that it doesn't fix it, but at least i got a nice-relaxing-blank-white-page, if i remove the *do_action( 'init' );* from wp-settings.php.
i googled a while and i found that "*Your problem is probably wp_cron being called by init. In 2.1 and up, the cron process is called externally, so one thing that could be your problem is the DNS resolution not working on your webserver to find its own address.*"… i don't know if this could be the right answer to my issue, what am i supposed to do to fix it all?
ty!
To determine what the actual error is, you will want to turn on debugging. To do this, add the following line to your wp-config.php file:
define('WP_DEBUG', true);
It should then start spitting out lots of textual data as to what the error is. In all likelihood, it is a PHP error due to a coding issue (bad function call, missing end tag, etc.) in the new theme, or a difference in configuration between your live site and MAMP setup.
For more info on WordPress debugging, see http://codex.wordpress.org/Debugging_in_WordPress.

Resources