From:             richc at drivecurrent dot com
Operating system: Linux Redhat
PHP version:      5.2.6
PHP Bug Type:     Variables related
Bug description:  Variable copies corrupted by memcache problem

Description:
------------
I believe a problem with memcache reveals a problem with PHP. (PECL
Memcache bug: http://pecl.php.net/bugs/bug.php?id=14239)

A call to memcache changes the parameter variable to 'string' type. The
PHP problem is that this conversion is passed to ancestor and decendent
copies of the variable, even through function calls, even though passed by
value, not reference.

This appears to be similar to PHP Bug #42813, closed as Bogus. This is a
newly compiled PHP installation using latest PHP, PECL, memcached.

Reproduce code:
---------------
$value1 = 1.2;
$value2 = $value1; // this value is being passed -- all get modified
$value3 = $value2;

echo '<br>1 ' . gettype($value1) . ' / ' . gettype($value2) . ' / ' .
gettype($value3);
set('asdf', $value2);
echo '<br>4 ' . gettype($value1) . ' / ' . gettype($value2) . ' / ' .
gettype($value3);

function set( $key, $valueA ) {
  $valueB = $valueA; // this value is being passed -- all get modified
  $valueC = $valueB;
  
  echo '<br>2 ' . gettype($valueA) . ' / ' . gettype($valueB) . ' / ' .
gettype($valueC);
  
  $m = new Memcache();
  $m->addServer('localhost');
  $m->set($key, $valueB);
  
  echo '<br>3 ' . gettype($valueA) . ' / ' . gettype($valueB) . ' / ' .
gettype($valueC);
}

Expected result:
----------------
Even when memcache bug corrupts $valueB, others should not be affected:

1 double / double / double
2 double / double / double
3 double / string / double
4 double / string / double

Actual result:
--------------
1 double / double / double
2 double / double / double
3 string / string / string
4 string / string / string

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

Reply via email to