WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 6 months ago

Last modified 3 months ago

#49938 closed defect (bug) (fixed)

Deprecate wp_unregister_GLOBALS()

Reported by: desrosj Owned by: desrosj
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Bootstrap/Load Keywords: has-patch early has-dev-note
Focuses: Cc:

Description

register_globals was deprecated in PHP 5.3.0 and removed in 5.4.0. Since Core now supports PHP >= 5.6.20, this can probably be deprecated.

The first line of wp_unregister_GLOBALS() checks if ( ! ini_get( 'register_globals' ) ) and returns early. ini_get() returns false if the option is not set, so this function is probably dead code.

Follow up ticket to #46152, #49922.

Attachments (1)

49938-1.patch (2.2 KB) - added by ayeshrajans 6 months ago.
Attaching a atch that removes the call to this function, moves it the deprecated functions file, and emits a deprecation notice. It also removes the dead code that would never run in PHP versions beyond PHP 5.4.

Download all attachments as: .zip

Change History (12)

#1 @desrosj
6 months ago

What's not clear to me is whether an .ini configuration will apply if PHP does not support the option. If it does, then deprecating will be more difficult. However, this is something that has not been supported for some time, and modifying Super globals should be discouraged.

#2 @ayeshrajans
6 months ago

If a user-land ini_set() call tries to set a PHP configuration value that's not recognized (which the case for register_globals), its value will not "stick".

For example:

var_dump(ini_set('register_globals', 'on'));
var_dump(ini_get('register_globals'));

Both of these will return false because register_globals is not registered as a value.

@ayeshrajans
6 months ago

Attaching a atch that removes the call to this function, moves it the deprecated functions file, and emits a deprecation notice. It also removes the dead code that would never run in PHP versions beyond PHP 5.4.

#3 @SergeyBiryukov
6 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.5

#5 @desrosj
6 months ago

  • Keywords early added

Thanks for confirming @ayeshrajans! You beat me to testing. I created a PR to ensure the build passes (which it does). I am also marking this early. While it does not appear there would be any consequences of deprecating this function, I'd rather land it early because it affects the loading process just in case.

#6 @SergeyBiryukov
6 months ago

  • Keywords commit added; 2nd-opinion removed

#7 @desrosj
6 months ago

  • Owner set to desrosj
  • Status changed from new to assigned

#8 @desrosj
6 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 47612:

Bootstrap/Load: Deprecate wp_unregister_GLOBALS().

The register_globals directive in PHP was deprecated in version 5.3 and removed entirely in 5.4.

Now that WordPress only supports PHP 5.6.20 and newer, the wp_unregister_GLOBALS() function can be deprecated.

Props ayeshrajans, desrosj, SergeyBiryukov.
Fixes #49938.

#10 @desrosj
4 months ago

  • Keywords needs-dev-note added; commit removed

Going to note this in a PHP improvements dev note.

#11 @desrosj
3 months ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.