Skip to content
Open
Changes from all commits
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
5 changes: 4 additions & 1 deletion src/wp-admin/admin-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
}

get_admin_page_title();
$title = strip_tags( $title );

if ( ! is_null( $title ) ) {
$title = wp_strip_all_tags( $title ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
}
Comment on lines +36 to +39
Copy link
Author

Choose a reason for hiding this comment

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

Since wp_strip_all_tags() now handles null (see related trac ticket and commit d46dc08), I suppose we could do without the extra check, and only replace strip_tags by wp_strip_all_tags:

Suggested change
if ( ! is_null( $title ) ) {
$title = wp_strip_all_tags( $title ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
}
$title = wp_strip_all_tags( $title ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

Copy link
Member

@jrfnl jrfnl Apr 6, 2023

Choose a reason for hiding this comment

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

HIya @jeherve !

IMO, the pulled fix is not the right approach/fix for the following reason: $title may still be null afterwards.
This means, the problem is now moved to subsequent functions which may be handling $title and using PHP native functions to do so, so this is just setting WP up for the next bug report instead of fixing the actual issue that $title should always be set and set to a string.

As for the second proposal (comment above), which I do think is better, there is one thing I'd like to point out about that:

  • Yes, it will handle null silently, but for anything scalar but non-string, that will now yield a warning, which is a significantly higher error level than the original deprecation (though justifiable).

In both cases, the // phpcs:ignore ... comment needs to be removed as that WPCS rule does not apply to WP Core and we should not add unnecessary noise like that to the codebase.


if ( is_network_admin() ) {
/* translators: Network admin screen title. %s: Network title. */
Expand Down