Make WordPress Core

Opened 11 months ago

Last modified 6 months ago

#59297 new defect (bug)

Remove unused variables

Reported by: upadalavipul's profile upadalavipul Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: coding-standards Cc:

Description

I have reviewed the code and found some of the variables are defined but they do not use in the below files. Please check the below files:

Files:

  1. wp-admin/includes/class-wp-privacy-policy-content.php
  2. wp-admin/includes/post.php

Attachments (7)

59297.patch (1.0 KB) - added by upadalavipul 11 months ago.
patch added
59297.2.patch (905 bytes) - added by upadalavipul 11 months ago.
added two more files.
59297.3.patch (545 bytes) - added by viralsampat 11 months ago.
I have checked above mentioned issue and founds another file. Here, I have added its patch.
59297.4.patch (1.5 KB) - added by viralsampat 11 months ago.
I have checked above mentioned issue and founds another files. Here, I have added its patch.
59297.5.patch (1.7 KB) - added by viralsampat 11 months ago.
I have added another patch
59297.6.patch (1.4 KB) - added by viralsampat 9 months ago.
I have checked above mentioned issue and founds few files. Here, I have added its patch.
59297.7.patch (1.3 KB) - added by viralsampat 9 months ago.
I have checked above mentioned issue and founds few files. Here, I have added its patch.

Download all attachments as: .zip

Change History (8)

@upadalavipul
11 months ago

patch added

@upadalavipul
11 months ago

added two more files.

@viralsampat
11 months ago

I have checked above mentioned issue and founds another file. Here, I have added its patch.

@viralsampat
11 months ago

I have checked above mentioned issue and founds another files. Here, I have added its patch.

@viralsampat
11 months ago

I have added another patch

@viralsampat
9 months ago

I have checked above mentioned issue and founds few files. Here, I have added its patch.

@viralsampat
9 months ago

I have checked above mentioned issue and founds few files. Here, I have added its patch.

#1 @sabernhardt
6 months ago

  • Keywords has-patch added
  • Summary changed from Remove Unused variables in the wp-admin folder. to Remove unused variables

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. wp-admin/network/sites.php, line 18
  2. wp-admin/network/themes.php, line 18
  3. wp-admin/plugins.php, line 17
  4. 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(). 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 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

59420.5.patch and 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.

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].

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.
Note: See TracTickets for help on using tickets.