Make WordPress Core

Ticket #11831: wp-cron.php.patch

File wp-cron.php.patch, 1.1 KB (added by Scott Herbert , 11 years ago)

Added custom error handler to provide more information to site admins

  • wp-cron.php

     
    2626        require_once( dirname( __FILE__ ) . '/wp-load.php' );
    2727}
    2828
     29// catch timeout errors and display a useful error message.
     30function _wp_Cron_Error ($errno, $errstr, $errfile, $errline) {
     31
     32        if(WP_DEBUG && strrpos($errstr,'fopen')){
     33                echo "WP-CRON failed, most likely due to an error with CURL, try adding \n   define('ALTERNATE_WP_CRON', true);\n to wp-config.php in your wordpress directory";
     34        } else {
     35                echo "$errno ($errstr) in $errfile at line $errline";
     36        }
     37
     38}
     39
    2940// Uncached doing_cron transient fetch
    3041function _get_cron_lock() {
    3142        global $wpdb;
     
    97108                         * @param string $hook Name of the hook that was scheduled to be fired.
    98109                         * @param array $v['args'] The arguments to be passed to the hook.
    99110                         */
     111                        set_error_handler("_wp_Cron_Error");
    100112                        do_action_ref_array( $hook, $v['args'] );
    101 
     113                        restore_error_handler();
     114                       
    102115                        // If the hook ran too long and another cron process stole the lock, quit.
    103116                        if ( _get_cron_lock() != $doing_wp_cron )
    104117                                return;