[wp-trac] [WordPress Trac] #56799: PHP notice in class-wp-block-supports.php
WordPress Trac
noreply at wordpress.org
Tue Oct 11 18:44:09 UTC 2022
#56799: PHP notice in class-wp-block-supports.php
------------------------------+-----------------------------
Reporter: petitphp | Owner: hellofromTonya
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.1
Component: Editor | Version: trunk
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses:
------------------------------+-----------------------------
Changes (by hellofromTonya):
* status: reviewing => closed
* resolution: => fixed
Comment:
In [changeset:"54498" 54498]:
{{{
#!CommitTicketReference repository="" revision="54498"
Editor: Fix PHP notice in `WP_Block_Supports` when no attributes declared.
A check is added to verify if the block's `'attrs'` key exists before
accessing it. If no, it defaults to an empty array.
How was this found?
WP 6.1 removed the attributes from the `core/page-list` block. When this
block is being processed by `WP_Block_Supports::apply_block_supports()`,
the key `'attrs'` does not exist in `self::$block_to_render`.
This commit includes a tiny micro-optimization by moving this line of code
after the existing guard clause. Why? If the guard clause is triggered,
the method bails out early, meaning the attributes code is not used. By
moving it after the guard clause, it saves a tiny bit of memory and
processing if this happens.
Follow-up to [49310], [54399].
Props petitphp, spacedmonkey, hellofromTonya.
Fixes #56799.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56799#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list