-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Template activation: fix undefined array key PHP warning #72729
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
Conversation
d27e2f5 to
e39f21d
Compare
|
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 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. |
|
Flaky tests detected in 9c900ee. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18902483125
|
| $object = get_queried_object(); | ||
| $specific_template = $object ? get_page_template_slug( $object ) : null; | ||
| $object_id = get_queried_object_id(); | ||
| $specific_template = $object_id && get_post( $object_id ) ? get_page_template_slug( $object_id ) : null; |
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.
| $specific_template = $object_id && get_post( $object_id ) ? get_page_template_slug( $object_id ) : null; | |
| $specific_template = $object_id ? get_page_template_slug( $object_id ) : null; |
The get_page_template_slug also performs a get_post check and bails early. See: https://developer.wordpress.org/reference/functions/get_page_template_slug/
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.
Oh nice. Perhaps safer to pass an ID instead of a whole queried object though?
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.
Yes. ID is probably safer in this case
Developed in #10425. See https://core.trac.wordpress.org/ticket/62755. * Rename new endpoints, WordPress/gutenberg#72700. * Remove fake post type for registered templates, WordPress/gutenberg#72674. * Remove the ability to deactivate registered templates, WordPress/gutenberg#72636, * Fix undefined array key PHP warning, WordPress/gutenberg#72729. * Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and #10418. Fixes #62755. Props ellatrix, priethor. git-svn-id: https://develop.svn.wordpress.org/trunk@61078 602fd350-edb4-49c9-b593-d223f7449a82
Developed in WordPress/wordpress-develop#10425. See https://core.trac.wordpress.org/ticket/62755. * Rename new endpoints, WordPress/gutenberg#72700. * Remove fake post type for registered templates, WordPress/gutenberg#72674. * Remove the ability to deactivate registered templates, WordPress/gutenberg#72636, * Fix undefined array key PHP warning, WordPress/gutenberg#72729. * Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and WordPress/wordpress-develop#10418. Fixes #62755. Props ellatrix, priethor. Built from https://develop.svn.wordpress.org/trunk@61078 git-svn-id: http://core.svn.wordpress.org/trunk@60414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Developed in WordPress/wordpress-develop#10425. See https://core.trac.wordpress.org/ticket/62755. * Rename new endpoints, WordPress/gutenberg#72700. * Remove fake post type for registered templates, WordPress/gutenberg#72674. * Remove the ability to deactivate registered templates, WordPress/gutenberg#72636, * Fix undefined array key PHP warning, WordPress/gutenberg#72729. * Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and WordPress/wordpress-develop#10418. Fixes #62755. Props ellatrix, priethor. Built from https://develop.svn.wordpress.org/trunk@61078 git-svn-id: https://core.svn.wordpress.org/trunk@60414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
e39f21d to
9c900ee
Compare
Mamaduka
left a comment
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.
Thanks, @ellatrix!
Co-authored-by: ellatrix <[email protected]> Co-authored-by: Mamaduka <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 0bf76a7 |
)" This reverts commit 0bf76a7.
What?
Closes https://core.trac.wordpress.org/ticket/62755#comment:11
get_queried_objectdoes not return a post. We should double check that it's a post before getting the slug. This doesn't actually fix anything, but it would be good practice.Why?
Avoid PHP warnings.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast