Quantcast
Channel: wp-super-cache – WordPress.org Forums
Viewing all articles
Browse latest Browse all 3480

deeholzman on "Odd PHP error message occuring on wp-super-cache plugin page"

$
0
0

In case anyone else is researching this, I found the cause of the error - in the page /wp-super-cache/wp-cache-phase2.php on line 326 there is this command:

@unlink( $cache_file );

This can create an error because there isn't always a $cache_file to delete. The '@' before 'unlink' is meant to suppress any error messages, in case the '$cache_file' file does not exist.

My custom error reporting function (set with 'set_error_handler()') was still reporting this error, as ALL error reporting set up like this will. The @unlink command will still generate an error, while setting error_reporting() = 0. So to solve the problem and eliminate error notifications, if you're using a custom error handler, just make sure that error_reporting wasn't set to 0:

function customErrorHandler ($level,$message,$file,$line,$context){
if (error_reporting() !== 0) {
//handle the error
{
}

Perhaps a better way to handle this in the plugin is before calling unlink($cache_file), make sure the file exists:

if ( file_exists($cache_file) ) {
@unlink( $cache_file );
}

Viewing all articles
Browse latest Browse all 3480

Trending Articles