[wp-trac] [WordPress Trac] #57579: Replace most strip_tags() with wp_strip_tags() (was: Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in admin-header.php)
WordPress Trac
noreply at wordpress.org
Tue Aug 8 19:01:53 UTC 2023
#57579: Replace most strip_tags() with wp_strip_tags()
-------------------------------------------------+-------------------------
Reporter: ipajen | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
| Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: php81 has-patch changes-requested | Focuses: php-
needs-unit-tests | compatibility
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* focuses: => php-compatibility
Old description:
> When using the plugin HD Quiz this warning is given in version
> 6.2-alpha-55159 with PHP 8.1.
>
> Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type
> string is deprecated in /public_html/blog/wp-admin/admin-header.php on
> line 36
>
> Link to ticket for plugin:
> [https://wordpress.org/support/topic/strip_tags-php8-1-warning/#new-
> topic-0]
>
> "Core expects the $title global to always be set when wp-admin/admin-
> header.php is included." Is there something Core can do to improve the
> experience here?
New description:
Originally reported as an issue with `strip_tags()` in `wp-admin/admin-
header.php`, this ticket's scope as grown to initiative to replace
`strip_tags()` with `wp_strip_tags()`.
Proposal:
* Replace most calls to `strip_tags()` with calls to `wp_strip_all_tags()`
@peterwilsoncc [#comment:1 notes]:
>this is a slight compatibility change as it will strip the contents of
`<style>` and `<script>` tags, but I don't think that's a bad thing
* Add an early check in `wp-admin/admin-header.php` to set up the global
variables.
@jrf [#comment:2 notes]:
>I can see one more alternative option, which could (should) possible be
applied in conjunction with the solution suggested by @peterwilsoncc: for
`wp-admin/admin-header.php` to do an early check for the global variables
it requires to be set and to set those to a default value (for example, an
empty string for `$title`) if the variable is not available.
The original reported issue:
When using the plugin HD Quiz this warning is given in version
6.2-alpha-55159 with PHP 8.1.
{{{
Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type
string is deprecated in /public_html/blog/wp-admin/admin-header.php on
line 36
}}}
Link to ticket for plugin:
[https://wordpress.org/support/topic/strip_tags-php8-1-warning/#new-
topic-0]
"Core expects the $title global to always be set when wp-admin/admin-
header.php is included." Is there something Core can do to improve the
experience here?
--
Comment:
This ticket's scope has grown past the original reported issue. Thus, I've
updated the Summary and Description to help contributors know what is
being proposed and the work yet to be done.
I've also added the `php-compatibility` focus to include `strip_tags()`
usage in Core in the PHP 8.1 compat exclusion list.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57579#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list