WordPress.org

Make WordPress Core

Changeset 21512


Ignore:
Timestamp:
08/14/12 20:26:04 (20 months ago)
Author:
nacin
Message:

Add magic set, isset, and unset to wpdb. props pento.

These magic methods allow us to mark properties as protected or private, without breaking compatibility, as they were once accessible. The joys of PHP4.

fixes #18510.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-db.php

    r21511 r21512  
    566566     * @since 3.5.0 
    567567     * 
    568      * @param string $var The private member to get, and optionally process 
     568     * @param string $name The private member to get, and optionally process 
    569569     * @return mixed The private member 
    570570     */ 
    571     function __get( $var ) { 
    572         if ( 'col_info' == $var ) 
     571    function __get( $name ) { 
     572        if ( 'col_info' == $name ) 
    573573            $this->load_col_info(); 
    574574 
    575         return $this->$var; 
     575        return $this->$name; 
     576    } 
     577 
     578    /** 
     579     * Magic function, for backwards compatibility 
     580     * 
     581     * @since 3.5.0 
     582     * 
     583     * @param string $name  The private member to set 
     584     * @param mixed  $value The value to set 
     585     */ 
     586    function __set( $name, $value ) { 
     587        $this->$name = $value; 
     588    } 
     589 
     590    /** 
     591     * Magic function, for backwards compatibility 
     592     * 
     593     * @since 3.5.0 
     594     * 
     595     * @param string $name  The private member to check 
     596     * 
     597     * @return bool If the member is set or not 
     598     */ 
     599    function __isset( $name ) { 
     600        return isset( $this->$name ); 
     601    } 
     602 
     603    /** 
     604     * Magic function, for backwards compatibility 
     605     * 
     606     * @since 3.5.0 
     607     * 
     608     * @param string $name  The private member to unset 
     609     */ 
     610    function __unset( $name ) { 
     611        unset( $this->$name ); 
    576612    } 
    577613 
Note: See TracChangeset for help on using the changeset viewer.