[wp-trac] [WordPress Trac] #59365: Deprecated notice when calling get_admin_page_title() on some dashboard pages.
WordPress Trac
noreply at wordpress.org
Wed Jul 10 17:06:26 UTC 2024
#59365: Deprecated notice when calling get_admin_page_title() on some dashboard
pages.
-----------------------------------------------+---------------------------
Reporter: apedog | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Administration | Version:
Severity: minor | Resolution:
Keywords: has-patch reporter-feedback php81 | Focuses: php-
| compatibility
-----------------------------------------------+---------------------------
Comment (by hellofromTonya):
Diving into the issue ...
The root case is not in the `get_plugin_page_hookname()` function.
Why? It requires a non-nullable `string` to be passed to its
`$plugin_page` parameter
([https://developer.wordpress.org/reference/functions/get_plugin_page_hookname/
see the documentation for more information]). Passing `null` to its
`$plugin_page` parameter is incorrect and the deprecation notice is
correct if this happens.
This means, the root cause is ''elsewhere in the call stack'' and needs to
be fixed upstream of this function. That could be in how a plugin is
registering its settings page, something is unsetting or setting the
global variable to `null`, etc.
**Are there clues in the call stack?**
Possibly. The call stack (thank you for providing it):
* `get_admin_page_title()` is invoked.
* `get_admin_page_title()` invoked `get_plugin_page_hook()` and passed the
global `$plugin_page` variable to it.
* `get_plugin_page_hook()` invoked `get_plugin_page_hookname()` and passed
`$plugin_page` to it.
`get_plugin_page_hook()` has no function parameters. Instead, it uses the
global variables `$title` and `$plugin_page`. If `$title` is not empty,
then the title is returned, exiting out of the function. Else,
`get_plugin_page_hook()` is invoked, passing the global `$plugin_page`
variable to it. (More on this in a moment.)
`get_plugin_page_hook()` also requires a non-nullable `string` to be
passed to its `$plugin_page` parameter
([https://developer.wordpress.org/reference/functions/get_plugin_page_hook/
see the documentation for more information]).
So how would `null` be passed to the functions?
Both of these need to be true:
1. The global variable `$title` is empty or not set.
2. The URL does not have a `?page` query parameter.
As noted in the description, it happens when the global variable is
`null`.
>This occurs on all pages where global `$plugin_page` is null (Plugins,
Tools, etc.)
The Tools and Plugins admin page are built-in Core and have dedicated PHP
files:
* Tools admin page is `admin/tools.php` and has the global `$title`
variable set to "Tools" within that file.
* Plugins admin page is `admin/plugins.php` and has the global `$title`
variable set to "Plugins" within that file.
If the deprecation notice is happening on those admin pages, then it means
some code somewhere incorrectly setting (to `null`) or unsetting the
global `$title` variable.
@apedog Can you please confirm if the deprecation notice is being thrown
on the Tools and Plugins admin page please?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59365#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list