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

Fix undefined variable in ProductSchema.php closure #2962

Merged
merged 1 commit into from Aug 7, 2020

Conversation

senadir
Copy link
Member

@senadir senadir commented Aug 4, 2020

Fixes the issue by defining use ( $product ) in the closure, as far as my googling went, this syntax is supported from PHP 5.3, so we're safe (WC requires 7.0).

Fixes #2896

How to test the changes in this Pull Request:

  1. You shouldn't see the notice anymore

How to test

0- Make sure you have WP_DEBUG set to true.
1- Load a page that already contains a product data, so single product or All Products, either in the editor or frontend.
2- Make sure no notices are printed to the page, you can check the source code or at the top of the page.

Changelog

Fix an undefined variable PHP notice related to Product REST API.

@senadir senadir added type: bug The issue/PR concerns a confirmed bug. block: all products Issues related to the all products block. labels Aug 4, 2020
@senadir senadir added this to the 3.2.0 milestone Aug 4, 2020
@senadir senadir requested a review from a team as a code owner August 4, 2020 17:08
@senadir senadir self-assigned this Aug 4, 2020
@senadir senadir requested review from nerrad and removed request for a team August 4, 2020 17:08
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2020

Size Change: 0 B

Total Size: 1.65 MB

ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 8.52 kB 0 B
build/active-filters.js 8.8 kB 0 B
build/all-products-frontend.js 30.9 kB 0 B
build/all-products.js 35.6 kB 0 B
build/all-reviews-legacy.js 9.4 kB 0 B
build/all-reviews.js 9.73 kB 0 B
build/atomic-block-components/add-to-cart-frontend.js 8.84 kB 0 B
build/atomic-block-components/add-to-cart.js 7.46 kB 0 B
build/atomic-block-components/add-to-cart~atomic-block-components/button.js 3.12 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/button-frontend.js 1.99 kB 0 B
build/atomic-block-components/button.js 839 B 0 B
build/atomic-block-components/category-list-frontend.js 468 B 0 B
build/atomic-block-components/category-list.js 476 B 0 B
build/atomic-block-components/image-frontend.js 1.71 kB 0 B
build/atomic-block-components/image.js 1.15 kB 0 B
build/atomic-block-components/price-frontend.js 2.08 kB 0 B
build/atomic-block-components/price.js 2.11 kB 0 B
build/atomic-block-components/rating-frontend.js 523 B 0 B
build/atomic-block-components/rating.js 527 B 0 B
build/atomic-block-components/sale-badge-frontend.js 862 B 0 B
build/atomic-block-components/sale-badge.js 864 B 0 B
build/atomic-block-components/sku-frontend.js 389 B 0 B
build/atomic-block-components/sku.js 394 B 0 B
build/atomic-block-components/stock-indicator-frontend.js 568 B 0 B
build/atomic-block-components/stock-indicator.js 571 B 0 B
build/atomic-block-components/summary-frontend.js 918 B 0 B
build/atomic-block-components/summary.js 926 B 0 B
build/atomic-block-components/tag-list-frontend.js 465 B 0 B
build/atomic-block-components/tag-list.js 473 B 0 B
build/atomic-block-components/title-frontend.js 1.22 kB 0 B
build/atomic-block-components/title.js 1.06 kB 0 B
build/attribute-filter-frontend.js 17.8 kB 0 B
build/attribute-filter.js 12.4 kB 0 B
build/blocks-legacy.js 3.54 kB 0 B
build/blocks.js 3.54 kB 0 B
build/cart-frontend.js 66.1 kB 0 B
build/cart.js 34.6 kB 0 B
build/checkout-frontend.js 83.1 kB 0 B
build/checkout.js 40 kB 0 B
build/editor-legacy-rtl.css 13.8 kB 0 B
build/editor-legacy.css 13.8 kB 0 B
build/editor-rtl.css 14 kB 0 B
build/editor.css 14 kB 0 B
build/featured-category-legacy.js 7.29 kB 0 B
build/featured-category.js 7.67 kB 0 B
build/featured-product-legacy.js 9.55 kB 0 B
build/featured-product.js 9.92 kB 0 B
build/handpicked-products-legacy.js 6.95 kB 0 B
build/handpicked-products.js 7.32 kB 0 B
build/price-filter-frontend.js 14.2 kB 0 B
build/price-filter.js 10.2 kB 0 B
build/product-best-sellers-legacy.js 7.03 kB 0 B
build/product-best-sellers.js 7.39 kB 0 B
build/product-categories-legacy.js 3.23 kB 0 B
build/product-categories.js 3.23 kB 0 B
build/product-category-legacy.js 7.94 kB 0 B
build/product-category.js 8.34 kB 0 B
build/product-new-legacy.js 7.19 kB 0 B
build/product-new.js 7.56 kB 0 B
build/product-on-sale-legacy.js 7.56 kB 0 B
build/product-on-sale.js 7.95 kB 0 B
build/product-search-legacy.js 3.17 kB 0 B
build/product-search.js 3.51 kB 0 B
build/product-tag-legacy.js 6.12 kB 0 B
build/product-tag.js 6.47 kB 0 B
build/product-top-rated-legacy.js 7.16 kB 0 B
build/product-top-rated.js 7.53 kB 0 B
build/products-by-attribute-legacy.js 7.92 kB 0 B
build/products-by-attribute.js 8.26 kB 0 B
build/reviews-by-category-legacy.js 11.4 kB 0 B
build/reviews-by-category.js 11.8 kB 0 B
build/reviews-by-product-legacy.js 12.9 kB 0 B
build/reviews-by-product.js 13.3 kB 0 B
build/reviews-frontend-legacy.js 8.23 kB 0 B
build/reviews-frontend.js 9.11 kB 0 B
build/single-product-frontend.js 33.8 kB 0 B
build/single-product.js 10.1 kB 0 B
build/style-legacy-rtl.css 16.8 kB 0 B
build/style-legacy.css 16.8 kB 0 B
build/style-rtl.css 17.5 kB 0 B
build/style.css 17.5 kB 0 B
build/vendors-legacy.js 367 kB 0 B
build/vendors-style-legacy-rtl.css 1.03 kB 0 B
build/vendors-style-legacy.css 1.03 kB 0 B
build/vendors-style-rtl.css 1.03 kB 0 B
build/vendors-style.css 1.03 kB 0 B
build/vendors.js 416 kB 0 B
build/vendors~atomic-block-components/price-frontend.js 5.65 kB 0 B
build/wc-blocks-data.js 7.09 kB 0 B
build/wc-blocks-middleware.js 931 B 0 B
build/wc-blocks-registry.js 2.28 kB 0 B
build/wc-payment-method-bacs.js 790 B 0 B
build/wc-payment-method-cheque.js 796 B 0 B
build/wc-payment-method-cod.js 875 B 0 B
build/wc-payment-method-paypal.js 831 B 0 B
build/wc-payment-method-stripe.js 11.9 kB 0 B
build/wc-settings.js 2.14 kB 0 B
build/wc-shared-context.js 1.53 kB 0 B
build/wc-shared-hocs.js 1.66 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.

