Support » Plugin: UpdraftPlus WordPress Backup Plugin » Wrong check ‘schedule_event’ filter

  • Resolved esemlabel

    (@esemlabel)



    class-updraftplus.php on line 3240 will return “PHP Notice: Trying to get property of non-object” if some plugins, developers or users will use ‘schedule_event’ filter to return false in certain checks to prevent scheduling event, that is documented in wp_schedule_event() function.

    You need to add if ( isset( $event->hook ) or if ( is_object( $event->hook ) before checking your ‘updraft_backup’ and ‘updraft_backup_database’ event hook names. Alternatively, low your ‘schedule_event’ filter to as low as possible priority.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Anderson

    (@davidanderson)

    Hi,

    It looks here like the WordPress code and documentation disagree. https://core.trac.wordpress.org/browser/trunk/src/wp-includes/cron.php#L41 says that this parameter should always be an object. But the following code allows for other things. Please can you open a report in WordPress Trac and put the link here, so that I can see what they say? (It looks most likely that they’ll change the doc to agree with the code).

    David

    It might me wrong documented. Because you won’t be able to return false without not passing ”, array(), null, 0 or false, whereas checking false as object will produce error.

    // A plugin disallowed this event
    if ( ! $event )
        return false;

    Or the code should be like this, where you can pass any of “false” values to $event->hook:

    $event = apply_filters( 'schedule_event', $event->hook, $event );
    if ( ! $event->hook )
        return false;

    Ticket
    https://core.trac.wordpress.org/ticket/40161

    Plugin Author David Anderson

    (@davidanderson)

    Hi,

    I’ve adjusted our development version, so that our next release will not raise a PHP notice in this situation.

    David

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Wrong check ‘schedule_event’ filter’ is closed to new replies.