From c653147d4782db02a96508c7b6a0b1a50f899111 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 14 Aug 2012 20:26:04 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@21512 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/wp-db.php | 44 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index a4870ec94f..7b6c3049a7 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -565,14 +565,50 @@ class wpdb { * * @since 3.5.0 * - * @param string $var The private member to get, and optionally process + * @param string $name The private member to get, and optionally process * @return mixed The private member */ - function __get( $var ) { - if ( 'col_info' == $var ) + function __get( $name ) { + if ( 'col_info' == $name ) $this->load_col_info(); - return $this->$var; + return $this->$name; + } + + /** + * Magic function, for backwards compatibility + * + * @since 3.5.0 + * + * @param string $name The private member to set + * @param mixed $value The value to set + */ + function __set( $name, $value ) { + $this->$name = $value; + } + + /** + * Magic function, for backwards compatibility + * + * @since 3.5.0 + * + * @param string $name The private member to check + * + * @return bool If the member is set or not + */ + function __isset( $name ) { + return isset( $this->$name ); + } + + /** + * Magic function, for backwards compatibility + * + * @since 3.5.0 + * + * @param string $name The private member to unset + */ + function __unset( $name ) { + unset( $this->$name ); } /**