Skip to content

Conversation

@Konamiman
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

#35669 introduced a helper method to migrate state codes in various places of the database (shipping locations, orders, store address) but one placed that was missing is the tax rates table. This pull request fixes that.

How to test the changes in this Pull Request:

Same testing instructions of #35669 but this time testing that the state codes in the tax rates (WooCommerce - Settings - Tax - Standard, Reduced and Zero taxes) are properly updated.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@Konamiman Konamiman self-assigned this Dec 14, 2022
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Dec 14, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 14, 2022

Test Results Summary

Commit SHA: 5b3f360

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 56s
E2E Tests187006019315m 49s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Contributor

@peterfabian peterfabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this works well.

Besides the PHPCS below, I think we need to fix also the version strings in class-wc-install


'7.2.0' => array(
			'wc_update_720_adjust_new_zealand_states',
			'wc_update_720_adjust_ukraine_states',
		),

private static function migrate_country_states_for_tax_rates( string $country_code, array $old_to_new_states_mapping ): void {
global $wpdb;

// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you put the $wpdb->prepare() directly into the $wpdb->query(), the phpcs disabling won't be necessary.

It's probably true for some other ones above, but this is fairly simple to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it but in general I prefer to first generate the query in a separate variable and then run it, as the resulting code is cleaner than a nested query(prepare($sql)), even if it's at the expense of having to disable the check.

peterfabian
peterfabian previously approved these changes Dec 14, 2022
Copy link
Contributor

@peterfabian peterfabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me now!

Copy link
Contributor

@peterfabian peterfabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failing e2e test is not related (p1671022234510819-slack-C03CPM3UXDJ), so approving after the PHPCS change again.

@Konamiman Konamiman merged commit 3f4f191 into trunk Dec 15, 2022
@Konamiman Konamiman deleted the fix/include-taxes-in-states-migrator branch December 15, 2022 07:34
@github-actions github-actions bot added this to the 7.3.0 milestone Dec 15, 2022
samueljseay added a commit that referenced this pull request Dec 16, 2022
* Include taxes migration in the states migrator helper method (#35967)
* Prep for cherry pick 35967

* Move 7.2.1 fixes to separate heading in readme.txt

Co-authored-by: Néstor Soriano <[email protected]>
Co-authored-by: WooCommerce Bot <[email protected]>
Co-authored-by: Sam Seay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants