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

Improve the logging/noticing of Legacy REST API usages #43851

Merged
merged 6 commits into from Jan 22, 2024

Conversation

Konamiman
Copy link
Contributor

Changes proposed in this Pull Request:

This pull request expands on #40535, #40866 and #41804 by adding the following improvements:

  • Add the IP address of the requester to the generated log entries.

  • Replace the "an extension will be available" text with "an extension is available", including a link to the extension in the WordPress.org plugins directory, in the usages detected notices and in the Legacy REST API settings page notices:

image

How to test the changes in this Pull Request:

First, if you have tested the pull requests mentioned above, you'll probably have dismissed the relevant notices; you'll need to undo the dismissals first:

wp user meta delete <your user id> "dismissed_legacy_api_usages_detected_notice"
wp user meta delete <your user id> "dismissed_legacy_api_removed_in_woo_90_notice"
wp user meta delete <your user id> "dismissed_legacy_webhooks_unsupported_in_woo_90_notice"

If you have the separate Legacy REST API extension installed, you need to at least disable (or uninstall if you prefer) it.

Make sure to have the Legacy REST API activated in settings, and to have webhooks that depend on the Legacy REST API (see the testing instructions in the other pull requests welcome); and force the recreation of the notices: wp eval 'WC_Admin_Notices::reset_admin_notices();'

Now go to the Legacy REST API settings page, you should see three Legacy REST API warnings (two dismissable notices, and one paragraph under the setting, as in the screenshot above); verify that all the links in those work as expected.

Finally, repeat the testing instructions of #41804 and verify that the log entries contain the IP address of the requester.

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

Improve the logging/noticing of Legacy REST API usages

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 22, 2024
@Konamiman Konamiman self-assigned this Jan 22, 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

github-actions bot commented Jan 22, 2024

Test Results Summary

Commit SHA: db80f0d

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 39s
E2E Tests1730011402875m 20s

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.

@lsinger
Copy link
Contributor

lsinger commented Jan 22, 2024

Closing and re-opening to trigger the CI checks.

@lsinger lsinger closed this Jan 22, 2024
@lsinger lsinger reopened this Jan 22, 2024
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.

This tests as intended -- the notices appear with correct links and the IP address is added to the logs.

I left two comments, one of which I think we should address (the sanitization one), but I'm open to arguments against as well.

Konamiman and others added 2 commits January 22, 2024 15:23
Co-authored-by: Leif Singer <leif@automattic.com>
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.

Thanks for addressing my comments -- still tests well and I have no further comments. :shipit:

@Konamiman Konamiman force-pushed the improve-legacy-rest-api-usage-logging branch from 37515de to db80f0d Compare January 22, 2024 15:32
@Konamiman Konamiman merged commit 7c62443 into trunk Jan 22, 2024
34 checks passed
@Konamiman Konamiman deleted the improve-legacy-rest-api-usage-logging branch January 22, 2024 16:02
@github-actions github-actions bot added this to the 8.6.0 milestone Jan 22, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 22, 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 Jan 23, 2024
opr pushed a commit that referenced this pull request Jan 25, 2024
* Include request IP address in the logging of Legacy REST API usages

* Add link to the Legacy REST API plugin to the usage notices
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.

None yet

3 participants