Skip to content

[9.x] Fixes usage of Migrator without output - #43326

Merged
taylorotwell merged 1 commit into
9.xfrom
fix/migrator-without-output
Jul 20, 2022
Merged

taylorotwell merged 1 commit into
9.xfrom
fix/migrator-without-output

Conversation

@nunomaduro

Copy link
Copy Markdown
Member

This pull request fixes an issue on the Migrator that may not run pending migrations if there is no Output instance on the class itself. This was a bug introduced at #43065, as the given closure only runs if there is an Output:

        $this->write(Task::class, $name, fn () => $this->runMigration($migration, 'up'));
        
     // ...

    protected function write($component, ...$arguments)
    {
        if ($this->output) {
            with(new $component($this->output))->render(...$arguments);
        }
    }

This pull requests addresses this issue, by giving a null output to the Task component, ensuring this way that the given task always run:

    protected function write($component, ...$arguments)
    {
        with(new $component(
            $this->output ?: new NullOutput()
        ))->render(...$arguments);
    }

Fixes #43325.

@nunomaduro
nunomaduro requested a review from taylorotwell July 20, 2022 17:55
@taylorotwell
taylorotwell merged commit bcf35ad into 9.x Jul 20, 2022
@taylorotwell
taylorotwell deleted the fix/migrator-without-output branch July 20, 2022 17:58
salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
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 this pull request may close these issues.

[9.x] Custom database migration in 9.21.0 does not work like it did in 9.20.0

2 participants