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

Roberto Gerola’s picture

Status: Active » Fixed

Commited to cvs, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)