git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit b53391e5 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x

parents 7dd532b6 7cfbe7c2

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -24,7 +24,7 @@
* @author Evan Prodromou <evan@status.net>
* @author Zach Copley <zach@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @copyright 2008-2010 StatusNet, Inc.
* @copyright 2008-2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
......@@ -92,7 +92,6 @@ class PathsadminpanelAction extends AdminPanelAction
'site' => array('path', 'locale_path', 'ssl', 'sslserver'),
'theme' => array('server', 'dir', 'path', 'sslserver', 'sslpath'),
'avatar' => array('server', 'dir', 'path'),
'background' => array('server', 'dir', 'path', 'sslserver', 'sslpath'),
'attachments' => array('server', 'dir', 'path', 'sslserver', 'sslpath')
);
......@@ -163,14 +162,6 @@ class PathsadminpanelAction extends AdminPanelAction
$this->clientError(sprintf(_('Avatar directory not writable: %s.'), $values['avatar']['dir']));
}
// Validate background dir
if (empty($values['background']['dir']) || !is_writable($values['background']['dir'])) {
// TRANS: Client error in Paths admin panel.
// TRANS: %s is the background directory that could not be written to.
$this->clientError(sprintf(_('Background directory not writable: %s.'), $values['background']['dir']));
}
// Validate locales dir
// XXX: What else do we need to validate for lacales path here? --Z
......
......@@ -36,7 +36,7 @@ class Memcached_DataObject extends Safe_DataObject
$v = $k;
$keys = self::pkeyCols($cls);
if (count($keys) > 1) {
// FIXME: maybe call pkeyGet() ourselves?
// FIXME: maybe call pkeyGet() ourselves?
throw new Exception('Use pkeyGet() for compound primary keys');
}
$k = $keys[0];
......@@ -113,10 +113,10 @@ class Memcached_DataObject extends Safe_DataObject
} else {
$result = array_fill_keys($keyVals, null);
}
$toFetch = array();
foreach ($keyVals as $keyVal) {
$toFetch = array();
foreach ($keyVals as $keyVal) {
if (is_array($keyCol)) {
$kv = array_combine($keyCol, $keyVal);
......@@ -124,25 +124,26 @@ class Memcached_DataObject extends Safe_DataObject
$kv = array($keyCol => $keyVal);
}
$kv = array_merge($otherCols, $kv);
$i = self::multicache($cls, $kv);
if ($i !== false) {
$kv = array_merge($otherCols, $kv);
$i = self::multicache($cls, $kv);
if ($i !== false) {
if (is_array($keyCol)) {
$result[implode(',', $keyVal)] = $i;
} else {
$result[$keyVal] = $i;
}
} else if (!empty($keyVal)) {
$toFetch[] = $keyVal;
}
}
if (count($toFetch) > 0) {
} else if (!empty($keyVal)) {
$toFetch[] = $keyVal;
}
}
if (count($toFetch) > 0) {
$i = DB_DataObject::factory($cls);
if (empty($i)) {
throw new Exception(_('Cannot instantiate class ' . $cls));
// TRANS: Exception thrown when a program code class (%s) cannot be instantiated.
throw new Exception(sprintf(_('Cannot instantiate class %s.'),$cls));
}
foreach ($otherCols as $otherKeyCol => $otherKeyVal) {
$i->$otherKeyCol = $otherKeyVal;
......@@ -152,10 +153,10 @@ class Memcached_DataObject extends Safe_DataObject
} else {
$i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
}
if ($i->find()) {
while ($i->fetch()) {
$copy = clone($i);
$copy->encache();
if ($i->find()) {
while ($i->fetch()) {
$copy = clone($i);
$copy->encache();
if (is_array($keyCol)) {
$vals = array();
foreach ($keyCol as $k) {
......@@ -165,36 +166,36 @@ class Memcached_DataObject extends Safe_DataObject
} else {
$result[$i->$keyCol] = $copy;
}
}
}
// Save state of DB misses
foreach ($toFetch as $keyVal) {
}
}
// Save state of DB misses
foreach ($toFetch as $keyVal) {
$r = null;
if (is_array($keyCol)) {
$r = $result[implode(',', $keyVal)];
} else {
$r = $result[$keyVal];
}
if (empty($r)) {
if (empty($r)) {
if (is_array($keyCol)) {
$kv = array_combine($keyCol, $keyVal);
} else {
$kv = array($keyCol => $keyVal);
}
$kv = array_merge($otherCols, $kv);
// save the fact that no such row exists
$c = self::memcache();
if (!empty($c)) {
$ck = self::multicacheKey($cls, $kv);
$c->set($ck, null);
}
}
}
}
// save the fact that no such row exists
$c = self::memcache();
if (!empty($c)) {
$ck = self::multicacheKey($cls, $kv);
$c->set($ck, null);
}
}
}
}
return $result;
return $result;
}
static function _inMultiKey($i, $cols, $values)
......@@ -249,7 +250,8 @@ class Memcached_DataObject extends Safe_DataObject
{
$i = DB_DataObject::factory($cls);
if (empty($i)) {
throw new Exception(_('Cannot instantiate a ' . $cls));
// TRANS: Exception thrown when a program code class (%s) cannot be instantiated.
throw new Exception(sprintf(_('Cannot instantiate class %s.'),$cls));
}
$types = $i->keyTypes();
ksort($types);
......@@ -267,27 +269,27 @@ class Memcached_DataObject extends Safe_DataObject
function listGet($cls, $keyCol, $keyVals)
{
$pkeyMap = array_fill_keys($keyVals, array());
$pkeyMap = array_fill_keys($keyVals, array());
$result = array_fill_keys($keyVals, array());
$pkeyCols = self::pkeyCols($cls);
$toFetch = array();
$toFetch = array();
$allPkeys = array();
// We only cache keys -- not objects!
foreach ($keyVals as $keyVal) {
$l = self::cacheGet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal));
if ($l !== false) {
$pkeyMap[$keyVal] = $l;
foreach ($keyVals as $keyVal) {
$l = self::cacheGet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal));
if ($l !== false) {
$pkeyMap[$keyVal] = $l;
foreach ($l as $pkey) {
$allPkeys[] = $pkey;
}
} else {
$toFetch[] = $keyVal;
}
}
} else {
$toFetch[] = $keyVal;
}
}
if (count($allPkeys) > 0) {
$keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys);
......@@ -303,10 +305,11 @@ class Memcached_DataObject extends Safe_DataObject
}
if (count($toFetch) > 0) {
$i = DB_DataObject::factory($cls);
if (empty($i)) {
throw new Exception(_('Cannot instantiate class ' . $cls));
}
$i = DB_DataObject::factory($cls);
if (empty($i)) {
// TRANS: Exception thrown when a program code class (%s) cannot be instantiated.
throw new Exception(sprintf(_('Cannot instantiate class %s.'),$cls));
}
$i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
if ($i->find()) {
sprintf("listGet() got {$i->N} results for class $cls key $keyCol");
......@@ -320,32 +323,32 @@ class Memcached_DataObject extends Safe_DataObject
}
$pkeyMap[$i->$keyCol][] = $pkeyVal;
}
}
foreach ($toFetch as $keyVal) {
}
foreach ($toFetch as $keyVal) {
self::cacheSet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal),
$pkeyMap[$keyVal]);
}
}
return $result;
}