I’ve not seen these personally. Does this mean that in the database you have an entry with a timestamp for the key but the value is an empty array? Or a null value?
I think in this case, if you try to delete one of these events with WP Crontrol it will probably fail to delete it.
How do these appear in the Tools -> Cron Events screen? Do they appear broken?
If you’re happy to send me a copy of the contents of your cron option from the wp_options table I’ll be happy to take a look at this. If there’s potentially private information in there then you can email it to me: https://johnblackbourn.com/about/
Thread Starter
nlpro
(@nlpro)
Does this mean that in the database you have an entry with a timestamp for the key but the value is an empty array? Or a null value?
I don’t know exactly because me opening this topic is related to this topic (Not mine by the way. I’m just trying to be helpful and learn some things along the way).
I’ve been fiddling with the failing command in php:
const HOOK = 'itsec_cron';
$crons = _get_cron_array();
foreach ( $crons as $timestamp => $args ) {
unset( $crons[ $timestamp ][ self::HOOK ] ); //this one fails
...
}
… to reproduce the PHP Fatal error:
Fatal error: Uncaught Error: Cannot unset string offsets
… and the only way I succeeded was with a timestamp ($timestamp) with NO array assigned. An empty array or an array without any itsec_cron key works fine. So my conclusion (though I might be wrong) is that the timestamp does not have an array() value assigned.
I’ve requested the topic owner to provide you with a screenshot of the Tools -> Cron Events screen.
Thank you very much for your assistance. Really appreciate it.
Thread Starter
nlpro
(@nlpro)
Ok, testing revealed the WP Crontrol plugin does not list any invalid cron events. The plugin code assumes there is an array assigned to every timestamp. While testing your plugin I did get these 2 warnings:
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/example.com/wp-content/plugins/wp-crontrol/src/event.php on line 202
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/example.com/wp-content/plugins/wp-crontrol/src/event.php on line 158
Since they are just warnings it doesn’t break things and code execution continues. It does mean invalid entries are simply skipped.
Anyway thank you for your input. Marking this topic as resolved.
-
This reply was modified 5 years, 10 months ago by
nlpro.
Thanks for the update. I think this sort of broken list of cron events is a bit beyond what you can expect any cron management plugin to handle. There are quite a few ways in which that cron array could be malformed.
I suspect if you try the wp cron event list command in WP-CLI you’ll see similar warnings and behaviour.
I hope you can get the issue fixed!