wp-cli/cron-command

Empty error message after action_scheduler_run_queue

Closed this issue · 4 comments

ctekk7 commented

Bug Report

[x] Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
[x] Yes, I reviewed the contribution guidelines.

  • Describe the current, buggy behavior

Empty errormessage after 'action_scheduler_run_queue' on 'wp cron event run --due-now'.
Success when 'action_scheduler_run_queue' is not run.

  • Describe how other contributors can replicate this bug

I run "wp cron event run --due-now" on ubuntu 22.04.
If action_scheduler_run_queue was run then there is an empty error message.
If action_scheduler_run_queue isn't run, then there is a success message.

Executed the cron event 'action_scheduler_run_queue' in 0.011s.
Error:
  • Describe what you would expect as the correct outcome

Error message states what the error is.

  • Let us know what environment you are running this on
OS:     Linux 5.15.0-92-generic #102-Ubuntu SMP Wed Jan 10 09:33:48 UTC 2024 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php8.1
PHP version:    8.1.2-1ubuntu2.14
php.ini used:   /etc/php/8.1/cli/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.6.16-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /var/www/www.example.com
WP-CLI packages dir:
WP-CLI cache dir:       /home/user/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.9.0

Thanks for the report, @ctekk7.

As a heads up, action_scheduler_run_queue isn't a core cron event, so that's something specific to the system.

I took a quick grep of the codebase and I don't see anywhere wp cron event run would output an empty error message. Here's the corresponding section of code:

$executed = 0;
foreach ( $events as $event ) {
$start = microtime( true );
$result = self::run_event( $event );
$total = round( microtime( true ) - $start, 3 );
++$executed;
WP_CLI::log( sprintf( "Executed the cron event '%s' in %ss.", $event->hook, $total ) );
}
$message = ( 1 === $executed ) ? 'Executed a total of %d cron event.' : 'Executed a total of %d cron events.';
WP_CLI::success( sprintf( $message, $executed ) );

Maybe you have another cron event that is calling WP_CLI::error() in its callback? Can you share the results of wp cron event list ?

Sure, here is the list.

I don't think its another event this is calling the error as it also occurs if only action_scheduler_run_queue is run.
Is there any way to debug this behaviour?

cron-list

I don't think its another event this is calling the error as it also occurs if only action_scheduler_run_queue is run.
Is there any way to debug this behaviour?

I don't have any great suggestions for further debugging off the top of my head, unfortunately. I think the problem is somewhere within your system, not WP-CLI itself.

okay lets close this one then.