WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/28/2015 03:26:41 PM (4 years ago)
Author:
jorbin
Message:

Deprecate php4 style constructors

PHP7 is deprecating PHP4 style constructors, so we need to modify our code to have _construct methods that fire before the named PHP4 style constructors. The PHP4 style constructors will call the PHP5 style constructor in case it is being called directly (usually via parent::METHOD).

This modifies external libraries to add PHP5 style constructors, but doesn't add a notice for when they are used. In WordPress core code, PHP4 style constructors are being given a call to _deprecated_constructor. To the PHP4 style constructor I say "I know that I can't take no more | It ain't no lie | I wanna see you out that door | Baby, bye, bye, bye..."

Upstream: https://wiki.php.net/rfc/remove_php4_constructors

Props jdgrimes, netweb, jorbin
See #31982

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pomo/streams.php

    r32672 r32990  
    1515    var $_post = '';
    1616
    17     function POMO_Reader() {
     17    /**
     18     * PHP5 constructor.
     19     */
     20    function __construct() {
    1821        $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr');
    1922        $this->_pos = 0;
     23    }
     24
     25    /**
     26     * PHP4 constructor.
     27     */
     28    public function POMO_Reader() {
     29        self::__construct();
    2030    }
    2131
     
    131141     * @param string $filename
    132142     */
    133     function POMO_FileReader($filename) {
     143    function __construct( $filename ) {
    134144        parent::POMO_Reader();
    135145        $this->_f = fopen($filename, 'rb');
     146    }
     147
     148    /**
     149     * PHP4 constructor.
     150     */
     151    public function POMO_FileReader( $filename ) {
     152        self::__construct( $filename );
    136153    }
    137154
     
    197214    var $_str = '';
    198215
    199     function POMO_StringReader($str = '') {
     216    /**
     217     * PHP5 constructor.
     218     */
     219    function __construct( $str = '' ) {
    200220        parent::POMO_Reader();
    201221        $this->_str = $str;
    202222        $this->_pos = 0;
     223    }
     224
     225    /**
     226     * PHP4 constructor.
     227     */
     228    public function POMO_StringReader( $str = '' ) {
     229        self::__construct( $str );
    203230    }
    204231
     
    246273 */
    247274class POMO_CachedFileReader extends POMO_StringReader {
    248     function POMO_CachedFileReader($filename) {
     275    /**
     276     * PHP5 constructor.
     277     */
     278    function __construct( $filename ) {
    249279        parent::POMO_StringReader();
    250280        $this->_str = file_get_contents($filename);
     
    253283        $this->_pos = 0;
    254284    }
     285
     286    /**
     287     * PHP4 constructor.
     288     */
     289    public function POMO_CachedFileReader( $filename ) {
     290        self::__construct( $filename );
     291    }
    255292}
    256293endif;
     
    261298 */
    262299class POMO_CachedIntFileReader extends POMO_CachedFileReader {
    263     function POMO_CachedIntFileReader($filename) {
     300    /**
     301     * PHP5 constructor.
     302     */
     303    public function __construct( $filename ) {
    264304        parent::POMO_CachedFileReader($filename);
    265305    }
    266 }
    267 endif;
     306
     307    /**
     308     * PHP4 constructor.
     309     */
     310    function POMO_CachedIntFileReader( $filename ) {
     311        self::__construct( $filename );
     312    }
     313}
     314endif;
     315
Note: See TracChangeset for help on using the changeset viewer.