Problem/Motivation

On /admin/config/system/cron/jobs when a job is ran individually (initialized by the user), the last run time for that job doesn't update.
Is this the right behavior?

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ginovski created an issue. See original summary.

rgpublic’s picture

Strangely, I have exactly the opposite problem: The "Last Run" time is updated when I run the Cron job manually, but never when it is run as part of a "drush cron-run". A new issue or the same?

Ginovski’s picture

Assigned: Unassigned » Ginovski
Status: Active » Needs review
FileSize
853 bytes

Here is a possible fix, making the log entry manually when an individual cron job is ran.
@rgpublic I'm not sure, check again to see if they don't update, if the problem still exists, create a new issue I guess.

Status: Needs review » Needs work

The last submitted patch, 3: run_time_not_updated-2774781-3.patch, failed testing.

Berdir’s picture

We shouldn't do this manually.

I've been dropping those methods and moving things around, but we're not quite there yet.

I think we should try to move most of \Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher::launch() into run(). It probably makes sense to expose $init_message as an optional argument for run() as that is tied to the threading stuff of the launcher. But locking and logging seems like sometihng that should always happen.

Ginovski’s picture

1. Moved most of the launch() to run()
2. Changed run() return value to boolean
3. Added $init_message as an argument in run()
4. Changed usages adding message as argument

Status: Needs review » Needs work

The last submitted patch, 6: last_run_time_not-2774781-6.patch, failed testing.

The last submitted patch, 6: last_run_time_not-2774781-6.patch, failed testing.

Ginovski’s picture

Status: Needs work » Needs review
FileSize
1.57 KB
7.96 KB

1. Small fix in UltimateCronQueueTest
2. Cleanup use in SerialLauncher
I think the other test fails are unrelated.

Status: Needs review » Needs work

The last submitted patch, 9: last_run_time_not-2774781-9.patch, failed testing.

Ginovski’s picture

Status: Needs work » Needs review
Berdir’s picture

Status: Needs review » Needs work

Yes, that fail is unrelated. #2804919: Rows in past_event_data not deleted? has the fix for the same test fail in past, please update ultimate_cron accordingly in a separate issue.

  1. +++ b/src/CronJobInterface.php
    @@ -224,8 +224,11 @@ interface CronJobInterface extends ConfigEntityInterface {
    +   * @param string $init_message
    +   *   The launch message.
    

    As discussed, despite adding specific messages, lets make the argument optional, default to NULL and in the method, if null, use the launched manually string. Then document as (optional) and mention the default string.

  2. +++ b/ultimate_cron.drush.inc
    @@ -330,7 +330,8 @@ function drush_ultimate_cron_cron_run($name = NULL) {
           if ($force || $job->isScheduled()) {
    -        $job->run();
    +        $init_message = t('Launched by drush');
    +        $job->run($init_message);
    

    You can just pass t() directly, you don't need a variable.

Ginovski’s picture

Status: Needs work » Needs review
FileSize
2.8 KB
8.17 KB

1. Added the default NULL and the message if left NULL. Configured the doc also (added optional and @return)
2. Passing the message directly, without variables.
3. Created an issue for the test fail #2815659: LoggerWebTest fail

Status: Needs review » Needs work

The last submitted patch, 13: last_run_time_not-2774781-13.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review

  • Berdir committed 7025858 on 8.x-2.x authored by Ginovski
    Issue #2774781 by Ginovski: Last run time not updated on individual job...
Berdir’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.