• Resolved pepe80

    (@pepe80)


    Hi! I updated the plugin from version 2.7.3 to 2.8.2 and faced “Cron event not found!” message. I have cron tasks fired by server every minute (define(‘DISABLE_WP_CRON’, true) in wp-config). Before the update everything was working fine. Now:
    – I set “enable expiration from published to draft in 5 minutes”
    – I wait 5 minutes
    – The page changes status from “published” to “draft”
    – I see a “Cron event not found!” message

    In the debug logs I don’t see “PROCESSED” log. Only this:

    2023-01-03 16:51:22	DEBUG: 90063 -> EXISTING CRON EVENT FOUND - UNSCHEDULED - no errors found
    
    2023-01-03 16:51:22	DEBUG: 90063 -> CRON EVENT SCHEDULED at Tue., 03 Jan 2023 16:55:00 +0100 (1672761300) with options Array ( [expireType] => draft [category] => [categoryTaxonomy] => [enabled] => 1 [id] => 90063 ) , no errors found

    …but as I said, page/post changes its status to “draft”.

    WP: 5.9.2
    PHP 8.1

    • This topic was modified 1 year, 10 months ago by pepe80.
Viewing 15 replies - 1 through 15 (of 17 total)
  • I’m getting a similar issue but also getting a fatal error. The pages and products are set to draft but there is an exclamation point after them.
    WordPress: 6.1.1
    PHP: 8.0.25

    [01-Jan-2023 10:00:21 UTC] PHP Fatal error: Uncaught Error: Call to undefined function PublishPressFuture\Modules\Expirator\Models\ray() in /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php:266
    Stack trace:
    
    0 /home1/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(145): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->getExpirationTaxonomy()
    
    1 /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(370): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->getExpirationDataAsArray()
    
    2 /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Controllers/ExpirationController.php(121): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->expire(false)
    
    3 /home1//public_html/wp-includes/class-wp-hook.php(308): PublishPressFuture\Modules\Expirator\Controllers\ExpirationController->onActionRunPostExpiration(31928)
    
    4 /home1//public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
    
    5 /home1//public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
    
    6 /home1//public_html/wp-cron.php(188): do_action_ref_array('publishpressfut…', Array)
    
    7 {main}
    
    thrown in /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php on line 266
    [02-Jan-2023 16:41:33 UTC] Cron reschedule event error for hook: jetpack_clean_nonces, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {"schedule":"hourly","args":[],"interval":3600}
    
    [04-Jan-2023 10:02:09 UTC] PHP Fatal error: Uncaught Error: Call to undefined function PublishPressFuture\Modules\Expirator\Models\ray() in /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php:266
    Stack trace:
    
    0 /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(145): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->getExpirationTaxonomy()
    
    1 /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(370): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->getExpirationDataAsArray()
    
    2 /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Controllers/ExpirationController.php(121): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->expire(false)
    
    3 /home1//public_html/wp-includes/class-wp-hook.php(308): PublishPressFuture\Modules\Expirator\Controllers\ExpirationController->onActionRunPostExpiration(36417)
    
    4 /home1//public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
    
    5 /home1//public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
    
    6 /home1//public_html/wp-cron.php(188): do_action_ref_array('publishpressfut…', Array)
    
    7 {main}
    
    thrown in /home1//public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php on line 266
    [05-Jan-2023 03:03:43 UTC] Cron reschedule event error for hook: action_scheduler_run_queue, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {"schedule":"every_minute","args":["WP Cron"],"interval":60}
    Plugin Author andergmartins

    (@andergmartins)

    Hi @jodunningevents and @pepe80 thanks for reporting the issue. Please, could you try the following beta package?

    https://1drv.ms/u/s!AsIYGyKS9Y3Ym00fGvrWO-_HpxlN?e=HQi7Tm

    Thanks

    My cron events seem to either not get created or they disappear after a minute. Here is what I see in the log, wondering if this is a similar issue:

    2023-01-07 20:53:03	DEBUG: 263237 -> CRON EVENT SCHEDULED at Thu, 12 Jan 2023 00:01:00 -0800 (1673510460) with options Array ( [expireType] => category-add [category] => Array ( [0] => 90 ) [categoryTaxonomy] => [enabled] => 1 [id] => 263237 ) , no errors found
    
    2023-01-07 20:53:03	DEBUG: 263237 -> EXISTING CRON EVENT FOUND - UNSCHEDULED - no errors found
    
    2023-01-07 20:53:03	DEBUG: 263237 -> CRON EVENT SCHEDULED at Thu, 12 Jan 2023 00:01:00 -0800 (1673510460) with options Array ( [expireType] => category-add [category] => Array ( [0] => 90 ) [categoryTaxonomy] => [enabled] => 1 [id] => 263237 ) , no errors found
    
    2023-01-07 20:53:03	DEBUG: 263236 -> CRON EVENT SCHEDULED at Thu, 12 Jan 2023 00:01:00 -0800 (1673510460) with options Array ( [expireType] => category-add [category] => Array ( [0] => 90 ) [categoryTaxonomy] => category [enabled] => 1 [id] => 263236 ) , no errors found

    I tried the beta and the issue is not fixed in my case.

    I see the cron events being created as seen in the screenshot below:
    https://ibb.co/9b01rxH

    But once cron runs, they’re gone even though their dates are in the future. It seems like PublishPress removes its own cron events by mistake.

    Also not sure why there are 2 events instead of just one.

    Here is the corresponding debug log:
    https://ibb.co/cNnTb2B

    Thread Starter pepe80

    (@pepe80)

    Hi @andergmartins I installed beta packega and nothing changed. Page changes its status to “draft” and I see the message “Cron event not found”. In the debug logs I don’t see “PROCESSED” log (only “CRON EVENT SCHEDULED”).

    Plugin Author andergmartins

    (@andergmartins)

    Thanks for the details guys.

    I see now that if I schedule a post to expire in the future and run wp cron event run --all it will not check the date and expiration action will run, and after running, it is removed (by design). The same thing don’t seem to happen if I run that command with --due-now.

    The wp cron system has the autonomy to execute the action, and will always delete a task after running it, no matter an error occur.

    But I do see the PROCESSED registers in the log.
    I’m debugging to find more information. Please, let us know if you find out any new pattern for this.

    @chamois_blanc there are 2 events on that screenshot because they are scheduled for 2 different posts.

    Plugin Author andergmartins

    (@andergmartins)

    Please, could you check if you see any meta expiration_log for the expired post?

    Thread Starter pepe80

    (@pepe80)

    @andergmartins You guided me with this sentence:
    “The wp cron system has the autonomy to execute the action, and will always delete a task after running it, no matter an error occur.”
    I checked the error logs on the server and found an error that occurs when a post should expire:

    2023-01-09 21:05:02.649428 [STDERR] PHP Warning:  foreach() argument must be of type array|object, bool given in /home/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php on line 218
    2023-01-09 21:05:02.649458 [STDERR] PHP Fatal error:  Uncaught TypeError: array_unique(): Argument #1 ($array) must be of type array, bool given in /home/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php:222
    Stack trace:
    #0 /home/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(222): array_unique(false)
    #1 /home/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(144): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->getExpirationCategoryIDs()
    #2 /home/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Models/ExpirablePostModel.php(369): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->getExpirationDataAsArray()
    #3 /home/public_html/wp-content/plugins/post-expirator/src/Modules/Expirator/Controllers/ExpirationController.php(121): PublishPressFuture\Modules\Expirator\Models\ExpirablePostModel->expire(false)
    #4 /home/public_html/wp-includes/class-wp-hook.php(307): PublishPressFuture\Modules\Expirator\Controllers\ExpirationController->onActionRunPostExpiration(90063)
    #5 /home/public_html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
    #6 /home/public_html/wp-includes/plugin.php(522): WP_Hook->do_action(Array)
    #7 /home/public_html/wp-cron.php(138): do_action_ref_array('publishpressfut...', Array)

    To make things even weirder… when I do the tests now, everything works as it should. There are no errors in the server logs either.

    Plugin Author andergmartins

    (@andergmartins)

    Guys, please could you try the following beta package? There are some changes in the expiration code and in the log. I hope we have a little more details in the log if you still see the error.

    https://1drv.ms/u/s!AsIYGyKS9Y3Ym2g6KTAo3h4qkGCw?e=kjaClI

    Plugin Author andergmartins

    (@andergmartins)

    Thanks @pepe80 I will check the error and the log

    Plugin Author andergmartins

    (@andergmartins)

    Ok, sorry for another beta package, but I think it will fix the warning and fatal error you found @pepe80

    https://1drv.ms/u/s!AsIYGyKS9Y3Ym2l4lHAZeQx3fSnW?e=MXHryS

    Thread Starter pepe80

    (@pepe80)

    @andergmartins now everything looks ok, thanks! Debug logs:

    2023-01-09 23:47:02	DEBUG: 90063 -> PROCESSED Array ( [expireType] => draft [category] => Array ( [0] => 0 ) [categoryTaxonomy] => [enabled] => 1 [date] => 1673304420 )
    
    2023-01-09 23:47:02	DEBUG: 90063 -> EXPIRATION DATA REMOVED from the post
    Plugin Author andergmartins

    (@andergmartins)

    Awesome, thanks guys for the feedback and for the help.
    Please if you see a similar issue again, please open a new thread and linking this one.

    Are the fixes included in the 2.8.3 version? I’m still seeing posts losing their cron events.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Cron event not found – after update to 2.8.2’ is closed to new replies.