Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Check if Cart and Checkout are registered before removing payment methods #4056

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

senadir
Copy link
Member

@senadir senadir commented Apr 13, 2021

Fixes woocommerce/woocommerce#29656

Elementor empties $wp_scripts and $wp_styles when rendering its editor (which is very dangerous), this breaks our integrations which must run after wp_enqueue_scripts and at the beginning of wp_print_scripts.

In this PR, I check if our scripts are still registered before validating payment methods dependencies.

This might have caused a regression with #3920 so more testing should happen using that PR steps.

Testing steps

  • On a website with PHP 8, install Elementor.
  • Create a new page, and select "Edit with Elementor", there should be no fatal errors.

Regression testing.

Changelog

Fix a compatibility bug with Elementor editor and PHP 8

@senadir senadir added type: bug The issue/PR concerns a confirmed bug. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. type: compatibility priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. labels Apr 13, 2021
@senadir senadir requested a review from Aljullu April 13, 2021 12:55
@senadir senadir self-assigned this Apr 13, 2021
@senadir senadir requested a review from a team as a code owner April 13, 2021 12:55
@senadir senadir added this to the 4.9.1 milestone Apr 13, 2021
@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 1.16 MB

ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 8.63 kB 0 B
build/active-filters.js 8.7 kB 0 B
build/all-products-frontend.js 35.6 kB 0 B
build/all-products.js 36.9 kB 0 B
build/all-reviews.js 9.92 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 1.8 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 2.21 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 335 B 0 B
build/atomic-block-components/add-to-cart-frontend.js 9.01 kB 0 B
build/atomic-block-components/add-to-cart.js 7.84 kB 0 B
build/atomic-block-components/button-frontend.js 2.02 kB 0 B
build/atomic-block-components/button.js 896 B 0 B
build/atomic-block-components/category-list-frontend.js 469 B 0 B
build/atomic-block-components/category-list.js 477 B 0 B
build/atomic-block-components/image-frontend.js 1.82 kB 0 B
build/atomic-block-components/image.js 1.29 kB 0 B
build/atomic-block-components/price-frontend.js 1.98 kB 0 B
build/atomic-block-components/price.js 2 kB 0 B
build/atomic-block-components/rating-frontend.js 521 B 0 B
build/atomic-block-components/rating.js 524 B 0 B
build/atomic-block-components/sale-badge-frontend.js 861 B 0 B
build/atomic-block-components/sale-badge.js 868 B 0 B
build/atomic-block-components/sku-frontend.js 391 B 0 B
build/atomic-block-components/sku.js 394 B 0 B
build/atomic-block-components/stock-indicator-frontend.js 570 B 0 B
build/atomic-block-components/stock-indicator.js 572 B 0 B
build/atomic-block-components/summary-frontend.js 918 B 0 B
build/atomic-block-components/summary.js 925 B 0 B
build/atomic-block-components/tag-list-frontend.js 465 B 0 B
build/atomic-block-components/tag-list.js 472 B 0 B
build/atomic-block-components/title-frontend.js 1.41 kB 0 B
build/atomic-block-components/title.js 1.26 kB 0 B
build/attribute-filter-frontend.js 18.4 kB 0 B
build/attribute-filter.js 12.5 kB 0 B
build/blocks-checkout.js 13.7 kB 0 B
build/blocks.js 3.49 kB 0 B
build/cart-frontend.js 77.7 kB 0 B
build/cart.js 43.6 kB 0 B
build/checkout-frontend.js 82 kB 0 B
build/checkout.js 45.8 kB 0 B
build/editor-rtl.css 14.9 kB 0 B
build/editor.css 14.9 kB 0 B
build/featured-category.js 7.87 kB 0 B
build/featured-product.js 10.1 kB 0 B
build/handpicked-products.js 6.5 kB 0 B
build/price-filter-frontend.js 14.8 kB 0 B
build/price-filter.js 10 kB 0 B
build/price-format.js 1.46 kB 0 B
build/product-best-sellers.js 6.59 kB 0 B
build/product-categories.js 3.23 kB 0 B
build/product-category.js 7.57 kB 0 B
build/product-new.js 6.76 kB 0 B
build/product-on-sale.js 7.17 kB 0 B
build/product-search.js 3.6 kB 0 B
build/product-tag.js 6.61 kB 0 B
build/product-top-rated.js 6.73 kB 0 B
build/products-by-attribute.js 7.51 kB 0 B
build/reviews-by-category.js 12 kB 0 B
build/reviews-by-product.js 13.5 kB 0 B
build/reviews-frontend.js 9.59 kB 0 B
build/single-product-frontend.js 38.7 kB 0 B
build/single-product.js 10.3 kB 0 B
build/style-rtl.css 18.8 kB 0 B
build/style.css 18.8 kB 0 B
build/vendors--atomic-block-components/price-frontend.js 6.54 kB 0 B
build/vendors-style-rtl.css 1.05 kB 0 B
build/vendors-style.css 1.05 kB 0 B
build/vendors.js 419 kB 0 B
build/wc-blocks-data.js 7.35 kB 0 B
build/wc-blocks-google-analytics.js 1.99 kB 0 B
build/wc-blocks-middleware.js 1.32 kB 0 B
build/wc-blocks-registry.js 2.75 kB 0 B
build/wc-payment-method-bacs.js 812 B 0 B
build/wc-payment-method-cheque.js 807 B 0 B
build/wc-payment-method-cod.js 903 B 0 B
build/wc-payment-method-paypal.js 844 B 0 B
build/wc-payment-method-stripe.js 12.3 kB 0 B
build/wc-settings.js 2.83 kB 0 B
build/wc-shared-context.js 1.54 kB 0 B
build/wc-shared-hocs.js 1.71 kB 0 B

compressed-size-action

Copy link
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

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

Code looks okay to me. I didn't test though.

@senadir senadir modified the milestones: 4.9.1, 4.7.1 Apr 13, 2021
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

I tested #3920 and it looks like it was not regressed. I also followed the testing steps in this PR with PHP 7.4 and couldn't find any error in the logs.

LGTM

@senadir senadir merged commit cf1eaac into trunk Apr 13, 2021
@senadir senadir deleted the fix/protect-fatal-when-wpscripts-not-set branch April 13, 2021 13:27
senadir added a commit that referenced this pull request Apr 13, 2021
senadir added a commit that referenced this pull request Apr 13, 2021
senadir added a commit that referenced this pull request Apr 13, 2021
@senadir senadir modified the milestones: 4.9.1, 4.7.2 Apr 13, 2021
senadir added a commit that referenced this pull request Apr 18, 2021
* Check if Cart and Checkout are registered before removing payment methods so it won't break Elementor (#4056)

* Empty commit for release pull request

* update versions and add testing file

* add download file

* Bumping version strings to new version.

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
senadir added a commit that referenced this pull request Apr 19, 2021
* Check if Cart and Checkout are registered before removing payment methods so it won't break Elementor (#4056)

* generating changeset for pull request

* generating changeset for pull request

* update version

* add testing instrcutions

* update release.md file

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue/PR concerns a confirmed bug. type: compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error: WooCommerce 5.2 and Elementor
3 participants