From 0333caf421308a61e5f76f334653ceeb0577c6c9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Jul 2009 10:56:46 -0400 Subject: update Piwik analytics code --- plugins/PiwikAnalyticsPlugin.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/plugins/PiwikAnalyticsPlugin.php b/plugins/PiwikAnalyticsPlugin.php index d2c52354e..dc3c7c37f 100644 --- a/plugins/PiwikAnalyticsPlugin.php +++ b/plugins/PiwikAnalyticsPlugin.php @@ -87,18 +87,25 @@ class PiwikAnalyticsPlugin extends Plugin function onEndShowScripts($action) { - $js1 = 'var pkBaseURL = (("https:" == document.location.protocol) ? "https://'. - $this->piwikroot.'" : "http://'.$this->piwikroot. - '"); document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\''. - ' type=\'text/javascript\'%3E%3C/script%3E"));'; - $js2 = 'piwik_action_name = ""; piwik_idsite = '.$this->piwikid. - '; piwik_url = pkBaseURL + "piwik.php"; piwik_log(piwik_action_name, piwik_idsite, piwik_url);'; - $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw($js1); - $action->elementEnd('script'); - $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw($js2); - $action->elementEnd('script'); + $piwikCode = << + + + + +ENDOFPIWIK; + + $action->raw($piwikCode); return true; } } \ No newline at end of file -- cgit v1.2.3-54-g00ecf From eb5679b0297738649b982dfb66af5021bb03be19 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 21 Jul 2009 11:31:34 -0700 Subject: correctly gc sessions --- classes/Session.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/classes/Session.php b/classes/Session.php index 93fd99baa..ac80279c5 100644 --- a/classes/Session.php +++ b/classes/Session.php @@ -106,14 +106,11 @@ class Session extends Memcached_DataObject { self::logdeb("garbage collection (maxlifetime = $maxlifetime)"); - $epoch = time() - $maxlifetime; - - $qry = 'DELETE FROM session ' . - 'WHERE modified < "'.$epoch.'"'; + $epoch = common_sql_date(time() - $maxlifetime); $session = new Session(); - - $result = $session->query($qry); + $session->whereAdd('modified < "'.$epoch.'"'); + $result = $session->delete(DB_DATAOBJECT_WHEREADD_ONLY); self::logdeb("garbage collection result = $result"); } -- cgit v1.2.3-54-g00ecf From 6467351e32d2fa3a838556725fbdaccfa907969d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 21 Jul 2009 12:50:32 -0700 Subject: update dbqueuemanager to respect handler timeout values --- lib/dbqueuemanager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php index 6e7172de0..a37a8ffdf 100644 --- a/lib/dbqueuemanager.php +++ b/lib/dbqueuemanager.php @@ -55,7 +55,8 @@ class DBQueueManager extends QueueManager { while (true) { $this->_log(LOG_DEBUG, 'Checking for notices...'); - $notice = $this->_nextItem($queue, null); + $timeout = $handler->timeout(); + $notice = $this->_nextItem($queue, $timeout); if (empty($notice)) { $this->_log(LOG_DEBUG, 'No notices waiting; idling.'); // Nothing in the queue. Do you -- cgit v1.2.3-54-g00ecf From 5f7fb994471e4326f6aea5e29157a6236de4001f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 23 Jul 2009 14:22:22 -0700 Subject: change NOTICE_GATEWAY to Notice::GATEWAY so autoloading works --- classes/Fave.php | 2 +- classes/Notice.php | 3 ++- classes/User.php | 2 +- scripts/twitterstatusfetcher.php | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/Fave.php b/classes/Fave.php index c3ec62dcf..d1e3b01b3 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -59,7 +59,7 @@ class Fave extends Memcached_DataObject $qry = 'SELECT fave.* FROM fave '; $qry .= 'INNER JOIN notice ON fave.notice_id = notice.id '; $qry .= 'WHERE fave.user_id = ' . $user_id . ' '; - $qry .= 'AND notice.is_local != ' . NOTICE_GATEWAY . ' '; + $qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' '; } if ($since_id != 0) { diff --git a/classes/Notice.php b/classes/Notice.php index 08125cf7b..4b9a866b0 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -32,7 +32,6 @@ define('NOTICE_CACHE_WINDOW', 61); define('NOTICE_LOCAL_PUBLIC', 1); define('NOTICE_REMOTE_OMB', 0); define('NOTICE_LOCAL_NONPUBLIC', -1); -define('NOTICE_GATEWAY', -2); define('MAX_BOXCARS', 128); @@ -63,6 +62,8 @@ class Notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + const GATEWAY = -2; + function getProfile() { return Profile::staticGet('id', $this->profile_id); diff --git a/classes/User.php b/classes/User.php index 6c1f149e4..bea47a3b0 100644 --- a/classes/User.php +++ b/classes/User.php @@ -443,7 +443,7 @@ class User extends Memcached_DataObject 'SELECT notice.* ' . 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . 'WHERE subscription.subscriber = %d ' . - 'AND notice.is_local != ' . NOTICE_GATEWAY; + 'AND notice.is_local != ' . Notice::GATEWAY; return Notice::getStream(sprintf($qry, $this->id), 'user:notices_with_friends:' . $this->id, $offset, $limit, $since_id, $before_id, diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 8b10bfbad..4a1ed8977 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -32,7 +32,7 @@ $helptext = <<rendered = common_render_content($notice->content, $notice); $notice->source = 'twitter'; $notice->reply_to = null; // XXX lookup reply - $notice->is_local = NOTICE_GATEWAY; + $notice->is_local = Notice::GATEWAY; if (Event::handle('StartNoticeSave', array(&$notice))) { $id = $notice->insert(); -- cgit v1.2.3-54-g00ecf