Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,12 @@ private function _process_directives( string $html ) {
array_pop( $tag_stack );
}
} else {
if ( 0 !== count( $p->get_attribute_names_with_prefix( 'data-wp-each-child' ) ) ) {
$each_child_attrs = $p->get_attribute_names_with_prefix( 'data-wp-each-child' );
if ( ! is_countable( $each_child_attrs ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a null check here, it's more consistent with other HTML API code:

Suggested change
if ( ! is_countable( $each_child_attrs ) ) {
if ( null === $each_child_attrs ) {

continue;
}

if ( 0 !== count( $each_child_attrs ) ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure right now, but I think the else block below should execute when $each_child_attrs is null, shouldn't it?

At least that's the behavior in PHP < 8.0, when count() returned 0 if null is passed.

Suggested change
if ( ! is_countable( $each_child_attrs ) ) {
continue;
}
if ( 0 !== count( $each_child_attrs ) ) {
if ( null !== $each_child_attrs && 0 !== count( $each_child_attrs ) ) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right. I thought it only contained a foreach with another get_attribute_names_with_prefix() but it contains another conditional block.

That other get_attribute_names_with_prefix has the same problem where it lacks a null check.

/*
* If the tag has a `data-wp-each-child` directive, jump to its closer
* tag because those tags have already been processed.
Expand Down
Loading