Skip to:
Content

bbPress.org

Changeset 6160


Ignore:
Timestamp:
12/12/2016 01:59:44 PM (7 years ago)
Author:
xknown
Message:

Branch 0.9: Fix PHP 7 compat issues w.r.t. the use of func_get_arg() and PHP 5.x constructors.

  • func_get_arg() returns the current (modified) value of the given argument. Let's make sure the code behaves the same.
  • Add PHP 5.x style constructors.
  • Use preg_match instead of eregi

See #3033

Location:
branches/0.9
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9/bb-admin/admin-functions.php

    r2348 r6160  
    248248    var $search_errors;
    249249
    250     function BB_User_Search ($search_term = false, $page = 1 ) { // constructor
     250    function __construct ($search_term = false, $page = 1 ) { // constructor
    251251        $this->search_term = $search_term ? stripslashes($search_term) : false;
    252252        $this->raw_page = ( '' == $page ) ? false : (int) $page;
     
    258258        $this->prepare_vars_for_template_usage();
    259259        $this->do_paging();
     260    }
     261
     262    function BB_User_Search ($search_term = false, $page = 1 ) {
     263        $this->__construct( $search_term, $page );
    260264    }
    261265
     
    403407    var $title = '';
    404408
    405     function BB_Users_By_Role($role = '', $page = '') { // constructor
     409    function __construct($role = '', $page = '') { // constructor
    406410        $this->role = $role ? $role : 'member';
    407411        $this->raw_page = ( '' == $page ) ? false : (int) $page;
     
    411415        $this->query();
    412416        $this->do_paging();
     417    }
     418
     419    function BB_Users_By_Role($role = '', $page = '') {
     420        $this->__construct($role, $page);
    413421    }
    414422
     
    435443        return false;
    436444
     445    $_args = func_get_args();
    437446    $defaults = array( 'forum_name' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => false );
    438447    $args = wp_parse_args( $args, $defaults );
    439448    if ( 1 < func_num_args() ) : // For back compat
    440         $args['forum_name']  = func_get_arg(0);
    441         $args['forum_desc']  = func_get_arg(1);
    442         $args['forum_order'] = 2 < func_num_args() ? func_get_arg(2) : 0;
     449        $args['forum_name']  = $_args[0];
     450        $args['forum_desc']  = $_args[1];
     451        $args['forum_order'] = 2 < func_num_args() ? $_args[2] : 0;
    443452    endif;
    444453
     
    480489        return false;
    481490
     491    $_args = func_get_args();
    482492    $defaults = array( 'forum_id' => 0, 'forum_name' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => 0 );
    483493    $args = wp_parse_args( $args, $defaults );
    484494    if ( 1 < func_num_args() ) : // For back compat
    485         $args['forum_id']    = func_get_arg(0);
    486         $args['forum_name']  = func_get_arg(1);
    487         $args['forum_desc']  = 2 < func_num_args() ? func_get_arg(2) : '';
    488         $args['forum_order'] = 3 < func_num_args() && is_numeric(func_get_arg(3)) ? func_get_arg(3) : 0;
     495        $args['forum_id']    = $_args[0];
     496        $args['forum_name']  = $_args[1];
     497        $args['forum_desc']  = 2 < func_num_args() ? $_args[2] : '';
     498        $args['forum_order'] = 3 < func_num_args() && is_numeric($_args[3]) ? $_args[3] : 0;
    489499    endif;
    490500
  • branches/0.9/bb-includes/capabilities.php

    r1173 r6160  
    88    var $role_key;
    99
    10     function BB_Roles() {
     10    function __construct() {
    1111        global $bbdb;
    1212        $this->role_key = $bbdb->prefix . 'user_roles';
     
    2121            $this->role_names[$role] = $this->roles[$role]['name'];
    2222        }
     23    }
     24
     25    function BB_Roles() {
     26        $this->__construct();
    2327    }
    2428
     
    214218    var $capabilities;
    215219
    216     function BB_Role($role, $capabilities) {
     220    function __construct($role, $capabilities) {
    217221        $this->name = $role;
    218222        $this->capabilities = $capabilities;
     223    }
     224
     225    function BB_Role($role, $capabilities) {
     226        $this->__construct($role, $capabilities);
    219227    }
    220228
     
    251259    var $allcaps = array();
    252260
    253     function BB_User($id) {
     261    function __construct($id) {
    254262        global $bb_roles, $bbdb;
    255263
     
    268276        }
    269277        $this->get_role_caps();
     278    }
     279
     280    function BB_User($id) {
     281        $this->__construct($id);
    270282    }
    271283
  • branches/0.9/bb-includes/functions.php

    r3517 r6160  
    6767
    6868function get_forums( $args = null ) {
     69    $_args = func_get_args();
    6970    if ( is_numeric($args) ) {
    7071        $args = array( 'child_of' => $args, 'hierarchical' => 1, 'depth' => 0 );
     
    7273        $args = array( 'callback' => $args );
    7374        if ( 1 < func_num_args() )
    74             $args['callback_args'] = func_get_arg(1);
     75            $args['callback_args'] = $_args[1];
    7576    }
    7677
  • branches/0.9/bb-includes/gettext.php

    r1363 r6160  
    102102     * @param boolean enable_cache Enable or disable caching of strings (default on)
    103103     */
    104     function gettext_reader($Reader, $enable_cache = true) {
     104    function __construct($Reader, $enable_cache = true) {
    105105        // If there isn't a StreamReader, turn on short circuit mode.
    106106        if (! $Reader || isset($Reader->error) ) {
     
    136136        $this->originals = $this->readint();
    137137        $this->translations = $this->readint();
     138    }
     139
     140    function gettext_reader($Reader, $enable_cache = true) {
     141        $this->__construct($Reader, $enable_cache);
    138142    }
    139143
     
    292296            }
    293297            $header .= "\n"; //make sure our regex matches
    294             if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
     298            if (preg_match("/plural-forms: ([^\n]*)\n/i", $header, $regs))
    295299                $expr = $regs[1];
    296300            else
Note: See TracChangeset for help on using the changeset viewer.