Skip to content

hook_init has a different bootstrap level for global commands and module commands #3058

@joachim-n

Description

@joachim-n

I've been running my command as a module command to get around #2918, and it's been working ok.

Now I'm testing the PR to fix that issue, #3052, and my command crashes.

The reason is that my call to drush_drupal_version() in my command's hook_init gets a FALSE, where before it got a version number.

Here's some test code:

  /**
   * Test hello.
   *
   * @command cb-hi
   * @bootstrap DRUSH_BOOTSTRAP_DRUPAL_FULL
   */
  public function commandHi() {
    dump(drush_drupal_version());
    dump('hello!');
  }

  /**
   * Initialize Drupal Code Builder before a command runs.
   *
   * @hook init cb-hi
   */
  public function initHi() {
    dump(drush_drupal_version());
    dump('init');
  }

The output running that as a global command is is:

false
"init"
"8.4.0-dev"
"hello!"

Whereas if running as a module command, the Drupal core version number would be output both times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions