Make WordPress Core

#60006 closed defect (bug) (invalid)

Remove the Unused global variables in the wp-admin

Reported by: viralsampat's profile viralsampat Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: close
Focuses: Cc:

Description

Hello Team,

I have reviewed the wp-admin folder code and found that a few files function with unused global $wpdb variable. So, we need to remove the $wpdb global variable here.

File Path:

/wp-admin/includes/class-core-upgrader.php src/wp-admin/includes/class-core-upgrader.php

/wp-admin/includes/post.php src/wp-admin/includes/post.php

Attachments (2)

59977.patch (1001 bytes) - added by viralsampat 20 months ago.
60006.patch (1.1 KB) - added by viralsampat 20 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 (5)

@viralsampat
20 months ago

#1 @SergeyBiryukov
20 months ago

  • Component changed from Site Health to Administration
  • Keywords close added; needs-patch dev-feedback removed

Hi there, thanks for the patch!

The suggested changes don't seem correct to me:

  • The $_wp_filesystem_direct_method global is used on line 235 of wp-admin/includes/class-core-upgrader.php.
  • The $current_user global is used on line 948 of wp-admin/includes/post.php.

So the @global tags should not be removed.

#2 @hellofromTonya
20 months ago

  • Version 6.4 deleted

Removing the Version as these globals were not introduced in 6.4.

#3 @hellofromTonya
20 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hello @viralsampat,

Welcome to WordPress Core's Trac :)

Thank you for the patch. As @SergeyBiryukov noted, these globals are used in within their function scope and thus need to remain.

I'll close this ticket. However, if there are others to remove, please reopen.

@viralsampat
20 months ago

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

Note: See TracTickets for help on using tickets.