Closed Luc45 closed 2 years ago
Thanks for creating this PR @Luc45!
I tried to use it today for creating some products and orders and, once I activated the plugin through WP CLI, I found the following error when I navigated anywhere in my store (which uses PHP 7.4):
Fatal error: Declaration of Automattic\WooCommerce\Container::has($id) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /srv/users/userff65ed31/apps/userff65ed31/public/wp-content/plugins/woocommerce/src/Container.php on line 106
Notice: Function is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see [Debugging in WordPress](https://wordpress.org/support/article/debugging-in-wordpress/) for more information. (This message was added in version 3.1.0.) in /srv/users/userff65ed31/apps/userff65ed31/public/wp-includes/functions.php on line 5831
Notice: Function is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see [Debugging in WordPress](https://wordpress.org/support/article/debugging-in-wordpress/) for more information. (This message was added in version 3.1.0.) in /srv/users/userff65ed31/apps/userff65ed31/public/wp-includes/functions.php on line 5831
There has been a critical error on this website. Please check your site admin email inbox for instructions.
[Learn more about troubleshooting WordPress.](https://wordpress.org/support/article/faq-troubleshooting/)
I created another test store using the same PHP version and installed WC Smooth Generator compiled from the latest release tag, it worked properly.
Is there any chance that issue was introduced somehow by this PR?
Nice catch @alopezari !
I have locked the psr/container version to 1.0.0, which is the same as WooCommerce's: https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/composer.json#L23
Faker, which is a dependency of this package, requires psr/container "^1.0 || ^2.0"
too: https://github.com/FakerPHP/Faker/blob/main/composer.json#L18
Since WooCommerce dependency resolution tree is independent from this package, both codes might require different versions of the interface and still run under the same context. So we had psr/container 2 being loaded, while WooCommerce expects 1.
This is an annoying conflict that will always be present in WordPress ecosystem, at least until we figure out a way to keep a centralized dependency resolution process in Core, which there's no proposal for AFAIK.
This problem is solved, for now.
Thanks, @Luc45! I've used it now and worked great 👍
How to test the changes in this Pull Request:
composer install
(Bonus point if your local PHP version is lower than PHP 8)wp-content/plugins
of a WordPress site that has WooCommerce installed.wp wc generate products 10
Other information:
Changelog entry
Lower required PHP version from PHP 8 to PHP 7.1.
FOR PR REVIEWER ONLY: