Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x

This commit is contained in:
Sarven Capadisli 2010-01-07 09:53:29 +00:00
commit e53512cd2c
25 changed files with 108 additions and 42 deletions

View File

@ -108,7 +108,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
$member = new Group_member(); $member = new Group_member();
$member->group_id = $this->group->id; $member->group_id = $this->group->id;
$member->profile_id = $this->auth->id; $member->profile_id = $this->auth_user->id;
if (!$member->find(true)) { if (!$member->find(true)) {
$this->serverError(_('You are not a member of this group.')); $this->serverError(_('You are not a member of this group.'));
@ -118,12 +118,12 @@ class ApiGroupLeaveAction extends ApiAuthAction
$result = $member->delete(); $result = $member->delete();
if (!$result) { if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__); common_log_db_error($member, 'DELETE', __FILE__);
$this->serverError( $this->serverError(
sprintf( sprintf(
_('Could not remove user %s to group %s.'), _('Could not remove user %s from group %s.'),
$this->user->nickname, $this->user->nickname,
$this->$group->nickname $this->group->nickname
) )
); );
return; return;

View File

@ -123,8 +123,8 @@ class LeavegroupAction extends Action
$result = $member->delete(); $result = $member->delete();
if (!$result) { if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__); common_log_db_error($member, 'DELETE', __FILE__);
$this->serverError(sprintf(_('Could not remove user %s to group %s'), $this->serverError(sprintf(_('Could not remove user %s from group %s'),
$cur->nickname, $this->group->nickname)); $cur->nickname, $this->group->nickname));
} }

View File

@ -208,7 +208,14 @@ class TwitapisearchatomAction extends ApiAction
$this->showFeed(); $this->showFeed();
foreach ($notices as $n) { foreach ($notices as $n) {
$this->showEntry($n);
$profile = $n->getProfile();
// Don't show notices from deleted users
if (!empty($profile)) {
$this->showEntry($n);
}
} }
$this->endAtom(); $this->endAtom();

View File

@ -37,7 +37,7 @@ class Avatar extends Memcached_DataObject
} }
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Avatar', $kv); return Memcached_DataObject::pkeyGet('Avatar', $kv);
} }

View File

@ -120,7 +120,7 @@ class Config extends Memcached_DataObject
return $result; return $result;
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Config', $kv); return Memcached_DataObject::pkeyGet('Config', $kv);
} }

View File

@ -32,7 +32,7 @@ class Fave extends Memcached_DataObject
return $fave; return $fave;
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Fave', $kv); return Memcached_DataObject::pkeyGet('Fave', $kv);
} }

View File

@ -62,7 +62,7 @@ class File_to_post extends Memcached_DataObject
} }
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('File_to_post', $kv); return Memcached_DataObject::pkeyGet('File_to_post', $kv);
} }

View File

@ -40,7 +40,7 @@ class Group_block extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Group_block', $kv); return Memcached_DataObject::pkeyGet('Group_block', $kv);
} }

View File

@ -20,7 +20,7 @@ class Group_inbox extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Group_inbox', $kv); return Memcached_DataObject::pkeyGet('Group_inbox', $kv);
} }

View File

@ -21,7 +21,7 @@ class Group_member extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Group_member', $kv); return Memcached_DataObject::pkeyGet('Group_member', $kv);
} }

View File

@ -90,17 +90,16 @@ class Memcached_DataObject extends DB_DataObject
unset($i); unset($i);
} }
$i = Memcached_DataObject::getcached($cls, $k, $v); $i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i !== false) { // false == cache miss if ($i === false) { // false == cache miss
return $i;
} else {
$i = DB_DataObject::factory($cls); $i = DB_DataObject::factory($cls);
if (empty($i)) { if (empty($i)) {
return false; $i = false;
return $i;
} }
$result = $i->get($k, $v); $result = $i->get($k, $v);
if ($result) { if ($result) {
// Hit!
$i->encache(); $i->encache();
return $i;
} else { } else {
// save the fact that no such row exists // save the fact that no such row exists
$c = self::memcache(); $c = self::memcache();
@ -108,12 +107,16 @@ class Memcached_DataObject extends DB_DataObject
$ck = self::cachekey($cls, $k, $v); $ck = self::cachekey($cls, $k, $v);
$c->set($ck, null); $c->set($ck, null);
} }
return false; $i = false;
} }
} }
return $i;
} }
function &pkeyGet($cls, $kv) /**
* @fixme Should this return false on lookup fail to match staticGet?
*/
function pkeyGet($cls, $kv)
{ {
$i = Memcached_DataObject::multicache($cls, $kv); $i = Memcached_DataObject::multicache($cls, $kv);
if ($i !== false) { // false == cache miss if ($i !== false) { // false == cache miss
@ -143,7 +146,9 @@ class Memcached_DataObject extends DB_DataObject
function insert() function insert()
{ {
$result = parent::insert(); $result = parent::insert();
$this->encache(); // in case of cached negative lookups if ($result) {
$this->encache(); // in case of cached negative lookups
}
return $result; return $result;
} }

View File

@ -101,7 +101,7 @@ class Notice_inbox extends Memcached_DataObject
return $ids; return $ids;
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Notice_inbox', $kv); return Memcached_DataObject::pkeyGet('Notice_inbox', $kv);
} }

View File

@ -96,7 +96,7 @@ class Notice_tag extends Memcached_DataObject
} }
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Notice_tag', $kv); return Memcached_DataObject::pkeyGet('Notice_tag', $kv);
} }

View File

