[wp-trac] [WordPress Trac] #59297: Remove unused variables (was: Remove Unused variables in the wp-admin folder.)
WordPress Trac
noreply at wordpress.org
Mon Feb 19 23:49:34 UTC 2024
#59297: Remove unused variables
--------------------------+-------------------------------
Reporter: upadalavipul | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: coding-standards
--------------------------+-------------------------------
Changes (by sabernhardt):
* keywords: => has-patch
Comment:
When uploading multiple patches to one ticket, please use the attachment's
Description field to identify what makes it different from the other
patches.
59297.patch changes two files:
- It removes `$content`, `$class`, `$meta` from `privacy_policy_guide()`.
These variables might not have any value after [50161], unless they still
help with the deprecated `wp_get_default_privacy_policy_content` filter.
- The same patch also removes `$hidden_inputs` from
`the_block_editor_meta_box_post_form_hidden_fields()`, which was added in
#45283 / [44241]. Could this have some use in the
`block_editor_meta_box_hidden_fields` hook?
59297.2.patch removes the `$post_ID` variable from `wp-admin/edit-form-
advanced.php` and `wp-admin/post-new.php` (note: other `$post_ID`
variables had been updated to `$post_id` in #57692, but not the global).
59297.3.patch proposes removing `$compat` and `$submenu` from `wp-
admin/user/menu.php`. However, **both are used** in `wp-
admin/includes/menu.php`.
59297.4.patch proposes removing `$parent_file`, `$title` and/or `$pagenum`
variables from three network admin pages.
- The `$title` and `$parent_file` variables are **necessary** for use in
`wp-admin/admin-header.php` (#53729).
- The `$pagenum` variable was added to `network/sites.php` in [17274], but
then [17900] removed where it was used. Also, [27499] removed `$pagenum`
from `wp-admin/includes/theme-install.php`. If it does not belong in
`network/sites.php` anymore, then it probably could be deleted from four
files:
1. [https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/network/sites.php?rev=56515#L18 wp-admin/network/sites.php, line 18]
2. [https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/network/themes.php?rev=56601#L18 wp-admin/network/themes.php, line
18]
3. [https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/plugins.php?rev=57586#L17 wp-admin/plugins.php, line 17]
4. [https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/upload.php?rev=56663#L252 wp-admin/upload.php, line 252]
59297.5.patch edits multiple files in the `wp-includes` directory:
- It removes `$more` from `wp-includes/feed-atom.php` but not the other
feeds (`feed-rdf.php`, `feed-rss.php` and `feed-rss2.php`). If one file
does not use the variable, the other three might not either.
- In `wp-includes/link-template.php`, the patch removes `$tax` from
`edit_term_link()`.
[https://core.trac.wordpress.org/changeset/38698/trunk/src/wp-includes
/link-template.php#file0 Changeset 38698] replaced `$tax` in that
function, though the similar function `get_edit_term_link()` still uses
the variable. Is it worth adding a `! $tax` condition in
`edit_term_link()` too, or would removing the `$tax` variable be
preferable?
- The `$wpdb` global documentation can be removed from the
`get_blog_id_from_url()` docblock. [37620] removed the global from that
function.
- In `wp-includes/ms-load.php`, the patch proposes removing `$blog_id`
from `ms_load_current_site_and_network()`.
59297.6.patch suggests removing `$AudioChunkStreamNum` from the
[https://github.com/JamesHeinrich/getID3/blob/c6e24a206132b64a0cb54d33c869afd76d1b01ec/getid3/module
.audio-video.riff.php#L1547 getID3 RIFF module], but that should be
reported on the external library's GitHub repository. The patch also
deletes the `$unapproved_ids` and `$unapproved_emails`, which were
**already removed** by [55559].
59297.7.patch has multiple changes:
- It removes `$blog_id`, `$_wp_switched_stack` and `$switched` from `wp-
includes/ms-settings.php`. As noted in ticket:59420#comment:2, the
`$_wp_switched_stack` and `$switched` globals **are necessary**.
- I am not sure about whether `$blog_id` can be removed from `wp-includes
/ms-settings.php`.
- The `class-wp-rest-server.php` change was **already committed** in
[56645].
==== Patches from #59420
[https://core.trac.wordpress.org/attachment/ticket/59420/59420.5.patch
59420.5.patch] and
[https://core.trac.wordpress.org/attachment/ticket/59420/59420.6.patch
59420.6.patch] remove `$returnType` and `$method` variables from
`IXR_IntrospectionServer::call()` (the IXR library is "adopted" - see
comment:2:ticket:48267). Note that //a// `$method` variable is used within
other parts of the class, though I am not sure it is the //same//
variable.
[https://core.trac.wordpress.org/attachment/ticket/59420/59420.8.patch
59420.8.patch] proposes changes to two files:
- The `privacy_policy_guide()` revisions are already part of 59297.patch.
- The patch removes `$network_exists` from in `wp-
admin/includes/schema.php`. The variable was added in [41348].
[https://core.trac.wordpress.org/attachment/ticket/59420/59420.10.patch
59420.10.patch] proposes multiple changes:
- The `$parent_file` is necessary to keep in both `wp-
admin/network/settings.php` and `wp-admin/network/sites.php`.
- The patch also removes `$is_main_site` from `wp-admin/network/site-
users.php`. One significant commit related to `$is_main_site` is [15903],
when the variable was moved from `network/sites.php`.
- The `$pagenum` might not be necessary in `wp-admin/network/sites.php`,
but see the note above about the possibility of removing it from other
files too.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59297#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list