Thanks for taking care of this Nadir. Code wise this is good, but I think our testing notes could include a bit more about what is impacted by this change (in particular anything that interacts with the routes using product schema). Can you expand on that in the testing notes please and include what should be tested to ensure there are no unexpected side-effects of this change?

I'll pre-approve but on the assumption additional testing notes will be added (and you've verified what you note works)

@@ -35,7 +35,7 @@ export const renderNoProductsPlaceholder = ( blockTitle, blockIcon ) => (
className="wc-block-products__add-product-button"
isDefault
isLarge
href={ adminUrl + 'post-new.php?post_type=product' }
href={ ADMIN_URL + 'post-new.php?post_type=product' }
Copy link
Contributor

Choose a reason for hiding this comment

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

wowzer! good catch here!

Copy link
Member Author

Choose a reason for hiding this comment

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

this was from another PR, not sure how it got here 😅, props to Albert.

Copy link
Member Author

Choose a reason for hiding this comment

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

this was from another PR, not sure how it got here 😅, props to Albert.

@nerrad
Copy link
Contributor

nerrad commented Aug 7, 2020

Tested okay, I also verified that there was no impact to variation meta data returned as a result of this change.

@nerrad nerrad merged commit e098f83 into main Aug 7, 2020
@nerrad nerrad deleted the fix/undefined-variable branch August 7, 2020 18:10
@senadir senadir mentioned this pull request Aug 19, 2020
20 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: all products Issues related to the all products block. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix undefined variable $product in ProductSchema.php
3 participants