wp-cli / search-replace-command

Searches/replaces strings in the database.
MIT License
57 stars 45 forks source link

Fix fatal error when serialized objects have protected properties #129

Closed Tofandel closed 1 year ago

Tofandel commented 4 years ago

Example: PHP Fatal error: Uncaught Error: Cannot access protected property WCML_Currency_Switcher_Template::$custom_filters in phar:///usr/local/bin/wp/vendor/wp-cli/search-replace-command/src/WP_CLI/SearchReplacer.php:105 Stack trace:

0 phar:///usr/local/bin/wp/vendor/wp-cli/search-replace-command/src/WP_CLI/SearchReplacer.php(92): WP_CLI\SearchReplacer->run_recursively(Object(WCML_Currency_Switcher_Template), false, 2, Array)

schlessera commented 4 years ago

@Tofandel Can you add a test for this PR that trigger the above error and asserts that the change fixes it?

Tofandel commented 3 years ago

How can I do that? The tests in this repo don't seem to have an environment?! I'd need to register a class with a protected property serialize it and then run the search replace command

danielbachhuber commented 1 year ago

Proceeding with https://github.com/wp-cli/wp-cli/issues/5594 for this repository. I've captured this PR to https://gist.github.com/danielbachhuber/3d3d6396cd96c88761dd3171b2d6981b in case this PR is auto-closed or broken in some way.