WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16920 closed defect (bug) (fixed)

PHP5-Port: Take out unnecessary compat functions from diverse files

Reported by: hakre Owned by: ryan
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: General Keywords: has-patch
Focuses: Cc:

Description

Now that we require PHP 5.2.4, let's take out anything in php other than compat.php that is no longer necessary. If you'd like to tackle this, please say so. Please also verify for certain that the functions you're removing are present in ALL PHP 5.2.4 installs.

Related: #16918, #16917

Attachments (9)

16920.patch (1.2 KB) - added by hakre 3 years ago.
class-http.php
16920.2.patch (2.2 KB) - added by hakre 3 years ago.
class-http.php - more replacements
16920.3.patch (1.3 KB) - added by hakre 3 years ago.
deprecate wp_clone()
16920.4.patch (3.3 KB) - added by hakre 3 years ago.
Follow-Up to: #11176
16920.5.patch (2.1 KB) - added by hakre 3 years ago.
setcookie() has httponly parameter now
16920.6.patch (869 bytes) - added by hakre 3 years ago.
E_RECOVERABLE_ERROR is available since PHP 5.2.0
16920.E_RECOVERABLE_ERROR.diff (2.5 KB) - added by duck_ 3 years ago.
get_gmt_from_date-php5.diff (1.7 KB) - added by technosailor 3 years ago.
get rid of php4 compat for get_gmt_from_date()/ with unit test
get_gmt_from_date-php5-unittest.php (707 bytes) - added by technosailor 3 years ago.
Unit test for get_gmt_from_date()

Download all attachments as: .zip

Change History (28)

hakre3 years ago

class-http.php

comment:1 nacin3 years ago

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

What is this? You literally copied #16918?

hakre3 years ago

class-http.php - more replacements

comment:2 hakre3 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to nacin:

What is this? You literally copied #16918?

Mind the slight but important difference svp.

hakre3 years ago

deprecate wp_clone()

comment:3 hakre3 years ago

reg. wp_clone(): #16813

hakre3 years ago

Follow-Up to: #11176

hakre3 years ago

setcookie() has httponly parameter now

comment:4 scribu3 years ago

  • Milestone set to 3.2

hakre3 years ago

E_RECOVERABLE_ERROR is available since PHP 5.2.0

comment:5 hakre3 years ago

[17535] - some php version compare in class-http, see 16920.patch, 16920.2.patch

-- done per that commit.

Last edited 3 years ago by hakre (previous) (diff)

comment:6 hakre3 years ago

Related: #16970

comment:7 ryan3 years ago

(In [17612]) Remove setcookie() back compat. Props hakre. see#16920

comment:8 ryan3 years ago

(In [17629]) E_RECOVERABLE_ERROR is always available in PHP 5.2+. Remove back compat code. Props hakre. see #16920

comment:9 ryan3 years ago

(In [17630]) Use stripos() instead of strpos( strtolower() ). Props hakre. see #16920

comment:10 duck_3 years ago

Three other instances of E_RECOVERABLE_ERROR checks. Patch attached.

comment:11 nacin3 years ago

(In [17632]) Remove more E_RECOVERABLE_ERROR checks. props duck_, see #16920.

comment:12 ryan3 years ago

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

comment:13 ocean903 years ago

  • Cc dd32 added
  • Keywords needs-patch added; has-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

I have found two PHP4 compat codes:

  • get_gmt_from_date() - wp-includes/formatting.php
  • _unzip_file_ziparchive() - wp-admin/includes/file.php (dd32?)

comment:14 dd323 years ago

_unzip_file_ziparchive() - wp-admin/includes/file.php (dd32?)

Not a compat function

_unzip_file_ziparchive() & _unzip_file_pclzip() are 2 different methods to extract zip files, The first is used when the PHP Zip extension is loaded (Which is not always the case) the 2nd is used in all other cases as it uses pure-PHP code to do the extraction. They're both "private workers" for unzip_file();

comment:15 follow-up: dd323 years ago

Ignore that.. Turns out there was some PHP4 comapt in there: (thanks ocean90)

- $zopen = $z->open($file, /* ZIPARCHIVE::CHECKCONS */ 4);
+ $zopen = $z->open($file, ZIPARCHIVE::CHECKCONS);
Last edited 3 years ago by dd32 (previous) (diff)

technosailor3 years ago

get rid of php4 compat for get_gmt_from_date()/ with unit test

technosailor3 years ago

Unit test for get_gmt_from_date()

comment:16 in reply to: ↑ 15 hakre3 years ago

  • Keywords reporter-feedback has-patch added; needs-patch removed

Replying to dd32:

Ignore that.. Turns out there was some PHP4 comapt in there: (thanks ocean90)

- $zopen = $z->open($file, /* ZIPARCHIVE::CHECKCONS */ 4);
+ $zopen = $z->open($file, ZIPARCHIVE::CHECKCONS);

php ZIPARCHIVE constants are not automatically available, so not using the CONST does make still sense with PHP 5.2+.


I think this ticket should be still reopend because of technosailor's findings. Patch looks good to me.

comment:17 hakre3 years ago

  • Keywords reporter-feedback removed

comment:18 ryan3 years ago

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

In [17920]:

Remove PHP5 back compat code from get_gmt_from_date. Props technosailor. fixes #16920

comment:19 ryan3 years ago

Of course that should say PHP4 instead of 5 in the commit message.

Note: See TracTickets for help on using tickets.