Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#48074 closed task (blessed) (fixed)

Remove work-arounds for unsupported PHP versions

Reported by: jrf's profile jrf Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.3
Component: General Keywords: has-patch
Focuses: performance, coding-standards Cc:

Description

As support for PHP < 5.6.20 has been dropped, certain work-arounds which were in place to support older PHP versions can be removed.

The patches I'm attaching to this ticket are all fairly simple. I will add a more detailed description with each patch.

Attachments (10)

48074-src-Remove-work-arounds-for-PHP-5.6.patch (4.4 KB) - added by jrf 5 years ago.
This patch removes all code using a version_compare() with a PHP version older than PHP 5.6.
48074-tests-Remove-work-arounds-for-PHP-5.6.patch (8.5 KB) - added by jrf 5 years ago.
Same as the previous patch, but now for the unit tests.
48074-src-Remove-work-arounds-for-HHVM.patch (935 bytes) - added by jrf 5 years ago.
Support for HHVM was dropped in 2017 via ticket #40548. This removes the one code work-around which I found which still checked for HHVM.
48074-src-Remove-work-arounds-for-IMAGETYPE_ICO.patch (1.1 KB) - added by jrf 5 years ago.
The IMAGETYPE_ICO constant was itroduced in PHP 5.3, so no longer needs a work-around. See: https://www.php.net/manual/en/image.constants.php
48074.4.patch (1.2 KB) - added by dkarfa 5 years ago.
48074-src-Remove-work-arounds-for-CURLOPT_PROTOCOLS.patch (1.0 KB) - added by jrf 5 years ago.
The CURLOPT_PROTOCOLS constant was introduced in PHP 5.2.10, so no longer needs a work-around. See: https://www.php.net/manual/en/function.curl-setopt.php
48074.6.patch (802 bytes) - added by dkarfa 5 years ago.
48074-src-Remove-work-arounds-for-spl_object_hash.patch (3.4 KB) - added by jrf 5 years ago.
[src] Remove work-arounds for spl_object_hash() - The sp_object_hash() function was introduced in PHP 5.2.0 and as of PHP 5.3, the PHP SPL extension can no longer be disabled, so these work-arounds are no longer needed. See: https://www.php.net/manual/en/function.spl-object-hash.php
48074-tests-Remove-work-arounds-for-get_called_class.patch (1.9 KB) - added by jrf 5 years ago.
The get_called_class() function was introduced in PHP 5.3, so no longer needs a work-around. See: https://www.php.net/manual/en/function.get-called-class.php All instances were this method was called within the WP core codebase have been adjusted. Leaving the method in place for now as plugins/themes which use the WP unit test framework could still call this method.
48074-tests-Remove-work-arounds-for-str_getcsv.patch (1.1 KB) - added by jrf 5 years ago.
The str_getcsv() function was introduced in PHP 5.3.0, so no longer needs a polyfill. See: https://www.php.net/manual/en/function.str-getcsv.php

Download all attachments as: .zip

Change History (27)

@jrf
5 years ago

This patch removes all code using a version_compare() with a PHP version older than PHP 5.6.

@jrf
5 years ago

Same as the previous patch, but now for the unit tests.

@jrf
5 years ago

Support for HHVM was dropped in 2017 via ticket #40548. This removes the one code work-around which I found which still checked for HHVM.

@jrf
5 years ago

The IMAGETYPE_ICO constant was itroduced in PHP 5.3, so no longer needs a work-around. See: https://www.php.net/manual/en/image.constants.php

@dkarfa
5 years ago

@jrf
5 years ago

The CURLOPT_PROTOCOLS constant was introduced in PHP 5.2.10, so no longer needs a work-around. See: https://www.php.net/manual/en/function.curl-setopt.php

@dkarfa
5 years ago

#1 @jrf
5 years ago

@dkarfa Thanks for your enthousiasm.

Regarding patch 48074.4.patch: this patch should not be committed as part of this ticket.

I left everything JSON out of this ticket on purpose as there is a separate ticket open for that and patches would too easily conflict otherwise.

See #47699

Patch 48074.6.patch LGTM.

@jrf
5 years ago

[src] Remove work-arounds for spl_object_hash() - The sp_object_hash() function was introduced in PHP 5.2.0 and as of PHP 5.3, the PHP SPL extension can no longer be disabled, so these work-arounds are no longer needed. See: https://www.php.net/manual/en/function.spl-object-hash.php

