Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Database table optimizations #65

Merged
merged 19 commits into from
Sep 12, 2018
Merged

Database table optimizations #65

merged 19 commits into from
Sep 12, 2018

Conversation

stevegrunwell
Copy link
Contributor

@stevegrunwell stevegrunwell commented May 23, 2018

This PR aims to optimize the custom orders table that is the plugin's namesake. @raunak-gupta provided some great notes in #48, so this PR is for working through them.

Fixes #48. Blocked by #64, #72, woocommerce/woocommerce#20222.

@stevegrunwell stevegrunwell added this to the Version 1.0.0 milestone May 23, 2018
@stevegrunwell stevegrunwell self-assigned this May 23, 2018
@stevegrunwell stevegrunwell added this to To do in Version 1.0.0 via automation May 23, 2018
@stevegrunwell stevegrunwell moved this from To do to In progress in Version 1.0.0 May 23, 2018
@stevegrunwell
Copy link
Contributor Author

FWIW, woocommerce/woocommerce#20222 has been merged but not backported to previous releases, so the WC_Tests_Order_Functions::test_wc_get_order_address_params test will still fail for WC_VERSION !== "trunk".

Previous versions of WooCommerce had this in api/system-status.php, but this file was moved into the v2 subdirectory in woocommerce/woocommerce:246672818
Based on woocommerce/woocommerce:0e785d46, the HTTP request required by `WC_Tests_Product_CSV_Importer::test_import()` was failing for earlier versions of PHP (< 7.2), and thus causing a false positive when testing WooCommerce < 3.4.
There are situations where the Custom Orders Table plugin has had to ignore certain WooCommerce tests (for instance, if they're explicitly checking post meta), and those files are excluded in phpunit.xml.dist. Unfortunately, PHPUnit doesn't let you ignore a specific test method (e.g. `WC_Tests_REST_System_Status::test_execute_system_tool_add_order_indexes()`), but rather the whole file.

In some cases, omitting the whole would be counter-productive, which is the case here: `WC_Tests_Order_Functions::test_wc_get_order_address_params()` will fail with the custom orders table, as the columns for `billing_country` and `shipping_country` are both `char(2)` (per WooCommerce's specification, countries should be stored using the ISO 3166-1 alpha-2 standard, e.g. "US" instead of "USA"), but earlier versions of the test suite hard-coded "USA".

These tests were fixed in woocommerce/woocommerce#20222, but the patch has not been backported to earlier releases. Rather than changing the custom orders table schema to a suboptimal column-type for the sake of getting old tests to pass, this commit uses the `WC_VERSION` constant to conditionally add filters to modify *test* data within the WooCommerce core test suite on older versions.

With this code in place, tests in (for example, WooCommerce 3.4, which doesn't include the patch from woocommerce/woocommerce#20222) will be setting a `billing_country` of "US" rather than "USA". For newer, post-patch releases, these filters will not be active.
@stevegrunwell stevegrunwell changed the title WIP: Database table optimizations Database table optimizations Sep 12, 2018
@stevegrunwell stevegrunwell moved this from In progress to Review in Version 1.0.0 Sep 12, 2018
@bswatson bswatson merged commit 715fce3 into develop Sep 12, 2018
Version 1.0.0 automation moved this from Review to Done Sep 12, 2018
@bswatson bswatson deleted the feature/table-optimizations branch September 12, 2018 15:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Version 1.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants