Skip to content

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

Description

@g-elwell

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions