function delete in dataobjects now don't break strict syntax

This commit is contained in:
Mikael Nordfeldth 2013-10-29 10:20:57 +01:00
parent 23a6b4595f
commit 2dfa0bfcee
19 changed files with 46 additions and 45 deletions

View File

@ -51,12 +51,14 @@ class Avatar extends Managed_DataObject
} }
// We clean up the file, too // We clean up the file, too
function delete() function delete($useWhere=false)
{ {
$filename = $this->filename; $filename = $this->filename;
if (parent::delete() && file_exists(Avatar::path($filename))) { if (file_exists(Avatar::path($filename))) {
@unlink(Avatar::path($filename)); @unlink(Avatar::path($filename));
} }
return parent::delete($useWhere);
} }
/* /*

View File

@ -115,10 +115,10 @@ class Config extends Managed_DataObject
return $result; return $result;
} }
function delete() function delete($useWhere=false)
{ {
$result = parent::delete(); $result = parent::delete($useWhere);
if ($result) { if ($result !== false) {
Config::_blowSettingsCache(); Config::_blowSettingsCache();
} }
return $result; return $result;

View File

@ -54,14 +54,14 @@ class Consumer extends Managed_DataObject
* XXX: Should this happen in an OAuthDataStore instead? * XXX: Should this happen in an OAuthDataStore instead?
* *
*/ */
function delete() function delete($useWhere=false)
{ {
// XXX: Is there any reason NOT to do this kind of cleanup? // XXX: Is there any reason NOT to do this kind of cleanup?
$this->_deleteTokens(); $this->_deleteTokens();
$this->_deleteNonces(); $this->_deleteNonces();
parent::delete(); return parent::delete($useWhere);
} }
function _deleteTokens() function _deleteTokens()

View File

@ -78,7 +78,7 @@ class Fave extends Managed_DataObject
return $fave; return $fave;
} }
function delete() function delete($useWhere=false)
{ {
$profile = Profile::getKV('id', $this->user_id); $profile = Profile::getKV('id', $this->user_id);
$notice = Notice::getKV('id', $this->notice_id); $notice = Notice::getKV('id', $this->notice_id);
@ -87,7 +87,7 @@ class Fave extends Managed_DataObject
if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) { if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) {
$result = parent::delete(); $result = parent::delete($useWhere);
self::blow('fave:list-ids:notice_id:%d', $this->notice_id); self::blow('fave:list-ids:notice_id:%d', $this->notice_id);
self::blow('popular'); self::blow('popular');

View File

@ -84,12 +84,12 @@ class File_to_post extends Managed_DataObject
} }
} }
function delete() function delete($useWhere=false)
{ {
$f = File::getKV('id', $this->file_id); $f = File::getKV('id', $this->file_id);
if (!empty($f)) { if (!empty($f)) {
$f->blowCache(); $f->blowCache();
} }
return parent::delete(); return parent::delete($useWhere);
} }
} }

View File

@ -401,10 +401,10 @@ class Memcached_DataObject extends Safe_DataObject
return $result; return $result;
} }
function delete() function delete($useWhere=false)
{ {
$this->decache(); # while we still have the values! $this->decache(); # while we still have the values!
return parent::delete(); return parent::delete($useWhere);
} }
static function memcache() { static function memcache() {

View File

@ -162,7 +162,7 @@ class Notice extends Managed_DataObject
$this->_profile = $profile; $this->_profile = $profile;
} }
function delete() function delete($useWhere=false)
{ {
// For auditing purposes, save a record that the notice // For auditing purposes, save a record that the notice
// was deleted. // was deleted.
@ -171,11 +171,11 @@ class Notice extends Managed_DataObject
// insert fails. // insert fails.
$deleted = Deleted_notice::getKV('id', $this->id); $deleted = Deleted_notice::getKV('id', $this->id);
if (!$deleted) { if (!$deleted instanceof Deleted_notice) {
$deleted = Deleted_notice::getKV('uri', $this->uri); $deleted = Deleted_notice::getKV('uri', $this->uri);
} }
if (!$deleted) { if (!$deleted instanceof Deleted_notice) {
$deleted = new Deleted_notice(); $deleted = new Deleted_notice();
$deleted->id = $this->id; $deleted->id = $this->id;
@ -202,7 +202,7 @@ class Notice extends Managed_DataObject
// NOTE: we don't clear queue items // NOTE: we don't clear queue items
} }
$result = parent::delete(); $result = parent::delete($useWhere);
$this->blowOnDelete(); $this->blowOnDelete();
return $result; return $result;

View File

@ -139,14 +139,14 @@ class Oauth_application extends Managed_DataObject
} }
} }
function delete() function delete($useWhere=false)
{ {
$this->_deleteAppUsers(); $this->_deleteAppUsers();
$consumer = $this->getConsumer(); $consumer = $this->getConsumer();
$consumer->delete(); $consumer->delete();
parent::delete(); return parent::delete($useWhere);
} }
function _deleteAppUsers() function _deleteAppUsers()

View File

@ -869,7 +869,7 @@ class Profile extends Managed_DataObject
return parent::update($dataObject); return parent::update($dataObject);
} }
function delete() function delete($useWhere=false)
{ {
$this->_deleteNotices(); $this->_deleteNotices();
$this->_deleteSubscriptions(); $this->_deleteSubscriptions();
@ -891,7 +891,7 @@ class Profile extends Managed_DataObject
$inst->delete(); $inst->delete();
} }
parent::delete(); return parent::delete($useWhere);
} }
function _deleteNotices() function _deleteNotices()

View File

@ -334,7 +334,7 @@ class Profile_list extends Managed_DataObject
* @return boolean success * @return boolean success
*/ */
function delete() function delete($useWhere=false)
{ {
// force delete one item at a time. // force delete one item at a time.
if (empty($this->id)) { if (empty($this->id)) {
@ -349,7 +349,7 @@ class Profile_list extends Managed_DataObject
self::blow('profile:lists:%d', $this->tagger); self::blow('profile:lists:%d', $this->tagger);
return parent::delete(); return parent::delete($useWhere);
} }
/** /**

View File

@ -322,10 +322,10 @@ class Profile_tag extends Managed_DataObject
return $result; return $result;
} }
function delete() function delete($useWhere=false)
{ {
$result = parent::delete(); $result = parent::delete($useWhere);
if ($result) { if ($result !== false) {
self::blow('profile_list:tagged_count:%d:%s', self::blow('profile_list:tagged_count:%d:%s',
$this->tagger, $this->tagger,
$this->tag); $this->tag);

View File

@ -127,10 +127,10 @@ class Profile_tag_subscription extends Managed_DataObject
return $result; return $result;
} }
function delete() function delete($useWhere=false)
{ {
$result = parent::delete(); $result = parent::delete($useWhere);
if ($result) { if ($result !== false) {
self::blow('profile_list:subscriber_count:%d', self::blow('profile_list:subscriber_count:%d',
$this->profile_tag_id); $this->profile_tag_id);
} }

View File

@ -108,7 +108,7 @@ class Safe_DataObject extends DB_DataObject
* @return mixed * @return mixed
* @throws Exception * @throws Exception
*/ */
function __call($method, array $params) function __call($method, $params)
{ {
$return = null; $return = null;
// Yes, that's _call with one underscore, which does the // Yes, that's _call with one underscore, which does the

View File

@ -183,10 +183,10 @@ class Status_network extends Safe_DataObject
return $result; return $result;
} }
function delete() function delete($useWhere=false)
{ {
$this->decache(); # while we still have the values! $this->decache(); # while we still have the values!
return parent::delete(); return parent::delete($useWhere);
} }
/** /**

View File

@ -125,11 +125,10 @@ class Status_network_tag extends Safe_DataObject
return $ret; return $ret;
} }
function delete() function delete($useWhere=false)
{ {
$ret = parent::delete();
$this->decache(); $this->decache();
return $ret; return parent::delete($useWhere);
} }
static function withTag($tag) static function withTag($tag)

View File

@ -678,11 +678,11 @@ class User extends Managed_DataObject
return $this->getProfile()->hasRight($right); return $this->getProfile()->hasRight($right);
} }
function delete() function delete($useWhere=false)
{ {
if (empty($this->id)) { if (empty($this->id)) {
common_log(LOG_WARNING, "Ambiguous User->delete(); skipping related tables."); common_log(LOG_WARNING, "Ambiguous User->delete(); skipping related tables.");
return parent::delete(); return parent::delete($useWhere);
} }
try { try {
@ -710,7 +710,7 @@ class User extends Managed_DataObject
$this->_deleteTags(); $this->_deleteTags();
$this->_deleteBlocks(); $this->_deleteBlocks();
parent::delete(); return parent::delete($useWhere);
} }
function _deleteTags() function _deleteTags()

View File

@ -727,11 +727,11 @@ class User_group extends Managed_DataObject
* are not de-cached in the UI, including the sidebar lists on * are not de-cached in the UI, including the sidebar lists on
* GroupsAction * GroupsAction
*/ */
function delete() function delete($useWhere=false)
{ {
if (empty($this->id)) { if (empty($this->id)) {
common_log(LOG_WARNING, "Ambiguous User_group->delete(); skipping related tables."); common_log(LOG_WARNING, "Ambiguous User_group->delete(); skipping related tables.");
return parent::delete(); return parent::delete($useWhere);
} }
try { try {
@ -779,7 +779,7 @@ class User_group extends Managed_DataObject
// blow the cached ids // blow the cached ids
self::blow('user_group:notice_ids:%d', $this->id); self::blow('user_group:notice_ids:%d', $this->id);
return parent::delete(); return parent::delete($useWhere);
} }
public function update($dataObject=false) public function update($dataObject=false)

View File

@ -100,11 +100,11 @@ class Spam_score extends Managed_DataObject
return $score; return $score;
} }
function delete() function delete($useWhere=false)
{ {
self::blow('spam_score:notice_ids'); self::blow('spam_score:notice_ids');
self::blow('spam_score:notice_ids;last'); self::blow('spam_score:notice_ids;last');
parent::delete(); return parent::delete($useWhere);
} }
/** /**

View File

@ -399,9 +399,9 @@ class RSVP extends Managed_DataObject
$eventTitle); $eventTitle);
} }
function delete() function delete($useWhere=false)
{ {
self::blow('rsvp:for-event:%s', $event->id); self::blow('rsvp:for-event:%s', $event->id);
parent::delete(); return parent::delete($useWhere);
} }
} }