@jrf
5 years ago

The get_called_class() function was introduced in PHP 5.3, so no longer needs a work-around. See: https://www.php.net/manual/en/function.get-called-class.php All instances were this method was called within the WP core codebase have been adjusted. Leaving the method in place for now as plugins/themes which use the WP unit test framework could still call this method.

@jrf
5 years ago

The str_getcsv() function was introduced in PHP 5.3.0, so no longer needs a polyfill. See: https://www.php.net/manual/en/function.str-getcsv.php

#2 @jrf
5 years ago

FYI: passing build containing all the patches I uploaded for this ticket + #48705: https://travis-ci.org/jrfnl/wordpress-develop/builds/587153857

Version 0, edited 5 years ago by jrf (next)

#3 @netweb
5 years ago

  • Milestone changed from Awaiting Review to Future Release

#4 @SergeyBiryukov
5 years ago

  • Milestone changed from Future Release to 5.3

#5 @SergeyBiryukov
5 years ago

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

In 46214:

Code Modernization: Remove all code using a version_compare() with a PHP version older than PHP 5.6.

Props jrf.
Fixes #48074.

#6 @SergeyBiryukov
5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Didn't mean to close the ticket :)

#7 @SergeyBiryukov
5 years ago

In 46215:

Docs: Update a comment about pcre.backtrack_limit upper limit in benchmark_pcre_backtracking().

See #48074.

#8 @SergeyBiryukov
5 years ago

In 46216:

Code Modernization: Remove a workaround for HHVM in WP_Image_Editor_Imagick::test().

Support for HHVM was dropped in 2017 via #40548.

Props jrf.
See #48074.

#9 @SergeyBiryukov
5 years ago

In 46217:

Code Modernization: Remove a workaround for IMAGETYPE_ICO in file_is_displayable_image().

The IMAGETYPE_ICO constant was introduced in PHP 5.3, so no longer needs a workaround.

Props jrf.
See #48074.

#10 @SergeyBiryukov
5 years ago

In 46218:

Code Modernization: Remove a workaround for CURLOPT_PROTOCOLS in WP_Http_Curl::request().

The CURLOPT_PROTOCOLS constant was introduced in PHP 5.2.10, so no longer needs a workaround.

Props jrf.
See #48074.

#11 @SergeyBiryukov
5 years ago

In 46219:

Tests: Remove a test for rest_preload_api_request() only relevant for PHP 5.2.

Props dkarfa.
See #48074.

#12 @SergeyBiryukov
5 years ago

In 46220:

Code Modernization: Remove workarounds for spl_object_hash().

The spl_object_hash() function was introduced in PHP 5.2.0. As of PHP 5.3, the PHP SPL extension can no longer be disabled, so these workarounds are no longer needed.

Props jrf.
See #48074.

#13 @SergeyBiryukov
5 years ago

In 46221:

Tests: Remove a workaround for get_called_class().

The get_called_class() function was introduced in PHP 5.3, so no longer needs a workaround.

Mark WP_UnitTestCase_Base::get_called_class() as deprecated. Leave it in place for now as plugins or themes using the WP unit test framework might still call this method.

Props jrf.
See #48074.

#14 @SergeyBiryukov
5 years ago

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

In 46222:

Tests: Remove a workaround for str_getcsv().

The str_getcsv() function was introduced in PHP 5.3.0, so no longer needs a polyfill.

Props jrf.
Fixes #48074.

#15 @jrf
5 years ago

Thank you @SergeyBiryukov for getting these all committed! 💕

#16 @SergeyBiryukov
5 years ago

In 46805:

Plugins: In _wp_filter_build_unique_id(), remove $wp_filter global and $filter_id_count static variable, unused since [46220].

See #47407, #48074.

#17 @SergeyBiryukov
5 years ago

In 46808:

Widgets: Remove WP_Widget_Factory::$hashed_class_counts property, unused since [46220].

The spl_object_hash() function was introduced in PHP 5.2.0. As of PHP 5.3, the PHP SPL extension can no longer be disabled, so the WP_Widget_Factory::hash_object() workaround was removed in [46220].

See #48074.

Note: See TracTickets for help on using tickets.