Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @oryfoxer. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +5 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
91434e7 to
db773c7
Compare
joemcgill
left a comment
There was a problem hiding this comment.
This looks right to me. It would probably be worth adding a unit test to catch this behavior in the future.
| return defaultTemplateId | ||
| ? select( coreStore ).getEditedEntityRecord( | ||
| 'postType', | ||
| 'wp_template', | ||
| defaultTemplateId | ||
| ) | ||
| : null; |
There was a problem hiding this comment.
I checked the return type of getEditedEntityRecord because sometimes the return type is important. And apparently it's gone through some recent changes; previously returning undefined and now returning false (see #60988). That being said, it seems null is fine here even if that's different from the previous two return values with how getEditedPostTemplate is used since it's only looking for falsy values, not anything specific.
|
I just cherry-picked this PR to the release/18.4 branch to get it included in the next release: afe6c6b |
…mplates/lookup) (#60925) Unlinked contributors: oryfoxer. Co-authored-by: creativecoder <grantmkin@git.wordpress.org> Co-authored-by: joemcgill <joemcgill@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: david-binda <davidbinda@git.wordpress.org>
Noting that there is a unit test that was added in the core patch (https://core.trac.wordpress.org/changeset/58079). I didn't duplicate it here in Gutenberg since the endpoint override here should be short lived, assuming the changes land in WP 6.6 as expected. |
…mplates/lookup) (WordPress#60925) Unlinked contributors: oryfoxer. Co-authored-by: creativecoder <grantmkin@git.wordpress.org> Co-authored-by: joemcgill <joemcgill@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: david-binda <davidbinda@git.wordpress.org>
…mplates/lookup) (WordPress#60925) Unlinked contributors: oryfoxer. Co-authored-by: creativecoder <grantmkin@git.wordpress.org> Co-authored-by: joemcgill <joemcgill@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: david-binda <davidbinda@git.wordpress.org>
What?
When a classic theme uses a theme.json file, it may not have any block templates available. This change modifies the
wp/v2/templates/lookupto return an empty object when no fallback templates available, rather than an object full of empty properties, to avoid PHP errors being triggered.Fixes https://core.trac.wordpress.org/ticket/60909
Fixes #60974
Companion wordpress-develop PR: WordPress/wordpress-develop#6420
Why?
Testing Instructions
{ "version": 2 })/wp-json/wp/v2/templates/lookuprespond with an empty object in the browser network tab