The following drush commands need to be ported to Drupal 8:

  • cron-logs
  • cron-list
  • cron-job-get
  • cron-job-set
  • cron-run
  • cron-enable
  • cron-disable
  • cron-unlock
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

bugsonly created an issue. See original summary.

Berdir’s picture

The drush commands are not ported yet.

Anonymous’s picture

Status: Active » Postponed
Berdir’s picture

Status: Postponed » Active

Postponed usually means that it's postponed on *something*. For example another issue needs to be fixed first.

That's not the case. It just requires someone to spend time on this and actually do it.

dermario’s picture

Title: drush cron-run fails: "Error: Call to undefined function ultimate_cron_run_scheduled()" » Port drush commands to Drupal 8
Category: Bug report » Task
dermario’s picture

Issue summary: View changes
dermario’s picture

I wonder if it makes sense to have 1 (child) issue per command or if its better to handle it all in this here?

dermario’s picture

Assigned: Unassigned » dermario
Issue summary: View changes
Status: Active » Needs review
FileSize
13.62 KB

Here is a patch for a drush integration with D8. With this patch i got the following commands running:

  • cron-logs
  • cron-list
  • cron-run
  • cron-enable
  • cron-disable
  • cron-unlock

This patch is not ready yet - there are some open questions i need to get answered somehow.

  1. How do we handle the core-cron override in ultimate_cron_drush_command_alter()? As far as i see we need a replacement for the variable_get('ultimate_cron_check_schedule_on_core_cron'). In D7 there was no install/update-hook or form for that variable, so it has to be set manually or in code. How do we achieve that in D8?
  2. How do we handle drush_ultimate_cron_cron_job_get() and drush_ultimate_cron_cron_job_set()? My suggestion is to remove them, because the Job-Settings are ConfigEntities now and not simple arrays (as in D7)
  3. Is there a way to run automated tests on drush commands?
dermario’s picture

Assigned: dermario » Unassigned
Berdir’s picture

Looks good.

  1. +++ b/ultimate_cron.drush.inc
    @@ -140,6 +141,7 @@ function ultimate_cron_drush_command_alter(&$command) {
         $command['path'] = drupal_get_path('module', 'ultimate_cron');
         $command['callback'] = 'drush_ultimate_cron_cron_run';
    +    // TODO: Remove the variable_get().
         if (!variable_get('ultimate_cron_check_schedule_on_core_cron', FALSE)) {
    

    You can remove this completely IMHO. The standard cron command works fine, we no longer need to replace it.

  2. +++ b/ultimate_cron.drush.inc
    @@ -181,39 +183,35 @@ function drush_ultimate_cron_cron_list() {
    +  $module = $module ? explode(',', $module) : array();
    

    while we touch this anyway, lets rename to $modules.

  3. +++ b/ultimate_cron.drush.inc
    @@ -419,17 +419,26 @@ function drush_ultimate_cron_cron_run($name = NULL) {
       if (!$name) {
    +    // Run all jobs.
         if (drush_get_option('force')) {
           CronPlugin::setGlobalOption('bypass_schedule', TRUE);
         }
    -    ultimate_cron_run_scheduled(FALSE);
    +
    +    $jobs = CronJob::loadMultiple();
    +    foreach($jobs as $job) {
    +      $job->launch();
    +    }
       }
       else {
    

    Is the force option really useful? If not, then we could just drop that and just call out to the cron service in this case. Not sure..

dermario’s picture

I applied all changes proposed in #10. Beside this i made some bigger changes. They are more or less a starting point for a discussion.

  1. I removed the check-schedule option for cron-run. IMO this option is redundant to the force option. check-schedule is the default option now.
  2. The shortcut for cron-run is crun now. Suggestions are very welcome :-)
  3. I removed 2 functions, because i have no idea how cron-job-get and cron-job-set can work in Drupal 8.
g18724’s picture

Is this latest patch/update already "in"

drupal/ultimate_cron:dev-8.x-2.x

I've installed that but don't see the 'drush crun' cmd.

Do I need to patch? wait?

ahillio’s picture

I think you should apply the patch, as https://www.drupal.org/node/1247158/commits doesn't list anything regarding drush commands. Typically when an issue's status is "Needs review" the patches have not yet been committed.

g18724’s picture

> the patches have not yet been committed

Thanks. Was unclear to me with "I applied all changes proposed ..." & "3 months ago".

  • Berdir committed ed7da75 on 8.x-2.x authored by dermario
    Issue #2665728 by dermario, Berdir: Port drush commands to Drupal 8
    
Berdir’s picture

Sorry for letting this lie around so long. Finally got to testing this. Made a few small additions/fixes and committed.

* Added the ID to the list. That's important for the other commands, so it should be thee.
* Fixed cron-run
* Some Cronjob => CronJob replacements

g18724’s picture

Installed

    drupal 8.1.6
    drupal/ultimate_cron:dev-2.x

        git log | head
            commit 21ef7429aa0ba08fb68a4c5b012fa23e5b52f918
            Author: fly2abhishek <fly2abhishek@468982.no-reply.drupal.org>
            Date:   Tue Jul 5 00:55:18 2016 +0200

                Issue #2728873 by abhishek-anand, Berdir: Ensure that cron jobs can have services as callbacks, refactor queue worker to one

            commit 5f7d877c39aaf127634ce34457e426ec32d489f2
            Author: mikkeX <mikkeX@382892.no-reply.drupal.org>
            Date:   Tue Jul 5 00:42:35 2016 +0200

checked

    drush
        ...
        All commands in ultimate_cron: (ultimate_cron)
         cron-disable (cd)     Disable cron job      
         cron-enable (ce)      Enable cron job       
         cron-list (cl)        List cron jobs        
         cron-logs             Show a cron jobs logs 
         cron-run (crun)       Run cron job          
         cron-unlock (cu)      Unlock cron job
        ...

list available cron jubs

    drush cl
       ID                         Module            Title                                                 Scheduled     Started  Duration  Status  
       comment_cron               Comment           Store the maximum possible comments per thread        Every 15 min  Never    00:00     no info 
       dblog_cron                 Database Logging  Remove expired log messages and flood control events  Every 15 min  Never    00:00     no info 
       field_cron                 Field             Purges deleted Field API data                         Every 15 min  Never    00:00     no info 
       file_cron                  File              Deletes temporary files                               Every 15 min  Never    00:00     no info 
       history_cron               History           Deletes history                                       Every 15 min  Never    00:00     no info 
       node_cron                  Node              Mark old nodes as read                                Every 15 min  Never    00:00     no info 
       purge_processor_cron_cron  Cron processor    Default cron handler                                  Every 15 min  Never    00:00     no info 
       search_api_cron            Search API        Default cron handler                                  Every 15 min  Never    00:00     no info 
       search_api_solr_cron       Solr search       Default cron handler                                  Every 15 min  Never    00:00     no info 
       system_cron                System            Cleanup (caches, batch, flood, temp-files, etc.)      Every 15 min  Never    00:00     no info 
       ultimate_cron_cron         Ultimate Cron     Runs internal cleanup operations                      Every 15 min  Never    00:00     no info 
       update_cron                Update Manager    Update indexes                                        Every 15 min  Never    00:00     no info

exec

        drush cron-run
        PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base_table.revision_id' in 'field list' in                                                                  [error]
        /web/d8/web/core/lib/Drupal/Core/Database/Statement.php:59
        Stack trace:
        #0 /web/d8/web/core/lib/Drupal/Core/Database/Statement.php(59): PDOStatement->execute(Array)
        #1 /web/d8/web/core/lib/Drupal/Core/Database/Connection.php(610): Drupal\Core\Database\Statement->execute(Array, Array)
        #2 /web/d8/web/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php(81): Drupal\Core\Database\Connection->query('SELECT base_tab...', Array,
        Array)
        #3 /web/d8/web/core/lib/Drupal/Core/Database/Query/Select.php(493): Drupal\Core\Database\Driver\mysql\Connection->query('SELECT base_tab...',
        Array, Array)
        #4 /web/d8/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(257): Drupal\Core\Database\Query\Select->execute()
        #5 /web/d8/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(84): Drupal\Core\Entity\Query\Sql\Query->result()
        #6 /web/d8/web/modules/contrib/search_api/src/Task/TaskManager.php(213): Drupal\Core\Entity\Query\Sql\Query->execute()
        #7 /web/d8/web/modules/contrib/search_api/src/Task/ServerTaskManager.php(92): Drupal\search_api\Task\TaskManager->executeAllTasks(Array, 100)
        #8 /web/d8/web/modules/contrib/search_api/search_api.module(50): Drupal\search_api\Task\ServerTaskManager->execute()
        #9 [internal function]: search_api_cron(Object(Drupal\ultimate_cron\Entity\CronJob))
        #10 /web/d8/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(315): call_user_func('search_api_cron',
        Object(Drupal\ultimate_cron\Entity\CronJob))
        #11 /web/d8/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(448): Drupal\ultimate_cron\Entity\CronJob->invokeCallback()
        #12 /web/d8/web/modules/contrib/ultimate_cron/ultimate_cron.drush.inc(333): Drupal\ultimate_cron\Entity\CronJob->run()
        #13 /web/d8/vendor/drush/drush/includes/command.inc(366): drush_ultimate_cron_cron_run()
        #14 /web/d8/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
        #15 /web/d8/vendor/drush/drush/includes/command.inc(185): drush_command()
        #16 /web/d8/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
        #17 /web/d8/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
        #18 /web/d8/vendor/drush/drush/drush.php(12): drush_main()
        #19 {main}

        Next Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base_table.revision_id' in 'field list': SELECT base_table.revision_id
        AS revision_id, base_table.id AS id
        FROM 
        {search_api_task} base_table
        INNER JOIN {search_api_task} search_api_task ON search_api_task.id = base_table.id
        WHERE  (search_api_task.type IN  (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3,
        :db_condition_placeholder_4)) AND (search_api_task._deleted = :db_condition_placeholder_5) 
        ORDER BY base_table.id ASC
        LIMIT 100 OFFSET 0; Array
        (
            [:db_condition_placeholder_0] => addIndex
            [:db_condition_placeholder_1] => updateIndex
            [:db_condition_placeholder_2] => removeIndex
            [:db_condition_placeholder_3] => deleteItems
            [:db_condition_placeholder_4] => deleteAllIndexItems
            [:db_condition_placeholder_5] => 0
        )
         in /web/d8/web/core/lib/Drupal/Core/Database/Connection.php:671
        Stack trace:
        #0 /web/d8/web/core/lib/Drupal/Core/Database/Connection.php(635): Drupal\Core\Database\Connection->handleQueryException(Object(PDOException),
        'SELECT base_tab...', Array, Array)
        #1 /web/d8/web/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php(81): Drupal\Core\Database\Connection->query('SELECT base_tab...', Array,
        Array)
        #2 /web/d8/web/core/lib/Drupal/Core/Database/Query/Select.php(493): Drupal\Core\Database\Driver\mysql\Connection->query('SELECT base_tab...',
        Array, Array)
        #3 /web/d8/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(257): Drupal\Core\Database\Query\Select->execute()
        #4 /web/d8/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(84): Drupal\Core\Entity\Query\Sql\Query->result()
        #5 /web/d8/web/modules/contrib/search_api/src/Task/TaskManager.php(213): Drupal\Core\Entity\Query\Sql\Query->execute()
        #6 /web/d8/web/modules/contrib/search_api/src/Task/ServerTaskManager.php(92): Drupal\search_api\Task\TaskManager->executeAllTasks(Array, 100)
        #7 /web/d8/web/modules/contrib/search_api/search_api.module(50): Drupal\search_api\Task\ServerTaskManager->execute()
        #8 [internal function]: search_api_cron(Object(Drupal\ultimate_cron\Entity\CronJob))
        #9 /web/d8/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(315): call_user_func('search_api_cron',
        Object(Drupal\ultimate_cron\Entity\CronJob))
        #10 /web/d8/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(448): Drupal\ultimate_cron\Entity\CronJob->invokeCallback()
        #11 /web/d8/web/modules/contrib/ultimate_cron/ultimate_cron.drush.inc(333): Drupal\ultimate_cron\Entity\CronJob->run()
        #12 /web/d8/vendor/drush/drush/includes/command.inc(366): drush_ultimate_cron_cron_run()
        #13 /web/d8/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
        #14 /web/d8/vendor/drush/drush/includes/command.inc(185): drush_command()
        #15 /web/d8/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
        #16 /web/d8/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
        #17 /web/d8/vendor/drush/drush/drush.php(12): drush_main()
        #18 {main}
g18724’s picture

Status: Fixed » Active
Berdir’s picture

Status: Active » Fixed

As you can see in the backtrace, that's an exception thrown by search_api that is apparently broken. Has nothing to do with this issue, it just triggers it.

g18724’s picture

Status: Fixed » Closed (fixed)

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