• I have a plugin that uses simplepie to pull in rss feeds inside wordpress. Sometimes, even with good rss feeds, the user will get this type of error message:

    Warning: file_get_contents(some feed) [function.file-get-contents]: failed to open stream: No such file or directory in /wp-includes/class-feed.php on line 88

    Since it’s very annoying to users to see this message, I would like to catch and suppress it. Is this even possible? I tried using $feed->get_error_message(); which will give me more information about the error, it doesn’t help me trap for the error since it’s coming from class-feed.php.

    I haven’t seen any discussion on the web about this or how to solve this (again, not trying to solve there is an error – there is, especially from tumblr sites and others – there are lots of posts on the web about these problems), but suppressing the error message to the user.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    This is a PHP warning. You don’t want any PHP warnings, errors, or notices displayed to the user on a production server. They should instead be routed to a log file that is not publicly accessible.

    First ensure the WP_DEBUG value in the wp-config.php file is defined as false. If it is false, all error handling settings are controlled by the php.ini file. If you do not have access to php.ini, you can override it’s settings with @ini_set() lines inserted into wp-config.php. Here’s one possible segment to place in the file:

    define('WP_DEBUG', false);
    
    // log php errors, prevent display to user, does not work if WP_DEBUG is true
    @ini_set('error_reporting', 4339 );	// moderate error reporting level, ignores notices
    @ini_set('html_errors', 'Off');		// startup errors off
    @ini_set('display_errors','Off');	// disable public display of errors
    @ini_set('log_errors','On');		// enable php error logging
    // path to server-writable log file, example shown, must be changed to a valid path for your server
    @ini_set('error_log','/home/content/123456/logs/PHP_errors.log');

    Adjust the values for your particular needs and server configuration.

    Thread Starter Allen

    (@amweiss98)

    Yes, that would be a great solution if I could get everybody who uses my plugin right now to go in a set up their config files. Thanks.

    Moderator bcworkz

    (@bcworkz)

    I obviously didn’t read your post very carefully. My bad. You could set up an error handler for that particular error that warns the user in a friendly manner, or just quietly ignore the warning. Try a search for PHP error handling functions for more info.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Class-feed.php warning messages – how to suppress’ is closed to new replies.