We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit f405ffa5 authored by Evan Prodromou's avatar Evan Prodromou

Corrected pkeys for listGet()

parent e09310ff
...@@ -267,10 +267,10 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -267,10 +267,10 @@ class Memcached_DataObject extends Safe_DataObject
function listGet($cls, $keyCol, $keyVals) function listGet($cls, $keyCol, $keyVals)
{ {
$pkeyMap = array_fill_keys($keyVals, array()); $pkeyMap = array_fill_keys($keyVals, array());
$results = array_fill_keys($keyVals, array()); $result = array_fill_keys($keyVals, array());
$pkeyCols = self::pkeyCols($cls); $pkeyCols = self::pkeyCols($cls);
$toFetch = array(); $toFetch = array();
$allPkeys = array(); $allPkeys = array();
...@@ -280,19 +280,23 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -280,19 +280,23 @@ class Memcached_DataObject extends Safe_DataObject
$l = self::cacheGet(sprintf("%s:list-ids:%s:%s", $cls, $keyCol, $keyVal)); $l = self::cacheGet(sprintf("%s:list-ids:%s:%s", $cls, $keyCol, $keyVal));
if ($l !== false) { if ($l !== false) {
$pkeyMap[$keyVal] = $l; $pkeyMap[$keyVal] = $l;
$allPkeys = array_merge($allPkeys, $l); foreach ($l as $pkey) {
$allPkeys[] = $pkey;
}
} else { } else {
$toFetch[] = $keyVal; $toFetch[] = $keyVal;
} }
} }
$keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys); if (count($allPkeys) > 0) {
$keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys);
foreach ($pkeyMap as $keyVal => $pkeyList) { foreach ($pkeyMap as $keyVal => $pkeyList) {
foreach ($pkeyList as $pkeyVal) { foreach ($pkeyList as $pkeyVal) {
$i = $keyResults[$pkeyVal]; $i = $keyResults[implode(',',$pkeyVal)];
if (!empty($i)) { if (!empty($i)) {
$results[$keyVal][] = $i; $result[$keyVal][] = $i;
}
} }
} }
} }
...@@ -304,6 +308,7 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -304,6 +308,7 @@ class Memcached_DataObject extends Safe_DataObject
} }
$i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol)); $i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
if ($i->find()) { if ($i->find()) {
sprintf("listGet() got {$i->N} results for class $cls key $keyCol");
while ($i->fetch()) { while ($i->fetch()) {
$copy = clone($i); $copy = clone($i);
$copy->encache(); $copy->encache();
...@@ -320,7 +325,7 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -320,7 +325,7 @@ class Memcached_DataObject extends Safe_DataObject
$pkeyMap[$keyVal]); $pkeyMap[$keyVal]);
} }
} }
return $result; return $result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment