Closed (fixed)
Project:
Localizer
Version:
5.x-1.9
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 May 2007 at 10:09 UTC
Updated:
25 May 2007 at 07:32 UTC
My site loads slowly, because of a not working cache in localizertranslation_find, there are some typos...
here's a fixed version of the function:
function localizertranslation_find($conditions=NULL, $howmany='all', $force=FALSE) {
static $localecache=array();
if(array_key_exists($conditions . ":$howmany", $localecache) && isset($localecache[$conditions . ":$howmany"]) && !$force) {
return $localecache[$conditions . ":$howmany"];
}
$items = array();
$sql = "SELECT * FROM {localizertranslation}";
if($conditions) {
$sql .= ' WHERE ' . $conditions;
}
$result = db_query($sql);
while ($item = db_fetch_object($result)) {
$items[$item->tid]['tid'] = $item->tid;
$items[$item->tid]['object_name'] = $item->object_name;
$items[$item->tid]['object_key'] = $item->object_key;
$items[$item->tid]['object_field'] = $item->object_field;
$items[$item->tid]['locale'] = $item->locale;
$items[$item->tid]['translation'] = $item->translation;
}
if($howmany=='one') {
$oneitem = array();
foreach($items as $tid=>$item) {
foreach($item as $key=>$value) {
$oneitem[$key]=$value;
}
break;
}
$localecache[$conditions . ":$howmany"] = $oneitem;
return $oneitem;
}
else {
$localecache[$conditions . ":$howmany"] = $items;
return $items;
}
}
Comments
Comment #1
Roberto Gerola commentedCommited to cvs, thanks.
Comment #2
(not verified) commented