| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2009-04-21 10:38 UTC] black at scene-si dot org
 Description:
------------
Fetching multiple keys from array works as expected in var_dump, but isset() returns false on existing key. Foreach over the results and overwriting key/value pairs, creates duplicate keys inside the array itself.
I can reproduce the test with a clean memcache instance.
Memcache Extension version: 3.0.1
memcached 1.2.2
PHP 5.2.6-1+lenny2 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan 26 2009 22:41:04)
Linux rtvdevnews 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686 GNU/Linux
Reproduce code:
---------------
<?php
$keys['forum'] = "_sql_forum_last_forum_topics";
$keys['photos'] = "_sql_photos_last";
$keys['videos'] = "_sql_videos_last";
$keys['audios'] = "_sql_audios_last";
$keys['blog'] = "_sql_blog_last";
$keys['popotnik'] = "_sql_popotnik_last";
$keys['mojsvet'] = "_sql_mojsvet_last";
$keys['klepetalnica'] = "_sql_klepetalnica_last";
$cache = array();
$key = "photos";
$mc = new Memcache;
$mc->addServer("localhost", 11211);
$mc->set("_sql_forum_last_forum_topics", array (
  0 =>
  array (
    'topic_id' => '25255',
    'forum_id' => '7',
    'topic_title' => 'S-t-a-v-e',
    'topic_time' => '1240323473',
    'topic_last_post_id' => '1590262',
    'forum_name' => 'Razno',
  ),
));
$mc->set("_sql_photos_last", array (
  0 =>
  array (
    'id' => '87097',
    'album_id' => '13310',
    'file_id' => '89021',
    'score' => '0',
    'cover' => NULL,
    'title' => 'Slika uporabnika veseljakinja',
    'caption' => NULL,
    'stamp' => '2009-04-21 16:06:16',
    'vote_count' => '0',
    'vote_sum' => '0',
    'voting_show' => '1',
    'tags' => '',
    'seen' => '',
    'visible' => '1',
    'listed' => '1',
    'category' => '0',
    'user_id' => '65748',
    'date' => '<a href="/slike/koledar/2009/04/21/">21.04.2009</a> || 16:06:16',
    'date_diff' => 'pred 8 minutami',
    'rating' => '0.0',
    'rating_count' => '0',
    'link' => '/slike/photo/87097',
    'show' => '/_up/photos/2009/04/21/u65748-87145_8396209_show.jpg',
    'thumb' => '/_up/photos/2009/04/21/u65748-87145_8396209_thumb.jpg',
    'small' => '/_up/photos/2009/04/21/u65748-87145_8396209_small.jpg',
    'author' => 'veseljakinja',
    'author_link' => '/profil/veseljakinja',
  ),
));
$cache = $mc->get(array_values($keys));
echo "array_keys ";
debug_zval_dump(array_keys($cache));
echo "isset ";
debug_zval_dump(isset($cache[$keys[$key]]));
echo "in_array/array_keys ";
debug_zval_dump(in_array($keys[$key],array_keys($cache)));
foreach ($cache as $k=>$v) {
        $cache[$k] = $v;
}
echo "array_keys ";
debug_zval_dump(array_keys($cache));
echo "isset ";
debug_zval_dump(isset($cache[$keys[$key]]));
echo "in_array/array_keys ";
debug_zval_dump(in_array($keys[$key],array_keys($cache)));
Expected result:
----------------
array_keys array(2) refcount(1){
  [0]=>
  string(28) "_sql_forum_last_forum_topics" refcount(1)
  [1]=>
  string(16) "_sql_photos_last" refcount(1)
}
isset bool(true) refcount(1)
in_array/array_keys bool(true) refcount(1)
array_keys array(3) refcount(1){
  [0]=>
  string(28) "_sql_forum_last_forum_topics" refcount(1)
  [1]=>
  string(16) "_sql_photos_last" refcount(1)
}
isset bool(true) refcount(1)
in_array/array_keys bool(true) refcount(1)
Actual result:
--------------
array_keys array(2) refcount(1){
  [0]=>
  string(28) "_sql_forum_last_forum_topics" refcount(1)
  [1]=>
  string(16) "_sql_photos_last" refcount(1)
}
isset bool(false) refcount(1)
in_array/array_keys bool(true) refcount(1)
array_keys array(3) refcount(1){
  [0]=>
  string(28) "_sql_forum_last_forum_topics" refcount(1)
  [1]=>
  string(16) "_sql_photos_last" refcount(1)
  [2]=>
  string(16) "_sql_photos_last" refcount(1)
}
isset bool(true) refcount(1)
in_array/array_keys bool(true) refcount(1)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 13:00:02 2025 UTC | 
I managed to reproduce the error today on debian lenny, php 5.2.6-lenny6/8 patchset, and the bundled php5-memcached 3.0.1 extension. Sadly, it was in production. A simple foreach like this is a temporary workaround: $multiget_copy = array(); foreach ($multiget_data as $k=>$v) { $multiget_copy[$k] = $v; } $multiget_data = $multiget_copy; Best regards, Tit