Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#16920 closed defect (fixed)

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

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

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 2 years ago.
class-http.php
16920.2.patch (2.2 KB) - added by hakre 2 years ago.
class-http.php - more replacements
16920.3.patch (1.3 KB) - added by hakre 2 years ago.
deprecate wp_clone()
16920.4.patch (3.3 KB) - added by hakre 2 years ago.
Follow-Up to: #11176
16920.5.patch (2.1 KB) - added by hakre 2 years ago.
setcookie() has httponly parameter now
16920.6.patch (869 bytes) - added by hakre 2 years ago.
E_RECOVERABLE_ERROR is available since PHP 5.2.0
16920.E_RECOVERABLE_ERROR.diff (2.5 KB) - added by duck_ 2 years ago.
get_gmt_from_date-php5.diff (1.7 KB) - added by technosailor 2 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 2 years ago.
Unit test for get_gmt_from_date()

Download all attachments as: .zip

Change History (28)

hakre2 years ago

class-http.php

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

What is this? You literally copied #16918?

hakre2 years ago

class-http.php - more replacements

  • 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.

hakre2 years ago

deprecate wp_clone()

reg. wp_clone(): #16813

hakre2 years ago

Follow-Up to: #11176

hakre2 years ago

setcookie() has httponly parameter now

  • Milestone set to 3.2

hakre2 years ago

E_RECOVERABLE_ERROR is available since PHP 5.2.0

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

-- done per that commit.

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

Related: #16970

comment:7   ryan2 years ago

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

comment:8   ryan2 years ago

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

comment:9   ryan2 years ago

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

Three other instances of E_RECOVERABLE_ERROR checks. Patch attached.

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

  • Resolution set to fixed
  • Status changed from reopened to closed
  • 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?)

_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: ↓ 16   dd322 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 2 years ago by dd32 (previous) (diff)

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

Unit test for get_gmt_from_date()

comment:16 in reply to: ↑ 15   hakre2 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.

  • Keywords reporter-feedback removed
  • 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

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

Note: See TracTickets for help on using tickets.