WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 4 months ago

#48074 closed task (blessed) (fixed)

Remove work-arounds for unsupported PHP versions

Reported by: jrf Owned by: 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 7 months 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 7 months 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 7 months 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 7 months 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 7 months ago.
48074-src-Remove-work-arounds-for-CURLOPT_PROTOCOLS.patch (1.0 KB) - added by jrf 7 months 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 7 months ago.
48074-src-Remove-work-arounds-for-spl_object_hash.patch (3.4 KB) - added by jrf 7 months 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 7 months 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 7 months 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
7 months ago

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

@jrf
7 months ago

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

@jrf
7 months 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
7 months 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
7 months ago

@jrf
7 months 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
7 months ago

#1 @jrf
7 months 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
7 months 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
7 months 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
7 months 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
7 months ago

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

Last edited 7 months ago by SergeyBiryukov (previous) (diff)

#3 @netweb
7 months ago

  • Milestone changed from Awaiting Review to Future Release

#4 @SergeyBiryukov
7 months ago

  • Milestone changed from Future Release to 5.3

#5 @SergeyBiryukov
7 months 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
7 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Didn't mean to close the ticket :)

#7 @SergeyBiryukov
7 months ago

In 46215:

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

See #48074.

#8 @SergeyBiryukov
7 months 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
7 months 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
7 months 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
7 months ago

In 46219:

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

Props dkarfa.
See #48074.

#12 @SergeyBiryukov
7 months 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
7 months 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
7 months 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
7 months ago

Thank you @SergeyBiryukov for getting these all committed! 💕

#16 @SergeyBiryukov
4 months 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
4 months 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.