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

Attempting to clean a seeder without a clean method causes a fatal error. #135

Open
g-elwell opened this issue Jun 19, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@g-elwell
Copy link
Member

Describe the bug
Attempting to clean a seeder without a clean method causes a fatal error.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Seeder class without a clean method
  2. Run the seeder with the clean flag: npx wp-cypress seed MySeeder --clean-first
  3. See the fatal error in your console

Expected behavior
Attempting to clean a seeder which does not have a clean method should produce an informative error.

This case is actually being handled already here:

WP_CLI::error( "clean() method does not exist on seeder {$seeder} class." );

The issue is that $seeder is a class instance. $seeder_name is available and using this here should fix the issue.

Error message

wp-cypress ✖ Fatal error: Uncaught Error: Object of class PostSeeder could not be converted to string in /var/www/html/wp-content/plugins/wp-cypress/src/Seeder/SeedCommand.php:121
Stack trace:
#0 /var/www/html/wp-content/plugins/wp-cypress/src/Seeder/SeedCommand.php(41): WP_Cypress\Seeder\SeedCommand->clean('PostSeeder')
#1 [internal function]: WP_Cypress\Seeder\SeedCommand->__invoke(Array, Array)
#2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#3 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(497): call_user_func(Object(Closure), Array, Array)
#5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(441): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#6 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(464): WP_CLI\Runner->run_command(Array, Array)
#7 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1295): WP_CLI\Runner->run_command_and_exit()
#8 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#9 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#10 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#11 phar:///usr/bin/wp/php/boot-phar.php(20): include('phar:///usr/bin...')
#12 /usr/bin/wp(4): include('phar:///usr/bin...')
#13 {main}
  thrown in /var/www/html/wp-content/plugins/wp-cypress/src/Seeder/SeedCommand.php on line 121
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.
@g-elwell g-elwell added the bug Something isn't working label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant