Skip to:
Content

bbPress.org


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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.