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

Fix deprecated get_option notice when viewing Analytics > Orders #49092

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

mikkamp
Copy link
Contributor

@mikkamp mikkamp commented Jul 3, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

When viewing Analytics > Orders a deprecated message is shown/logged. The reason this happens is because we switched to using a whitelist for allowed options, since WC 6.3. The option woocommerce_orders_report_date_tour_shown was not included in this whitelist, which is what this PR changes.

We can observe the requests for options by viewing the API requests when visiting Analytics > Orders. There we can see the request to: https://domain.test/wp-json/wc-admin/options?options=woocommerce_task_list_reminder_bar_hidden%2Cwoocommerce_orders_report_date_tour_shown%2Cwoocommerce_date_type&_locale=user

The only option that was missing from the whitelist was woocommerce_orders_report_date_tour_shown. I also checked all the other Analytics pages to ensure they aren't loading any options that weren't whitelisted.

Closes #47026
Closes #37592

How to test the changes in this Pull Request:

  1. Start with testing before checking out this PR to confirm the error is logged
  2. Configure site to log deprecations notices:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
  1. In the DB table wp_options set the option woocommerce_orders_report_date_tour_shown to no (only needed if previously viewed)
  2. Visit the page Analytics > Orders and click on the Got it to acknowledge the notice
    image
  3. Check the log file wp-content/debug.log and confirm we see both deprecation messages for get_options and update_options
[03-Jul-2024 10:02:53 UTC] The Automattic\WooCommerce\Admin\API\Options::get_options function is deprecated since version 6.3.
[03-Jul-2024 10:02:53 UTC] The Automattic\WooCommerce\Admin\API\Options::get_options function is deprecated since version 6.3.
[03-Jul-2024 10:03:13 UTC] The Automattic\WooCommerce\Admin\API\Options::update_options function is deprecated since version 6.3.
[03-Jul-2024 10:03:13 UTC] The Automattic\WooCommerce\Admin\API\Options::update_options function is deprecated since version 6.3.
[03-Jul-2024 10:03:13 UTC] The Automattic\WooCommerce\Admin\API\Options::update_options function is deprecated since version 6.3.
[03-Jul-2024 10:03:13 UTC] The Automattic\WooCommerce\Admin\API\Options::update_options function is deprecated since version 6.3.
  1. Checkout this PR and repeat steps 3 to 5, this time we shouldn't see any warnings for either get_options or update_options
  2. Check all additional pages in Analytics and confirm we don't get warnings for any other page.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

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

Changelog Entry Comment

Comment

@mikkamp mikkamp self-assigned this Jul 3, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@github-actions github-actions bot added the focus: e2e tests Issues related to e2e tests label Jul 3, 2024
@mikkamp mikkamp requested a review from a team July 3, 2024 13:30
Copy link
Contributor

github-actions bot commented Jul 3, 2024

Hi , @woocommerce/automata

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
Member

@eason9487 eason9487 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix.

Confirmed the deprecated get_options and update_options notices are no longer logged. LGTM.

@eason9487 eason9487 added the team: Automata WC Analytics label Jul 4, 2024
@mikkamp mikkamp merged commit cf7fc7b into trunk Jul 4, 2024
29 checks passed
@mikkamp mikkamp deleted the fix/option-notice-analytics-orders branch July 4, 2024 15:10
@github-actions github-actions bot added this to the 9.2.0 milestone Jul 4, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jul 4, 2024
@nigeljamesstevenson nigeljamesstevenson added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. 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 Jul 10, 2024
mikejolley pushed a commit that referenced this pull request Jul 10, 2024
)

* Add option for orders_report_date_tour_shown to allow list

* Disable the orders report date tour in E2E test
thealexandrelara pushed a commit that referenced this pull request Jul 18, 2024
)

* Add option for orders_report_date_tour_shown to allow list

* Disable the orders report date tour in E2E test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: e2e tests Issues related to e2e tests needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Automata WC Analytics
Projects
None yet
3 participants