@ -504,6 +504,7 @@ class Profile extends Memcached_DataObject
'Reply', 'Reply',
'Group_member', 'Group_member',
); );
Event::handle('ProfileDeleteRelated', array($this, &$related));
foreach ($related as $cls) { foreach ($related as $cls) {
$inst = new $cls(); $inst = new $cls();

View File

@ -43,7 +43,7 @@ class Profile_role extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Profile_role', $kv); return Memcached_DataObject::pkeyGet('Profile_role', $kv);
} }

View File

@ -55,7 +55,7 @@ class Queue_item extends Memcached_DataObject
return null; return null;
} }
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Queue_item', $kv); return Memcached_DataObject::pkeyGet('Queue_item', $kv);
} }

View File

@ -46,7 +46,7 @@ class Subscription extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('Subscription', $kv); return Memcached_DataObject::pkeyGet('Subscription', $kv);
} }

View File

@ -352,7 +352,7 @@ class HTMLOutputter extends XMLOutputter
{ {
if(Event::handle('StartScriptElement', array($this,&$src,&$type))) { if(Event::handle('StartScriptElement', array($this,&$src,&$type))) {
$url = parse_url($src); $url = parse_url($src);
if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment)) if( empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment']))
{ {
$src = common_path($src) . '?version=' . STATUSNET_VERSION; $src = common_path($src) . '?version=' . STATUSNET_VERSION;
} }

View File

@ -105,8 +105,14 @@ class JSONSearchResultsList
break; break;
} }
$item = new ResultItem($this->notice); $profile = $this->notice->getProfile();
array_push($this->results, $item);
// Don't show notices from deleted users
if (!empty($profile)) {
$item = new ResultItem($this->notice);
array_push($this->results, $item);
}
} }
$time_end = microtime(true); $time_end = microtime(true);

View File

@ -52,7 +52,6 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
public $attributes = array(); public $attributes = array();
function onInitializePlugin(){ function onInitializePlugin(){
parent::onInitializePlugin();
if(!isset($this->host)){ if(!isset($this->host)){
throw new Exception("must specify a host"); throw new Exception("must specify a host");
} }

View File

@ -84,7 +84,7 @@ class MinifyPlugin extends Plugin
function onStartScriptElement($action,&$src,&$type) { function onStartScriptElement($action,&$src,&$type) {
$url = parse_url($src); $url = parse_url($src);
if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment)) if( empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment']))
{ {
$src = $this->minifyUrl($src); $src = $this->minifyUrl($src);
} }

View File

@ -22,7 +22,7 @@ class User_openid_trustroot extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv); return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv);
} }

View File

@ -102,20 +102,20 @@ class UserFlagPlugin extends Plugin
function onAutoload($cls) function onAutoload($cls)
{ {
switch ($cls) switch (strtolower($cls))
{ {
case 'FlagprofileAction': case 'flagprofileaction':
case 'AdminprofileflagAction': case 'adminprofileflagaction':
case 'ClearflagAction': case 'clearflagaction':
include_once INSTALLDIR.'/plugins/UserFlag/' . include_once INSTALLDIR.'/plugins/UserFlag/' .
strtolower(mb_substr($cls, 0, -6)) . '.php'; strtolower(mb_substr($cls, 0, -6)) . '.php';
return false; return false;
case 'FlagProfileForm': case 'flagprofileform':
case 'ClearFlagForm': case 'clearflagform':
include_once INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php'); include_once INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php');
return false; return false;
case 'User_flag_profile': case 'user_flag_profile':
include_once INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php'; include_once INSTALLDIR.'/plugins/UserFlag/'.ucfirst(strtolower($cls)).'.php';
return false; return false;
default: default:
return true; return true;
@ -258,4 +258,39 @@ class UserFlagPlugin extends Plugin
} }
return true; return true;
} }
/**
* Ensure that flag entries for a profile are deleted
* along with the profile when deleting users.
* This prevents breakage of the admin profile flag UI.
*
* @param Profile $profile
* @param array &$related list of related tables; entries
* with matching profile_id will be deleted.
*
* @return boolean hook result
*/
function onProfileDeleteRelated($profile, &$related)
{
$related[] = 'user_flag_profile';
return true;
}
/**
* Ensure that flag entries created by a user are deleted
* when that user gets deleted.
*
* @param User $user
* @param array &$related list of related tables; entries
* with matching user_id will be deleted.
*
* @return boolean hook result
*/
function onUserDeleteRelated($user, &$related)
{
$related[] = 'user_flag_profile';
return true;
}
} }

View File

@ -89,6 +89,17 @@ class User_flag_profile extends Memcached_DataObject
return array('profile_id' => 'N', 'user_id' => 'N'); return array('profile_id' => 'N', 'user_id' => 'N');
} }
/**
* return key definitions for DB_DataObject
*
* @return array key definitions
*/
function keyTypes()
{
return $this->keys();
}
/** /**
* Get a single object with multiple keys * Get a single object with multiple keys
* *
@ -97,7 +108,7 @@ class User_flag_profile extends Memcached_DataObject
* @return User_flag_profile found object or null * @return User_flag_profile found object or null
*/ */
function &pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('User_flag_profile', $kv); return Memcached_DataObject::pkeyGet('User_flag_profile', $kv);
} }

View File

@ -128,6 +128,8 @@ function console_help()
if (CONSOLE_INTERACTIVE) { if (CONSOLE_INTERACTIVE) {
print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n"; print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n";
$prompt = common_config('site', 'name') . '> '; $prompt = common_config('site', 'name') . '> ';
} else {
$prompt = '';
} }
while (!feof(STDIN)) { while (!feof(STDIN)) {
$line = read_input_line($prompt); $line = read_input_line($prompt);