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

[10.x] Bug in reset() with string path #47047

Merged
merged 3 commits into from
May 12, 2023
Merged

Conversation

daftspunk
Copy link
Contributor

@daftspunk daftspunk commented May 12, 2023

Report

Related class: Illuminate\Database\Migrations\Migrator

The reset() method interface hints at a string for the $paths argument, which is accurate to marry up with the rollback() interface.

/**
 * Rolls all of the currently applied migrations back.
 *
 * @param  array|string  $paths
 * @param  bool  $pretend
 * @return array
 */
public function reset($paths = [], $pretend = false);

However passing a string to this method fails:

// Eg:
$migrator->reset(base_path('database/migrations'));

Actual

Exception is thrown.

In Migrator.php line 346:

  Illuminate\Database\Migrations\Migrator::resetMigrations(): Argument #2 ($paths) must be of type array, string given, called in ~\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php on line 331

Expect

Happy path.

Proposal

Use an internal type cast/check at the first instance the variable is used.

Have a great day.

Fix with type cast/check
@taylorotwell taylorotwell merged commit ff152fa into laravel:10.x May 12, 2023
milwad-dev pushed a commit to milwad-dev/framework that referenced this pull request May 12, 2023
* Bug in reset() with string path

Fix with type cast/check

* Uses wrap instead

* Adds tests

---------

Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
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.

4 participants