[wp-trac] [WordPress Trac] #59622: Block supports: Avoid warning for non string class attributes

WordPress Trac noreply at wordpress.org
Fri Oct 13 20:13:02 UTC 2023


#59622: Block supports: Avoid warning for non string class attributes
--------------------------+-----------------------------
 Reporter:  dmsnell       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:  trunk
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 Block Supports: Avoid throwing warning when checking for class attribute
 as string.

 When encountering HTML tags with boolean or missing tags, the
 `get_attribute()`
 method in the HTML API returns `true` and `null`, respectively. If these
 returned
 values are sent directly into string comparison functions then as of PHP
 8.0 they
 will throw `E_DEPRECATED` errors.

 In this patch, block supports is enhanced to check that the `class` value
 is a
 string before it performs string operations on it.

 ---

 There is a small likelihood of any real damage in production here, as
 these are only deprecation notices and the logic in these cases isn't
 affected by the change. That is,
 the intention of the code is maintained even when the attribute values
 aren't strings.

 For background support there's a tiny but benign defect when the `style`
 attribute is
 boolean. It will erroneously inject a `;` at the beginning of the
 wrapper's new `style`
 value. As this doesn't impact the rendering of the wrapper, it's not a
 true defect.

 Further review belongs to block rendering code, but this will occur in the
 Gutenberg
 repo since that PHP comes back into Core through the generated packages.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59622>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list