Fix i18n issues

Remove trailing whitespace and convert leading tabs to spaces
This commit is contained in:
Siebrand Mazeland 2011-08-30 11:03:26 +02:00
parent 3e60d4cb3f
commit c4fd560b32

View File

@ -36,7 +36,7 @@ class Memcached_DataObject extends Safe_DataObject
$v = $k; $v = $k;
$keys = self::pkeyCols($cls); $keys = self::pkeyCols($cls);
if (count($keys) > 1) { if (count($keys) > 1) {
// FIXME: maybe call pkeyGet() ourselves? // FIXME: maybe call pkeyGet() ourselves?
throw new Exception('Use pkeyGet() for compound primary keys'); throw new Exception('Use pkeyGet() for compound primary keys');
} }
$k = $keys[0]; $k = $keys[0];
@ -113,10 +113,10 @@ class Memcached_DataObject extends Safe_DataObject
} else { } else {
$result = array_fill_keys($keyVals, null); $result = array_fill_keys($keyVals, null);
} }
$toFetch = array(); $toFetch = array();
foreach ($keyVals as $keyVal) { foreach ($keyVals as $keyVal) {
if (is_array($keyCol)) { if (is_array($keyCol)) {
$kv = array_combine($keyCol, $keyVal); $kv = array_combine($keyCol, $keyVal);
@ -124,25 +124,25 @@ class Memcached_DataObject extends Safe_DataObject
$kv = array($keyCol => $keyVal); $kv = array($keyCol => $keyVal);
} }
$kv = array_merge($otherCols, $kv); $kv = array_merge($otherCols, $kv);
$i = self::multicache($cls, $kv); $i = self::multicache($cls, $kv);
if ($i !== false) { if ($i !== false) {
if (is_array($keyCol)) { if (is_array($keyCol)) {
$result[implode(',', $keyVal)] = $i; $result[implode(',', $keyVal)] = $i;
} else { } else {
$result[$keyVal] = $i; $result[$keyVal] = $i;
} }
} else if (!empty($keyVal)) { } else if (!empty($keyVal)) {
$toFetch[] = $keyVal; $toFetch[] = $keyVal;
} }
} }
if (count($toFetch) > 0) { if (count($toFetch) > 0) {
$i = DB_DataObject::factory($cls); $i = DB_DataObject::factory($cls);
if (empty($i)) { if (empty($i)) {
throw new Exception(_('Cannot instantiate class ' . $cls)); throw new Exception(sprintf(_('Cannot instantiate class %s.'),$cls));
} }
foreach ($otherCols as $otherKeyCol => $otherKeyVal) { foreach ($otherCols as $otherKeyCol => $otherKeyVal) {
$i->$otherKeyCol = $otherKeyVal; $i->$otherKeyCol = $otherKeyVal;
@ -152,10 +152,10 @@ class Memcached_DataObject extends Safe_DataObject
} else { } else {
$i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol)); $i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
} }
if ($i->find()) { if ($i->find()) {
while ($i->fetch()) { while ($i->fetch()) {
$copy = clone($i); $copy = clone($i);
$copy->encache(); $copy->encache();
if (is_array($keyCol)) { if (is_array($keyCol)) {
$vals = array(); $vals = array();
foreach ($keyCol as $k) { foreach ($keyCol as $k) {
@ -165,36 +165,36 @@ class Memcached_DataObject extends Safe_DataObject
} else { } else {
$result[$i->$keyCol] = $copy; $result[$i->$keyCol] = $copy;
} }
} }
} }
// Save state of DB misses // Save state of DB misses
foreach ($toFetch as $keyVal) { foreach ($toFetch as $keyVal) {
$r = null; $r = null;
if (is_array($keyCol)) { if (is_array($keyCol)) {
$r = $result[implode(',', $keyVal)]; $r = $result[implode(',', $keyVal)];
} else { } else {
$r = $result[$keyVal]; $r = $result[$keyVal];
} }
if (empty($r)) { if (empty($r)) {
if (is_array($keyCol)) { if (is_array($keyCol)) {
$kv = array_combine($keyCol, $keyVal); $kv = array_combine($keyCol, $keyVal);
} else { } else {
$kv = array($keyCol => $keyVal); $kv = array($keyCol => $keyVal);
} }
$kv = array_merge($otherCols, $kv); $kv = array_merge($otherCols, $kv);
// save the fact that no such row exists // save the fact that no such row exists
$c = self::memcache(); $c = self::memcache();
if (!empty($c)) { if (!empty($c)) {
$ck = self::multicacheKey($cls, $kv); $ck = self::multicacheKey($cls, $kv);
$c->set($ck, null); $c->set($ck, null);
} }
} }
} }
} }
return $result; return $result;
} }
static function _inMultiKey($i, $cols, $values) static function _inMultiKey($i, $cols, $values)
@ -267,27 +267,27 @@ 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());
$result = 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();
// We only cache keys -- not objects! // We only cache keys -- not objects!
foreach ($keyVals as $keyVal) { foreach ($keyVals as $keyVal) {
$l = self::cacheGet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal)); $l = self::cacheGet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal));
if ($l !== false) { if ($l !== false) {
$pkeyMap[$keyVal] = $l; $pkeyMap[$keyVal] = $l;
foreach ($l as $pkey) { foreach ($l as $pkey) {
$allPkeys[] = $pkey; $allPkeys[] = $pkey;
} }
} else { } else {
$toFetch[] = $keyVal; $toFetch[] = $keyVal;
} }
} }
if (count($allPkeys) > 0) { if (count($allPkeys) > 0) {
$keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys); $keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys);
@ -303,10 +303,10 @@ class Memcached_DataObject extends Safe_DataObject
} }
if (count($toFetch) > 0) { if (count($toFetch) > 0) {
$i = DB_DataObject::factory($cls); $i = DB_DataObject::factory($cls);
if (empty($i)) { if (empty($i)) {
throw new Exception(_('Cannot instantiate class ' . $cls)); throw new Exception(_('Cannot instantiate class ' . $cls));
} }
$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"); sprintf("listGet() got {$i->N} results for class $cls key $keyCol");
@ -320,32 +320,32 @@ class Memcached_DataObject extends Safe_DataObject
} }
$pkeyMap[$i->$keyCol][] = $pkeyVal; $pkeyMap[$i->$keyCol][] = $pkeyVal;
} }
} }
foreach ($toFetch as $keyVal) { foreach ($toFetch as $keyVal) {
self::cacheSet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal), self::cacheSet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal),
$pkeyMap[$keyVal]); $pkeyMap[$keyVal]);
} }
} }
return $result; return $result;
}
function columnType($columnName)
{
$keys = $this->table();
if (!array_key_exists($columnName, $keys)) {
throw new Exception('Unknown key column ' . $columnName . ' in ' . join(',', array_keys($keys)));
}
$def = $keys[$columnName];
if ($def & DB_DATAOBJECT_INT) {
return 'integer';
} else {
return 'string';
}
} }
function columnType($columnName)
{
$keys = $this->table();
if (!array_key_exists($columnName, $keys)) {
throw new Exception('Unknown key column ' . $columnName . ' in ' . join(',', array_keys($keys)));
}
$def = $keys[$columnName];
if ($def & DB_DATAOBJECT_INT) {
return 'integer';
} else {
return 'string';
}
}
/** /**
* @todo FIXME: Should this return false on lookup fail to match staticGet? * @todo FIXME: Should this return false on lookup fail to match staticGet?
*/ */