ID:               45360
 User updated by:  richc at drivecurrent dot com
 Reported By:      richc at drivecurrent dot com
 Status:           Open
 Bug Type:         Variables related
 Operating System: Linux Redhat
 PHP Version:      5.2.6
 New Comment:

The last "Expected Result" should read
  4 double / double / double


Previous Comments:
------------------------------------------------------------------------

[2008-06-25 20:24:42] richc at drivecurrent dot com

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 this bug report at http://bugs.php.net/?id=45360&edit=1

Reply via email to