You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an assumption that the init hook will run before the cron_schedules hook, but if another plugin, the theme or an mu-plugin calls the function wp_get_schedules() before the the init hook fires (typically by calling it outside of the context of any hooks), the following warning gets logged:
PHP message: Warning: Trying to access array offset on value of type null in /var/www/wp-content/plugins/push-syndication/includes/class-wp-push-syndication-server.php on line 1227
The cause is $this->push_syndicate_settings being null when WP_Push_Syndication_Server::cron_add_pull_time_interval() is called
'display' => __( 'Pull Time Interval', 'push-syndication' )
);
As far as I can tell this does not create a functional problem with the Syndication plugin, but the warning can cause noise in logs which can make it more difficult to find important log messages.
Workaround:
As a workaround, a defensive check can be added to the plugin:
public function cron_add_pull_time_interval( $schedules ) {
+ // Only add custom interval if syndication settings are defined.+ if (+ empty( $this->push_syndicate_settings )+ || ! array_key_exists( 'pull_time_interval', $this->push_syndicate_settings )+ ) {+ return $schedules;+ }+
// Adds the custom time interval to the existing schedules.
$schedules['syn_pull_time_interval'] = array(
'interval' => intval( $this->push_syndicate_settings['pull_time_interval'] ),
'display' => __( 'Pull Time Interval', 'push-syndication' )
);
return $schedules;
}
Steps to Reproduce:
This can be reproduced when installing the Syndication plugin on a plain WordPress installation and calling the wp_get_schedules(); outside of any hooks in the default theme's functions.php. Then load any front or backend page and the error will be logged.
The text was updated successfully, but these errors were encountered:
Description:
There is an assumption that the
init
hook will run before thecron_schedules
hook, but if another plugin, the theme or an mu-plugin calls the functionwp_get_schedules()
before the theinit
hook fires (typically by calling it outside of the context of any hooks), the following warning gets logged:The cause is
$this->push_syndicate_settings
beingnull
whenWP_Push_Syndication_Server::cron_add_pull_time_interval()
is calledsyndication/includes/class-wp-push-syndication-server.php
Lines 1224 to 1230 in b47a461
As far as I can tell this does not create a functional problem with the Syndication plugin, but the warning can cause noise in logs which can make it more difficult to find important log messages.
Workaround:
As a workaround, a defensive check can be added to the plugin:
Steps to Reproduce:
This can be reproduced when installing the Syndication plugin on a plain WordPress installation and calling the
wp_get_schedules();
outside of any hooks in the default theme'sfunctions.php
. Then load any front or backend page and the error will be logged.The text was updated successfully, but these errors were encountered: