Make WordPress Core


Ignore:
Timestamp:
06/28/2015 03:26:41 PM (10 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/class-IXR.php

    r32964 r32990  
    5050    var $type;
    5151
    52     function IXR_Value($data, $type = false)
     52    /**
     53     * PHP5 constructor.
     54     */
     55    function __construct( $data, $type = false )
    5356    {
    5457        $this->data = $data;
     
    6972        }
    7073    }
     74
     75    /**
     76     * PHP4 constructor.
     77     */
     78    public function IXR_Value( $data, $type = false ) {
     79        self::__construct( $data, $type );
     80    }
    7181
    7282    function calculateType()
     
    195205    var $_parser;
    196206
    197     function IXR_Message($message)
     207    /**
     208     * PHP5 constructor.
     209     */
     210    function __construct( $message )
    198211    {
    199212        $this->message =& $message;
    200213    }
     214
     215    /**
     216     * PHP4 constructor.
     217     */
     218    public function IXR_Message( $message ) {
     219        self::__construct( $message );
     220    }
    201221
    202222    function parse()
     
    387407    var $capabilities;
    388408
    389     function IXR_Server($callbacks = false, $data = false, $wait = false)
     409    /**
     410     * PHP5 constructor.
     411     */
     412    function __construct( $callbacks = false, $data = false, $wait = false )
    390413    {
    391414        $this->setCapabilities();
     
    398421        }
    399422    }
     423
     424    /**
     425     * PHP4 constructor.
     426     */
     427    public function IXR_Server( $callbacks = false, $data = false, $wait = false ) {
     428        self::__construct( $callbacks, $data, $wait );
     429    }
    400430
    401431    function serve($data = false)
     
    601631    var $xml;
    602632
    603     function IXR_Request($method, $args)
     633    /**
     634     * PHP5 constructor.
     635     */
     636    function __construct($method, $args)
    604637    {
    605638        $this->method = $method;
     
    620653        $this->xml .= '</params></methodCall>';
    621654    }
     655
     656    /**
     657     * PHP4 constructor.
     658     */
     659    public function IXR_Request( $method, $args ) {
     660        self::__construct( $method, $args );
     661    }
    622662
    623663    function getLength()
     
    654694    var $error = false;
    655695
    656     function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
     696    /**
     697     * PHP5 constructor.
     698     */
     699    function __construct( $server, $path = false, $port = 80, $timeout = 15 )
    657700    {
    658701        if (!$path) {
     
    679722        $this->timeout = $timeout;
    680723    }
     724
     725    /**
     726     * PHP4 constructor.
     727     */
     728    public function IXR_Client( $server, $path = false, $port = 80, $timeout = 15 ) {
     729        self::__construct( $server, $path, $port, $timeout );
     730    }
    681731
    682732    function query()
     
    799849    var $message;
    800850
    801     function IXR_Error($code, $message)
     851    /**
     852     * PHP5 constructor.
     853     */
     854    function __construct( $code, $message )
    802855    {
    803856        $this->code = $code;
    804857        $this->message = htmlspecialchars($message);
    805858    }
     859
     860    /**
     861     * PHP4 constructor.
     862     */
     863    public function IXR_Error( $code, $message ) {
     864        self::__construct( $code, $message );
     865    }
    806866
    807867    function getXml()
     
    845905    var $timezone;
    846906
    847     function IXR_Date($time)
     907    /**
     908     * PHP5 constructor.
     909     */
     910    function __construct( $time )
    848911    {
    849912        // $time can be a PHP timestamp or an ISO one
     
    854917        }
    855918    }
     919
     920    /**
     921     * PHP4 constructor.
     922     */
     923    public function IXR_Date( $time ) {
     924        self::__construct( $time );
     925    }
    856926
    857927    function parseTimestamp($timestamp)
     
    903973    var $data;
    904974
    905     function IXR_Base64($data)
     975    /**
     976     * PHP5 constructor.
     977     */
     978    function __construct( $data )
    906979    {
    907980        $this->data = $data;
    908981    }
     982
     983    /**
     984     * PHP4 constructor.
     985     */
     986    public function IXR_Base64( $data ) {
     987        self::__construct( $data );
     988    }
    909989
    910990    function getXml()
     
    9251005    var $help;
    9261006
    927     function IXR_IntrospectionServer()
     1007    /**
     1008     * PHP5 constructor.
     1009     */
     1010    function __construct()
    9281011    {
    9291012        $this->setCallbacks();
     
    9581041        );
    9591042    }
     1043
     1044    /**
     1045     * PHP4 constructor.
     1046     */
     1047    public function IXR_IntrospectionServer() {
     1048        self::__construct();
     1049    }
    9601050
    9611051    function addCallback($method, $callback, $args, $help)
     
    10871177    var $calls = array();
    10881178
    1089     function IXR_ClientMulticall($server, $path = false, $port = 80)
     1179    /**
     1180     * PHP5 constructor.
     1181     */
     1182    function __construct( $server, $path = false, $port = 80 )
    10901183    {
    10911184        parent::IXR_Client($server, $path, $port);
    10921185        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
    10931186    }
     1187
     1188    /**
     1189     * PHP4 constructor.
     1190     */
     1191    public function IXR_ClientMulticall( $server, $path = false, $port = 80 ) {
     1192        self::__construct( $server, $path, $port );
     1193    }
    10941194
    10951195    function addCall()
Note: See TracChangeset for help on using the changeset viewer.