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

Handle posts > HPOS redirect more gracefully when backup post is missing #45605

Merged
merged 4 commits into from Mar 21, 2024

Conversation

jorgeatorres
Copy link
Member

@jorgeatorres jorgeatorres commented Mar 14, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

When HPOS is authoritative, we automatically redirect admin URLs for order posts to the corresponding HPOS one. For example, /wp-admin/post.php?post=123&action=edit gets turned into /wp-admin/admin.php?page=wc-orders&action=edit&id=123.

This works correctly when the order post exists, but was producing a 500 error when not.

This is sort of an edge case as we don't endorse removal of the backup post / placeholder post, but we've seen some users doing that after migrating to HPOS anyways.

This PR adds an additional check so that the redirect succeeds in those cases (as long as the HPOS order exists).

Closes #44177.

How to test the changes in this Pull Request:

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

  1. Make sure HPOS is configured as datastore in WC > Settings > Advanced > Features and that compatibility mode is disabled.
  2. Ensure your site has a few orders. If necessary, create some or use Smooth Generator for a smoother testing experience. Make note of some order IDs.
  3. Delete the backup post for one of the orders by running the following command:
    wp db query "DELETE FROM $(wp db prefix)posts WHERE ID = <order_id>"
    
  4. Visit https://yoursite.test/wp-admin/post.php?post=<order_id>&action=edit and confirm that you're redirected to the (HPOS) order edit screen.
  5. Visit https://yoursite.test/wp-admin/post.php?post=<post_id>&action=edit with a <post_id> that has no corresponding post and confirm that you see an error.

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
Copy link
Contributor

github-actions bot commented Mar 14, 2024

Test Results Summary

Commit SHA: 46727c7

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

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.

@jorgeatorres jorgeatorres marked this pull request as ready for review March 14, 2024 23:08
@jorgeatorres jorgeatorres requested review from a team and vedanshujain and removed request for a team March 14, 2024 23:08
Copy link
Contributor

Hi @vedanshujain,

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

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

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

left couple of minor comments, lgtm otherwise

@jorgeatorres
Copy link
Member Author

@vedanshujain: Thanks for the review! I've implemented your suggestion and simplified the logic a bit. Please let me know what you think.

Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

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

nice, LGTM!

@jorgeatorres jorgeatorres merged commit db34a15 into trunk Mar 21, 2024
25 checks passed
@jorgeatorres jorgeatorres deleted the fix/44177 branch March 21, 2024 18:34
@github-actions github-actions bot added this to the 8.8.0 milestone Mar 21, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Mar 21, 2024
@veljkho veljkho 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 21, 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.

Missing HPOS placeholder posts not handled gracefully
3 participants