php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58107 Changed type of returned array keys
Submitted: 2008-03-18 11:05 UTC Modified: 2008-04-16 14:46 UTC
From: r at roze dot lv Assigned:
Status: Not a bug Package: memcache (PECL)
PHP Version: Irrelevant OS: OpenSuse 10.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: r at roze dot lv
New email:
PHP Version: OS:

 

 [2008-03-18 11:05 UTC] r at roze dot lv
Description:
------------
Keys of returned array (in multiget) are type-casted to string. This behaviour has changed since 2.2.2 (version 2.2.1 still works fine).

I undestand this is a very special case (when using integers as keys and then relaying on the data type), but to clarify if this is supposed to be like that reporting this issue.

Reproduce code:
---------------
<?
$mc = new Memcache;
$mc->addServer('127.0.0.1',11212,0,1,2,1,1);

$ids = array(322,22);
$data = $mc->get($ids);
var_dump(array_keys($data));
?>


Expected result:
----------------
array(2) {
  [0]=>
  int(322)
  [1]=>
  int(22)
}

Actual result:
--------------
array(2) {
  [0]=>
  string(3) "322"
  [1]=>
  string(2) "22"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-16 14:46 UTC] mikael at synd dot info
Actually, in my setup this works as expected both with PHP4 and PHP5 and with pecl/memcache 2.2.3 and 3.0.1, I don't even think it's possible to add numeric string keys to a PHP array and have them represented as anything other than ints, try for example

 var_dump(array_keys(array('123'=>'test')));

If the problem persists in your setup please re-open the bug and post PHP and pecl/memcache versions and how to reproduce the problem. My test script:

$memcache->set(123, 'test1');
$memcache->set(456, 'test2');

$result = $memcache->get(array(123, 456));
var_dump(array_keys($result));

?>
--EXPECT--
array(2) {
  [0]=>
  int(123)
  [1]=>
  int(456)
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 07:01:32 2024 UTC