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

Introduce additional cache purging when creating pages - Consider old pages older than 60 minutes #1311

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

PanosSynetos
Copy link
Contributor

@PanosSynetos PanosSynetos commented Sep 28, 2023

Changes proposed in this Pull Request:

Closes #1310.

TLDR;

Instead of deleting all pages except for 'faq', 'contact-us', 'blog', we now delete only WooCommerce related pages.

We're extra careful, and check if the Woo Page we're about to delete is old.

For example, if we have a simple site with a page called shop , when an Ecommerce plan is purchased, this page won't be overwritten. but instead we instruct WooCommerce to create a new page

"Old" pages, are considered those that are older than 60 minutes.

  • This PR is a very minor change/addition and does not require testing instructions (if checked you can ignore/remove the next section).

How to test the changes in this Pull Request:

  • Create a new Free site and add some pages.
  • Get blog id from store admin
    https://wordpress.com/wp-admin/network/admin.php?page=store-admin&action=blog_id_search&id=https%3A%2F%2FYOURTESTSITE.wordpress.com
  • Go to https://mc.a8c.com/atomic/wpcom-dev-blogs/
  • Enter the blog id, check Transfers to Atomic dev server pool and click Add dev blog
  • Upgrade to Business
  • Go to Settings > Hosting management and activate SFTP/SSH access (keep the credentials handy for the SSH and SCP commands further down)
  • On your laptop, checkout branch fix/1310-ensure-pages-are-deleted
  • CD into the local repo and scp ./includes/class-wc-calypso-bridge-setup.php [email protected]:/srv/htdocs/wp-content/mu-plugins/wpcomsh/vendor/automattic/wc-calypso-bridge/includes to your WOA DEV site
  • SSH into the new site and tail -f -n1000 /tmp/php-errors to see the logfile (keep it open)
  • Click on Upgrades and upgrade to Ecommerce plan
  • Check site that the pages created on the free site are DELETED (they are considered as old since they were created in the past hour)
  • Check that you have all WooCommerce-related pages (shop, cart, checkout, my-account, refund-returns)
  • Check that there are no duplicate pages

You would see something similar to in your terminal - Please copy/paste it in your comments when you wrap up the test.

[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4138) INITIALIZED
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4141) START TRANSACTION
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4149) DELETING WOOCOMMERCE PAGES
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.425) deleted page shop
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4311) deleted page shop-2
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4373) deleted page cart
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4435) deleted page cart-2
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4492) deleted page checkout
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4551) deleted page checkout-2
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4608) deleted page my-account
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4664) deleted page my-account-2
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4723) deleted page refund_returns
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4727) DELETING WOOCOMMERCE PAGE OPTIONS
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4851) deleted option woocommerce_shop_page_id : 634
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.4853) failed to delete cache for option woocommerce_shop_page_id : 634
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.5423) deleted option woocommerce_cart_page_id : 635
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.5425) failed to delete cache for option woocommerce_cart_page_id : 635
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.5945) deleted option woocommerce_checkout_page_id : 636
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.5946) failed to delete cache for option woocommerce_checkout_page_id : 636
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.6506) deleted option woocommerce_myaccount_page_id : 637
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.6508) failed to delete cache for option woocommerce_myaccount_page_id : 637
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.7064) deleted option woocommerce_refund_returns_page_id : 638
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.7066) failed to delete cache for option woocommerce_refund_returns_page_id : 638
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.7067) DELETING HEADSTART PAGES
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.7159) deleted page refund_returns
[28-Sep-2023 11:46:05 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901565.7164) FLUSH CACHE AND SLEEP
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2167) GETTING WOOCOMMERCE PAGE OPTIONS AFTER DELETION
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2707) getting option woocommerce_shop_page_id :
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2712) getting option woocommerce_cart_page_id :
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2716) getting option woocommerce_checkout_page_id :
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.272) getting option woocommerce_myaccount_page_id :
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2724) getting option woocommerce_refund_returns_page_id :
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2757) CREATING PAGES
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2769) woocommerce_create_pages filter - updated content to use cart/checkout blocks
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2777) woocommerce_create_pages filter - pages:shop, cart, checkout, myaccount, refund_returns
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2782) woocommerce_create_page_id force create slug: shop
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.2868) woocommerce_page_created action - id: 641, slug: shop
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.3953) woocommerce_create_page_id force create slug: cart
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.4074) woocommerce_page_created action - id: 642, slug: cart
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.5152) woocommerce_create_page_id force create slug: checkout
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.5255) woocommerce_page_created action - id: 643, slug: checkout
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.6311) woocommerce_create_page_id force create slug: my-account
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.6387) woocommerce_page_created action - id: 644, slug: my-account
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.7433) woocommerce_create_page_id force create slug: refund_returns
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.7551) woocommerce_page_created action - id: 645, slug: refund_returns
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.8586) finished WC_Install::create_pages
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.9267) created menu items
[28-Sep-2023 11:46:06 UTC] WooExpress: Operation: woocommerce_create_pages: (1695901566.9277) COMMIT and cache deleted

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions
Copy link

Size Change: 0 B

Total Size: 196 kB

ℹ️ View Unchanged
Filename Size
./build/53.js 1.05 kB
./build/index.css 883 B
./build/index.js 121 kB
./build/marketing.js 58 kB
./build/payment-gateway-suggestions.css 1.25 kB
./build/payment-gateway-suggestions.js 6.45 kB
./build/plugins.js 3.92 kB
./build/style-index.css 2 kB
./build/style-marketing.css 805 B

compressed-size-action

@PanosSynetos PanosSynetos merged commit b5851d2 into master Sep 28, 2023
5 checks passed
@PanosSynetos PanosSynetos deleted the fix/1310-ensure-pages-are-deleted branch September 28, 2023 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WooCoomerce Create Pages: Introduce additional cache purging - Ensure pages are deleted
2 participants