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->group_id = $this->group->id;
$member->profile_id = $this->auth->id;
$member->profile_id = $this->auth_user->id;
if (!$member->find(true)) {
$this->serverError(_('You are not a member of this group.'));
@ -118,12 +118,12 @@ class ApiGroupLeaveAction extends ApiAuthAction
$result = $member->delete();
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.'),
_('Could not remove user %s from group %s.'),
$this->user->nickname,
$this->$group->nickname
$this->group->nickname
)
);
return;

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ class Fave extends Memcached_DataObject
return $fave;
}
function &pkeyGet($kv)
function pkeyGet($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);
}

View File

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

View File

@ -90,17 +90,16 @@ class Memcached_DataObject extends DB_DataObject
unset($i);
}
$i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i !== false) { // false == cache miss
return $i;
} else {
if ($i === false) { // false == cache miss
$i = DB_DataObject::factory($cls);
if (empty($i)) {
return false;
$i = false;
return $i;
}
$result = $i->get($k, $v);
if ($result) {
// Hit!
$i->encache();
return $i;
} else {
// save the fact that no such row exists
$c = self::memcache();
@ -108,12 +107,16 @@ class Memcached_DataObject extends DB_DataObject
$ck = self::cachekey($cls, $k, $v);
$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);
if ($i !== false) { // false == cache miss
@ -143,7 +146,9 @@ class Memcached_DataObject extends DB_DataObject
function insert()
{
$result = parent::insert();
if ($result) {
$this->encache(); // in case of cached negative lookups
}
return $result;
}

View File

@ -101,7 +101,7 @@ class Notice_inbox extends Memcached_DataObject
return $ids;
}
function &pkeyGet($kv)
function pkeyGet($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);
}

View File

@ -504,6 +504,7 @@ class Profile extends Memcached_DataObject
'Reply',
'Group_member',
);
Event::handle('ProfileDeleteRelated', array($this, &$related));
foreach ($related as $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 */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Profile_role', $kv);
}

View File

@ -55,7 +55,7 @@ class Queue_item extends Memcached_DataObject
return null;
}
function &pkeyGet($kv)
function pkeyGet($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 */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($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))) {
$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;
}

View File

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

View File

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

View File

@ -84,7 +84,7 @@ class MinifyPlugin extends Plugin
function onStartScriptElement($action,&$src,&$type) {
$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);
}

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 */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv);
}

View File

@ -102,20 +102,20 @@ class UserFlagPlugin extends Plugin
function onAutoload($cls)
{
switch ($cls)
switch (strtolower($cls))
{
case 'FlagprofileAction':
case 'AdminprofileflagAction':
case 'ClearflagAction':
case 'flagprofileaction':
case 'adminprofileflagaction':
case 'clearflagaction':
include_once INSTALLDIR.'/plugins/UserFlag/' .
strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
case 'FlagProfileForm':
case 'ClearFlagForm':
case 'flagprofileform':
case 'clearflagform':
include_once INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php');
return false;
case 'User_flag_profile':
include_once INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php';
case 'user_flag_profile':
include_once INSTALLDIR.'/plugins/UserFlag/'.ucfirst(strtolower($cls)).'.php';
return false;
default:
return true;
@ -258,4 +258,39 @@ class UserFlagPlugin extends Plugin
}
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 key definitions for DB_DataObject
*
* @return array key definitions
*/
function keyTypes()
{
return $this->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
*/
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('User_flag_profile', $kv);
}

View File

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