This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Add protection against wrong params in get_block_template_fallback() #11690
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
woocommercebot
requested review from
a team and
dinhtungdu
and removed request for
a team
November 8, 2023 12:19
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.54 MB ℹ️ View Unchanged
|
Aljullu
added
status: needs review
type: bug
The issue/PR concerns a confirmed bug.
focus: template
Related to API powering block template functionality in the Site Editor
labels
Nov 8, 2023
Aljullu
changed the title
Add protection towards wrong params in get_block_template_fallback()
Add protection against wrong params in get_block_template_fallback()
Nov 8, 2023
dinhtungdu
approved these changes
Nov 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is testing well. I can confirm there isn't any error/warning adding testing code with invalid parameters.
Aljullu
force-pushed
the
fix/get_block_template_fallback-protect-params
branch
from
November 8, 2023 15:36
d55197b
to
e144909
Compare
Aljullu
added a commit
that referenced
this pull request
Nov 8, 2023
…11690) * Add protection towards wrong params in get_block_template_fallback() * Improve protection
Aljullu
added a commit
that referenced
this pull request
Nov 8, 2023
* Empty commit for release pull request * Add readme and testing notes * Bump versions to 11.5.1 * Fix Single Product Classic Template block not showing on the front-end (#11455) In WordPress 6.4, it appears that the global `have_posts` is `false` in the context of the full site editing single product template. This breaks the Classic Template block. In this commit, we are creating a custom query using the available id instead of relying on the global query. This might be a temporary workaround as we are waiting to see if that's an issue that core is willing to fix, as it might affect backwards-compatibility for other vendors. (cherry picked from commit d9e8809) * Update testing notes with new zip file * Add protection against wrong params in get_block_template_fallback() (#11690) * Add protection towards wrong params in get_block_template_fallback() * Improve protection * Update WC Blocks 11.5.1 changelog and testing steps with new fix --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Lucio Giannotta <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]>
gigitux
added a commit
that referenced
this pull request
Nov 8, 2023
* Empty commit for release pull request * Add readme and testing notes * Bump versions to 11.5.1 * Fix Single Product Classic Template block not showing on the front-end (#11455) In WordPress 6.4, it appears that the global `have_posts` is `false` in the context of the full site editing single product template. This breaks the Classic Template block. In this commit, we are creating a custom query using the available id instead of relying on the global query. This might be a temporary workaround as we are waiting to see if that's an issue that core is willing to fix, as it might affect backwards-compatibility for other vendors. (cherry picked from commit d9e8809) * Update testing notes with new zip file * Add protection against wrong params in get_block_template_fallback() (#11690) * Add protection towards wrong params in get_block_template_fallback() * Improve protection * Update WC Blocks 11.5.1 changelog and testing steps with new fix * bump version * [CYS] Fix decoding issue and pattern (#11681) * Fix pattern description * Decode the actual file content, not the filepath * Use wp_post table instead wp_option to store patterns data generated by AI (#11659) * Use wp_post table instead wp_option to store patterns data generated by AI * avoid crash when there isn't any patterns_ai_data post type * restore check * remove unnecessary constant * catch error * pass boolean to return WP_Error * Rename Centered Header Menu with Search pattern (#11637) * Rename Centered Header Menu with Search pattern Since the search bar has been removed from this pattern, this PR renames the pattern title and slug to reflect that change. * Rename file to reflect search removal. Remove `search` from the filename, as this no longer reflects the pattern. * Add missing condition to avoid a php warning when 'plugins' is not set (#11652) * Fix pattern route performance (#11535) * fix pattern route performance * update namespace * improve middleware * improve ProductSchema * improve error handling * update identifier * fix middleware * update description * use schema to return the response * Break down the generate_content method and create the new fetch_dummy_products_to_update method for handling the fetch of dummy products to be updated. * Ensure the Product endpoint relies on the fetch_dummy_products_to_update method for fetching dummy products to avoid code repetition and add safety checks and handle errors in case certain properties are not available. * Add error handling for the Products endpoint. * Remove memory limit increase and update docblocks. * re-add set_time_limit --------- Co-authored-by: Patricia Hillebrandt <[email protected]> * Empty commit for release pull request * add testing instructions * add zip link --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Lucio Giannotta <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Luigi <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Daniel W. Robert <[email protected]> Co-authored-by: Patricia Hillebrandt <[email protected]>
gigitux
added a commit
that referenced
this pull request
Nov 8, 2023
* Empty commit for release pull request * Add readme and testing notes * Bump versions to 11.5.1 * Fix Single Product Classic Template block not showing on the front-end (#11455) In WordPress 6.4, it appears that the global `have_posts` is `false` in the context of the full site editing single product template. This breaks the Classic Template block. In this commit, we are creating a custom query using the available id instead of relying on the global query. This might be a temporary workaround as we are waiting to see if that's an issue that core is willing to fix, as it might affect backwards-compatibility for other vendors. (cherry picked from commit d9e8809) * Update testing notes with new zip file * Add protection against wrong params in get_block_template_fallback() (#11690) * Add protection towards wrong params in get_block_template_fallback() * Improve protection * Update WC Blocks 11.5.1 changelog and testing steps with new fix * bump version * [CYS] Fix decoding issue and pattern (#11681) * Fix pattern description * Decode the actual file content, not the filepath * Use wp_post table instead wp_option to store patterns data generated by AI (#11659) * Use wp_post table instead wp_option to store patterns data generated by AI * avoid crash when there isn't any patterns_ai_data post type * restore check * remove unnecessary constant * catch error * pass boolean to return WP_Error * Rename Centered Header Menu with Search pattern (#11637) * Rename Centered Header Menu with Search pattern Since the search bar has been removed from this pattern, this PR renames the pattern title and slug to reflect that change. * Rename file to reflect search removal. Remove `search` from the filename, as this no longer reflects the pattern. * Add missing condition to avoid a php warning when 'plugins' is not set (#11652) * Fix pattern route performance (#11535) * fix pattern route performance * update namespace * improve middleware * improve ProductSchema * improve error handling * update identifier * fix middleware * update description * use schema to return the response * Break down the generate_content method and create the new fetch_dummy_products_to_update method for handling the fetch of dummy products to be updated. * Ensure the Product endpoint relies on the fetch_dummy_products_to_update method for fetching dummy products to avoid code repetition and add safety checks and handle errors in case certain properties are not available. * Add error handling for the Products endpoint. * Remove memory limit increase and update docblocks. * re-add set_time_limit --------- Co-authored-by: Patricia Hillebrandt <[email protected]> * Empty commit for release pull request * add testing instructions * add zip link * [CYS] Fix decoding issue and pattern (#11681) * Fix pattern description * Decode the actual file content, not the filepath * bump version * add changelog * add zip link * add link to the readme --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Lucio Giannotta <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Luigi <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Daniel W. Robert <[email protected]> Co-authored-by: Patricia Hillebrandt <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
focus: template
Related to API powering block template functionality in the Site Editor
type: bug
The issue/PR concerns a confirmed bug.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Fixes #
Why
Given that
get_block_template_fallback()
is executed on a filter, we need to add some validation to make sure the parameters received are valid. This PR does that.Testing Instructions
Verify there are no regressions in the Editor
/product-category/clothing/accessories/
).Verify there are protections against wrong parameters in the filter (to test only by devs)
BlockTemplatesController.php
L62:/product-category/clothing/accessories/
).WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog