Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
108 stars 20 forks source link

Fix fatal error that it cannot call constructor #2715

Closed harriswong closed 9 months ago

harriswong commented 9 months ago

Description

This PR removes the parent::__construct(); since there are no parent constructors to call.

Related issue(s)

Closes https://github.com/Automattic/woocommerce-services/issues/2714

Steps to reproduce & screenshots/GIFs

  1. Pull trunk, open woocommerce-services.php and go to line 1028. Change if ( ! isset( $existing_routes['/wc/v3/data/continents'] ) ) { to if ( true || ! isset( $existing_routes['/wc/v3/data/continents'] ) ) {. This forces the plugin to use our own continents controller.
  2. Make a GET request to http://localhost/wp-json/wc/v3/data/continents, you should be able to reproduce the error: image
  3. Now, pull this branch. Repeat step 1 to 2.
  4. You should now get this instead image

Checklist

harriswong commented 9 months ago

That is possible. It could also be triggered if /wc/v3/data/continents is removed or is missing from the REST API's router registry somehow. These 3 lines in the log caught my eye but I don't think they did anything strange:

#6 /srv/htdocs/wp-content/plugins/vision/includes/plugin.php(69): register_rest_route('vision/v1', '/item/(?P<id>\\d...', Array)
#7 /srv/htdocs/wp-content/plugins/vision/vision.php(71): Vision_Builder->run()
#8 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(324): vision_run('')