[wp-trac] [WordPress Trac] #57580: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in functions.php
WordPress Trac
noreply at wordpress.org
Fri Jan 12 22:30:51 UTC 2024
#57580: strpos(): Passing null to parameter #1 ($haystack) of type string is
deprecated in functions.php
-------------------------------+-----------------------------
Reporter: ipajen | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 6.5
Component: General | Version: 6.2
Severity: normal | Resolution:
Keywords: PHP81 needs-patch | Focuses: administration
-------------------------------+-----------------------------
Changes (by sabernhardt):
* keywords: PHP81 close => PHP81 needs-patch
* status: closed => reopened
* focuses: => administration
* resolution: invalid =>
* milestone: => 6.5
Comment:
Core should edit the `add_submenu_page()` function. The //Codex//
incorrectly recommended using `null` for `$parent_slug` more than ten
years ago, and that example remains within a
[https://developer.wordpress.org/reference/functions/add_submenu_page/#comment-445
comment in the developer documentation].
One option is to check whether `$parent_slug` is empty before running
`plugin_basename()`, and it could assign an empty string (or
`options.php`) if it is empty.
{{{
$parent_slug = ( ! empty( $parent_slug ) ) ? plugin_basename( $parent_slug
) : '';
}}}
And if it checks for an empty `$parent_slug`, it probably could check
`$menu_slug` in a similar way on the
[https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/includes/plugin.php?rev=56571#L1408 line above that].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57580#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list