From:             aldo at armiento dot com
Operating system: Linux 2.6.18
PHP version:      5.2.5
PHP Bug Type:     Class/Object related
Bug description:  Magic methods __set, __get, __isset, __unset are triggered if 
a member exists

Description:
------------
Magic methods __set, __get, __isset, __unset are triggered also if a 
member exists if accessing member from a method used in a cURL callback 
function.

>From the documentation instead "These methods will only be triggered 
when your object or inherited object doesn't contain the member or 
method you're trying to access".

Reproduce code:
---------------
<?php

class Test
{
        public $member;
        
        public function __set($sName, $mValue)
        {
                echo "__set() called\n";
        }
        
        public function __get($sName)
        {
                echo "__get() called\n";
        }
        
        public function __isset($sName)
        {
                echo "__isset() called\n";
        }
        
        public function __unset($sName)
        {
                echo "__unset() called\n";
        }
        
        public function headerCallBack($hCurl, $sHeader)
        {
                $this->member = 'value';
                strtolower($this->member);
                isset($this->member);
                unset($this->member);
                
                return strlen($sHeader);
        }
        
        public function httpGet()
        {
                $hCurl = curl_init();
                curl_setopt($hCurl, CURLOPT_URL, 'http://www.php.net/');
                curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($hCurl, CURLOPT_HEADERFUNCTION, array($this,
'headerCallBack'));
                curl_exec($hCurl);
        }
}

$C = new Test();
$C->httpGet();

Expected result:
----------------
Nothing.

Actual result:
--------------
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called
__set() called
__get() called
__isset() called
__unset() called

-- 
Edit bug report at http://bugs.php.net/?id=44370&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44370&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44370&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44370&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44370&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44370&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44370&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44370&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44370&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44370&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44370&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44370&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44370&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44370&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44370&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44370&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44370&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44370&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44370&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44370&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44370&r=mysqlcfg

Reply via email to