Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[router:rebuild] does not handle unsuccessful rebuild #3969

Closed
eyudkin opened this issue Oct 24, 2018 · 2 comments · Fixed by #4050
Closed

[router:rebuild] does not handle unsuccessful rebuild #3969

eyudkin opened this issue Oct 24, 2018 · 2 comments · Fixed by #4050

Comments

@eyudkin
Copy link

eyudkin commented Oct 24, 2018

Problem/Motivation

[router:rebuild] command uses router_builder service (see RouteBuilderInterface) for rebuilding routes. The "rebuild" method can return TRUE if rebuild was successful or FALSE if there were any errors. But RebuildCommand does not handle it:

protected function execute(InputInterface $input, OutputInterface $output)
    {
      $this->getIo()->newLine();
        $this->getIo()->comment(
            $this->trans('commands.router.rebuild.messages.rebuilding')
        );

       // HERE - there are no if, just 'rebuild' call and 'success' call next.
        $this->routerBuilder->rebuild();

        $this->getIo()->success(
            $this->trans('commands.router.rebuild.messages.completed')
        );
    }

As for me, better to display some error message.

How to reproduce

Just acquire the 'router_rebuild' database lock in other place - and call [router:rebuild] command without lock release.

Details

  • Drupal version: 8.6.1;
  • Console version: 1.8.0;
  • Console Launcher version: 1.8.0.
@enzolutions
Copy link
Contributor

@eyudkin thanks for your report.

Could you help us to explain how to accomplish this just acquire the 'router_rebuild' database lock in other place. Thanks in advance

@eyudkin
Copy link
Author

eyudkin commented May 14, 2019

Hi @enzolutions , thanks for your response.
I have no installed drupal for now, but following code should work:
\Drupal::service('lock')->acquire('router_rebuild')
Then do something to execute that [router:rebuild] command, and you will see that
$this->routerBuilder->rebuild(); returns "false".

Unfortunately I dont remember in which case I faced that. Probably I called some other command which worked with router and then called "router rebuild" command in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants