Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not trigger 'pre_update' logic for HPOS option when value remains unchanged #45604

Merged
merged 2 commits into from Mar 15, 2024

Conversation

jorgeatorres
Copy link
Member

Submission Review Guidelines:

Changes proposed in this Pull Request:

We have some pre_update_option logic attached to the HPOS setting woocommerce_custom_orders_table_enabled (which enables HPOS) but this logic is executed regardless of whether the setting is actually changing value or not.

This can result in a confusing experience when a fatal error due to datastores being out of sync is triggered despite the datastore not being changed.

Closes #45225.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Go to WC > Settings > Advanced > Features and choose any datastore as order datastore. Make sure compatibility mode is disabled.
    If datastores are not in sync, run wp wc cot sync first if you want to change the current datastore.
  2. Go to WC > Orders and create an order with any details.
  3. Go back to WC > Settings > Advanced > Features and confirm that at least an order is reported as in need of sync and you are not allowed to change datastores.
  4. Run the following command and confirm that it doesn't trigger any fatal error:
    wp eval "update_option( 'woocommerce_custom_orders_table_enabled', get_option( 'woocommerce_custom_orders_table_enabled' ) );"
    
    Note: This is triggering a fatal error on trunk, so optionally check that too.
  5. Confirm that the following command does trigger a fatal error (which would be an attempt to change datastores with orders out of sync):
    wp eval "update_option( 'woocommerce_custom_orders_table_enabled', wc_bool_to_string( ! wc_string_to_bool( get_option( 'woocommerce_custom_orders_table_enabled' ) ) ) );"
    
  6. Run wp wc cot sync to sync orders.
  7. Confirm that the command from step 5 no longer throws a fatal error.
  8. You should've ended with a different datastore to the one you started with, so go to WC > Settings > Advanced > Features and change again or re-enable compatibility mode as necessary.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Mar 14, 2024
@jorgeatorres jorgeatorres requested review from a team and lsinger and removed request for a team March 14, 2024 21:01
@jorgeatorres jorgeatorres changed the title Do not trigger 'pre_update' logic for HPOS option when not changing value Do not trigger 'pre_update' logic for HPOS option when value remains unchanged Mar 14, 2024
Copy link
Contributor

Hi @lsinger,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

Test Results Summary

Commit SHA: 01b42e2

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 38s
E2E Tests311004103527m 13s

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

@lsinger lsinger left a comment

Choose a reason for hiding this comment

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

Looks good, works well. Great testing instructions! :shipit:

@lsinger lsinger merged commit d9013d4 into trunk Mar 15, 2024
40 checks passed
@lsinger lsinger deleted the fix/45225 branch March 15, 2024 11:46
@github-actions github-actions bot added this to the 8.8.0 milestone Mar 15, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Mar 15, 2024
@alopezari alopezari added needs: internal testing Indicates if the PR requires further testing conducted by Solaris status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error when updating option through wp-admin/options.php
3 participants