Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: depreciated notice when call preg_replace method in wp-admin/includes/plugin.php #5231

Conversation

nasimcoderex
Copy link

Ticket : https://core.trac.wordpress.org/ticket/59365

Description:

Check the string before using preg_replace method in wp-admin/includes/plugin.php file

Trac ticket:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@hellofromtonya
Copy link
Contributor

Thank you @nasimcoderex for the patch. However, it's not fixing the root cause. Let me explain (a more detailed explanation is here in the Trac ticket).

get_plugin_page_hookname() requires a non-nullable string to be passed to its $plugin_page parameter (see the documentation).

Passing null is incorrect. If null is passed to it, then the PHP native preg_replace() will throw the deprecation notice. The deprecation notice is informing of the incorrect data type received. (Currently) Core itself does not do incoming parameter data checks to ensure the incoming data is of the required type. Rather, it leans into it's documentation with the expectation of what's documented being the required data type(s) the function requires.

As this function is receiving a null instead of a string, the root cause is elsewhere. Thus, the fix is also elsewhere, i.e. where the root cause is (yet to be discovered).

I'm closing this PR. Once the root cause is found and if a Core fix needed, please consider opening a new PR to resolve it. Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants