Problem/Motivation
When calling drush node-access-rebuild-progressive
on a specific site, drush php-eval
is then called on the default site and fails if the default site is not configured:
> Error: Call to undefined function _drush_node_access_rebuild_progressive_process() in /var/www/vendor/drush/drush/src/Commands/core/PhpCommands.php(29) : eval()'d code on line 1 #0 /var/www/vendor/drush/drush/src/Commands/core/PhpCommands.php(29): eval()
> #1 [internal function]: Drush\Commands\core\PhpCommands->evaluate('_drush_node_acc...', Array)
> #2 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
> #3 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #4 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #5 /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(311): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #6 /var/www/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #7 /var/www/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #8 /var/www/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #9 /var/www/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #10 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #11 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
> #12 /var/www/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
> #13 /var/www/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/vendor...')
> #14 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main()
> #15 /usr/local/bin/drush(14): require('phar:///usr/loc...')
> #16 {main}
> [warning] Drush command terminated abnormally.
It seems to happen because _drush_node_access_rebuild_progressive_rebuild()
creates a new SiteAliasManager
manually instead of using the site.alias.manager
service, so the self alias is not correctly configured.
Steps to reproduce
- Configure a site that is not default.
- Create a Drush alias for that site.
- Call
drush @mysite node-access-rebuild-progressive
.
Proposed resolution
NodeAccessRebuildProgressiveCommands
should use SiteAliasManagerAwareTrait
.
Remaining tasks
I will submit a patch.