From 45c9d3d729a9c811282bdb9caa70450218200e8b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 29 Dec 2009 14:05:43 -0800 Subject: Add progress output and optional --sleep-time parameter to triminboxes.php --- classes/Notice_inbox.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'classes') diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index b39006542..d3ddad656 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -106,6 +106,13 @@ class Notice_inbox extends Memcached_DataObject return Memcached_DataObject::pkeyGet('Notice_inbox', $kv); } + /** + * Trim inbox for a given user to latest NOTICE_INBOX_LIMIT items + * (up to NOTICE_INBOX_GC_MAX will be deleted). + * + * @param int $user_id + * @return int count of notices dropped from the inbox, if any + */ static function gc($user_id) { $entry = new Notice_inbox(); @@ -133,6 +140,8 @@ class Notice_inbox extends Memcached_DataObject $notices = array(); } } + + return $total; } static function deleteMatching($user_id, $notices) -- cgit v1.2.3-54-g00ecf From 9218cce3cdc824e2011bcdf250a08ca1698f5ea1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 30 Dec 2009 15:55:15 -0800 Subject: subbug debug info to check on free ordering --- classes/Memcached_DataObject.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index d8b0db5a6..4efec06ab 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -31,11 +31,20 @@ class Memcached_DataObject extends DB_DataObject function __destruct() { + if (get_class($this) == 'Profile') + common_log(LOG_INFO, 'subbug: destructing result id ' . $this->_DB_resultid); $this->free(); if (method_exists('DB_DataObject', '__destruct')) { parent::__destruct(); } } + + function free() + { + if (get_class($this) == 'Profile') + common_log(LOG_INFO, 'subbug: freeing result id ' . $this->_DB_resultid); + parent::free(); + } function &staticGet($cls, $k, $v=null) { -- cgit v1.2.3-54-g00ecf From ff50c2b91d9fadaa9a4ede11785408408fc2d3c5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 30 Dec 2009 16:40:59 -0800 Subject: Revert debugging code --- classes/Memcached_DataObject.php | 9 --------- lib/profilelist.php | 5 ----- 2 files changed, 14 deletions(-) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 4efec06ab..d8b0db5a6 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -31,20 +31,11 @@ class Memcached_DataObject extends DB_DataObject function __destruct() { - if (get_class($this) == 'Profile') - common_log(LOG_INFO, 'subbug: destructing result id ' . $this->_DB_resultid); $this->free(); if (method_exists('DB_DataObject', '__destruct')) { parent::__destruct(); } } - - function free() - { - if (get_class($this) == 'Profile') - common_log(LOG_INFO, 'subbug: freeing result id ' . $this->_DB_resultid); - parent::free(); - } function &staticGet($cls, $k, $v=null) { diff --git a/lib/profilelist.php b/lib/profilelist.php index ae875ac01..3412d41d1 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -86,21 +86,16 @@ class ProfileList extends Widget function showProfiles() { - $log = strtolower(get_class($this)) == 'subscriberslist' && $this->owner->nickname == 'petercook'; $cnt = 0; - if ($log) common_log(LOG_INFO, "subbug: starting with {$this->profile->N}"); while ($this->profile->fetch()) { $cnt++; if($cnt > PROFILES_PER_PAGE) { - if ($log) common_log(LOG_INFO, "subbug: breaking at $cnt"); break; } - if ($log) common_log(LOG_INFO, "subbug: showing at $cnt"); $pli = $this->newListItem($this->profile); $pli->show(); } - if ($log) common_log(LOG_INFO, "subbug: ended at $cnt"); return $cnt; } -- cgit v1.2.3-54-g00ecf From 89cca01259d71f3da961ef64def3647f86a01567 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 30 Dec 2009 16:42:57 -0800 Subject: Take Memcached_DataObject destructor back out to check whether it might be causing some under-the-hood problems. --- classes/Memcached_DataObject.php | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index d8b0db5a6..644b84d5c 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -23,20 +23,6 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; class Memcached_DataObject extends DB_DataObject { - /** - * Destructor to free global memory resources associated with - * this data object when it's unset or goes out of scope. - * DB_DataObject doesn't do this yet by itself. - */ - - function __destruct() - { - $this->free(); - if (method_exists('DB_DataObject', '__destruct')) { - parent::__destruct(); - } - } - function &staticGet($cls, $k, $v=null) { if (is_null($v)) { -- cgit v1.2.3-54-g00ecf From 79c2e3f7202aa652414df885bd4c917a316ea7f3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 1 Jan 2010 11:27:13 -1000 Subject: Revert "add cleanup method to cleanup a single row" This reverts commit b0527801d9c2b84408bbfdf82bbdc5b778f72cfc. --- classes/Memcached_DataObject.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index cf7fb4340..f51133508 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -253,18 +253,6 @@ class Memcached_DataObject extends DB_DataObject return new ArrayWrapper($cached); } - function cleanup() - { - global $_DB_DATAOBJECT; - - if (isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) { - unset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]); - } - if (isset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid])) { - unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]); - } - } - // We overload so that 'SET NAMES "utf8"' is called for // each connection -- cgit v1.2.3-54-g00ecf From 52fbd101629b59f279195d0b11c7775b8aa4637f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 2 Jan 2010 08:36:47 -1000 Subject: incorrectly used empty() instead of isset() for a variable that could be 0 --- classes/Notice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index 0bb3b861c..93e94230d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -214,7 +214,7 @@ class Notice extends Memcached_DataObject extract($options); } - if (empty($is_local)) { + if (!isset($is_local)) { $is_local = Notice::LOCAL_PUBLIC; } -- cgit v1.2.3-54-g00ecf From 2bd32dfad73d1387353199e5f45d02a9c5d770e5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 2 Jan 2010 16:21:19 -1000 Subject: change harmless check of to check of in Memcached_DataObject --- classes/Memcached_DataObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index bf61b0766..ad8876ff9 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -99,7 +99,7 @@ class Memcached_DataObject extends DB_DataObject } static function cacheKey($cls, $k, $v) { - if (is_object($cls) || is_object($j) || is_object($v)) { + if (is_object($cls) || is_object($k) || is_object($v)) { $e = new Exception(); common_log(LOG_ERR, __METHOD__ . ' object in param: ' . str_replace("\n", " ", $e->getTraceAsString())); -- cgit v1.2.3-54-g00ecf From d32fb7c7c40e3d5fa67496d5df0574fc9c2e0151 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 2 Jan 2010 16:28:46 -1000 Subject: return false from Memcached_DataObject::staticGet() on not found, like DB_DataObject --- classes/Memcached_DataObject.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index ad8876ff9..b43cb0b56 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -39,14 +39,14 @@ class Memcached_DataObject extends DB_DataObject } else { $i = DB_DataObject::factory($cls); if (empty($i)) { - return null; + return false; } $result = $i->get($k, $v); if ($result) { $i->encache(); return $i; } else { - return null; + return false; } } } -- cgit v1.2.3-54-g00ecf