summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2010-01-31 23:42:19 +0100
committerSarven Capadisli <csarven@status.net>2010-01-31 23:42:19 +0100
commit7558e2fd61c527b31b5a49d29a59b6b0b1d6d542 (patch)
tree4f71863c12f8b20b261dad09496f65ca872f5712 /lib
parent4d0ee6a41f3cfb2e99dcb92e7b14f3183393f1a5 (diff)
parent81087e45c5b797028e90181459e4c673cd7be278 (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php2
-rw-r--r--lib/default.php4
-rw-r--r--lib/distribqueuehandler.php55
-rw-r--r--lib/jabber.php4
-rw-r--r--lib/jabberqueuehandler.php2
-rw-r--r--lib/mysqlschema.php (renamed from lib/schema.mysql.php)0
-rw-r--r--lib/ombqueuehandler.php2
-rw-r--r--lib/pgsqlschema.php (renamed from lib/schema.pgsql.php)0
-rw-r--r--lib/publicqueuehandler.php2
-rw-r--r--lib/router.php22
-rw-r--r--lib/schema.php8
-rw-r--r--lib/stompqueuemanager.php21
12 files changed, 94 insertions, 28 deletions
diff --git a/lib/api.php b/lib/api.php
index 794b14050..10a2fae28 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -298,7 +298,7 @@ class ApiAction extends Action
}
}
- if ($include_user) {
+ if ($include_user && $profile) {
# Don't get notice (recursive!)
$twitter_user = $this->twitterUserArray($profile, false);
$twitter_status['user'] = $twitter_user;
diff --git a/lib/default.php b/lib/default.php
index 1337a9633..2bedc4bf0 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -270,4 +270,8 @@ $default =
'singleuser' =>
array('enabled' => false,
'nickname' => null),
+ 'robotstxt' =>
+ array('crawldelay' => 0,
+ 'disallow' => array('main', 'settings', 'admin', 'search', 'message')
+ ),
);
diff --git a/lib/distribqueuehandler.php b/lib/distribqueuehandler.php
index f458d238d..4477468d0 100644
--- a/lib/distribqueuehandler.php
+++ b/lib/distribqueuehandler.php
@@ -62,23 +62,60 @@ class DistribQueueHandler
{
// XXX: do we need to change this for remote users?
- $notice->saveTags();
+ try {
+ $notice->saveTags();
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
- $groups = $notice->saveGroups();
+ try {
+ $groups = $notice->saveGroups();
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
- $recipients = $notice->saveReplies();
+ try {
+ $recipients = $notice->saveReplies();
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
- $notice->addToInboxes($groups, $recipients);
+ try {
+ $notice->addToInboxes($groups, $recipients);
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
- $notice->saveUrls();
+ try {
+ $notice->saveUrls();
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
- Event::handle('EndNoticeSave', array($notice));
+ try {
+ Event::handle('EndNoticeSave', array($notice));
+ // Enqueue for other handlers
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
- // Enqueue for other handlers
-
- common_enqueue_notice($notice);
+ try {
+ common_enqueue_notice($notice);
+ } catch (Exception $e) {
+ $this->logit($notice, $e);
+ }
return true;
}
+
+ protected function logit($notice, $e)
+ {
+ common_log(LOG_ERR, "Distrib queue exception saving notice $notice->id: " .
+ $e->getMessage() . ' ' .
+ str_replace("\n", " ", $e->getTraceAsString()));
+
+ // We'll still return true so we don't get stuck in a loop
+ // trying to run a bad insert over and over...
+ }
}
diff --git a/lib/jabber.php b/lib/jabber.php
index b6b23521b..e1bf06ba6 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -358,7 +358,7 @@ function jabber_broadcast_notice($notice)
common_log(LOG_WARNING, 'Refusing to broadcast notice with ' .
'unknown profile ' . common_log_objstring($notice),
__FILE__);
- return false;
+ return true; // not recoverable; discard.
}
$msg = jabber_format_notice($profile, $notice);
@@ -437,7 +437,7 @@ function jabber_public_notice($notice)
common_log(LOG_WARNING, 'Refusing to broadcast notice with ' .
'unknown profile ' . common_log_objstring($notice),
__FILE__);
- return false;
+ return true; // not recoverable; discard.
}
$msg = jabber_format_notice($profile, $notice);
diff --git a/lib/jabberqueuehandler.php b/lib/jabberqueuehandler.php
index 83471f2df..d6b4b7416 100644
--- a/lib/jabberqueuehandler.php
+++ b/lib/jabberqueuehandler.php
@@ -40,7 +40,7 @@ class JabberQueueHandler extends QueueHandler
try {
return jabber_broadcast_notice($notice);
} catch (XMPPHP_Exception $e) {
- $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
+ common_log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
return false;
}
}
diff --git a/lib/schema.mysql.php b/lib/mysqlschema.php
index 1f7c3d092..1f7c3d092 100644
--- a/lib/schema.mysql.php
+++ b/lib/mysqlschema.php
diff --git a/lib/ombqueuehandler.php b/lib/ombqueuehandler.php
index 24896c784..1921c2bac 100644
--- a/lib/ombqueuehandler.php
+++ b/lib/ombqueuehandler.php
@@ -39,7 +39,7 @@ class OmbQueueHandler extends QueueHandler
function handle($notice)
{
if ($this->is_remote($notice)) {
- $this->log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id);
+ common_log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id);
return true;
} else {
require_once(INSTALLDIR.'/lib/omb.php');
diff --git a/lib/schema.pgsql.php b/lib/pgsqlschema.php
index 91bc09667..91bc09667 100644
--- a/lib/schema.pgsql.php
+++ b/lib/pgsqlschema.php
diff --git a/lib/publicqueuehandler.php b/lib/publicqueuehandler.php
index c9edb8d5d..a497d1385 100644
--- a/lib/publicqueuehandler.php
+++ b/lib/publicqueuehandler.php
@@ -38,7 +38,7 @@ class PublicQueueHandler extends QueueHandler
try {
return jabber_public_notice($notice);
} catch (XMPPHP_Exception $e) {
- $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
+ common_log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
return false;
}
}
diff --git a/lib/router.php b/lib/router.php
index be9cfac0c..b046b240c 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -73,6 +73,8 @@ class Router
if (Event::handle('StartInitializeRouter', array(&$m))) {
+ $m->connect('robots.txt', array('action' => 'robotstxt'));
+
$m->connect('opensearch/people', array('action' => 'opensearch',
'type' => 'people'));
$m->connect('opensearch/notice', array('action' => 'opensearch',
@@ -649,7 +651,16 @@ class Router
if (common_config('singleuser', 'enabled')) {
- $nickname = common_config('singleuser', 'nickname');
+ $user = User::siteOwner();
+
+ if (!empty($user)) {
+ $nickname = $user->nickname;
+ } else {
+ $nickname = common_config('singleuser', 'nickname');
+ if (empty($nickname)) {
+ throw new ServerException(_("No single user defined for single-user mode."));
+ }
+ }
foreach (array('subscriptions', 'subscribers',
'all', 'foaf', 'xrds',
@@ -697,6 +708,10 @@ class Router
'nickname' => $nickname),
array('tag' => '[a-zA-Z0-9]+'));
+ $m->connect('rsd.xml',
+ array('action' => 'rsd',
+ 'nickname' => $nickname));
+
$m->connect('',
array('action' => 'showstream',
'nickname' => $nickname));
@@ -711,6 +726,7 @@ class Router
$m->connect('featured', array('action' => 'featured'));
$m->connect('favorited/', array('action' => 'favorited'));
$m->connect('favorited', array('action' => 'favorited'));
+ $m->connect('rsd.xml', array('action' => 'rsd'));
foreach (array('subscriptions', 'subscribers',
'nudge', 'all', 'foaf', 'xrds',
@@ -758,6 +774,10 @@ class Router
array('nickname' => '[a-zA-Z0-9]{1,64}'),
array('tag' => '[a-zA-Z0-9]+'));
+ $m->connect(':nickname/rsd.xml',
+ array('action' => 'rsd'),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'));
+
$m->connect(':nickname',
array('action' => 'showstream'),
array('nickname' => '[a-zA-Z0-9]{1,64}'));
diff --git a/lib/schema.php b/lib/schema.php
index 27a4deda1..137b814e0 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -77,14 +77,12 @@ class Schema
{
$type = common_config('db', 'type');
if (empty(self::$_single)) {
- include "lib/schema.{$type}.php";
- $class = $type.='Schema';
- self::$_single = new $class();
+ $schemaClass = ucfirst($type).'Schema';
+ self::$_single = new $schemaClass();
}
return self::$_single;
}
-
/**
* Gets a ColumnDef object for a single column.
*
@@ -475,7 +473,7 @@ class Schema
} else {
$sql .= ($cd->nullable) ? "null " : "not null ";
}
-
+
if (!empty($cd->auto_increment)) {
$sql .= " auto_increment ";
}
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index ec150bbb6..6730cd213 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -31,7 +31,6 @@
require_once 'Stomp.php';
require_once 'Stomp/Exception.php';
-
class StompQueueManager extends QueueManager
{
protected $servers;
@@ -41,7 +40,7 @@ class StompQueueManager extends QueueManager
protected $control;
protected $useTransactions = true;
-
+
protected $sites = array();
protected $subscriptions = array();
@@ -182,7 +181,7 @@ class StompQueueManager extends QueueManager
$this->_connect();
return $this->_doEnqueue($object, $queue, $this->defaultIdx);
}
-
+
/**
* Saves a notice object reference into the queue item table
* on the given connection.
@@ -354,7 +353,7 @@ class StompQueueManager extends QueueManager
}
return true;
}
-
+
/**
* Subscribe to all the queues we're going to need to handle...
*
@@ -459,7 +458,7 @@ class StompQueueManager extends QueueManager
if ($con) {
$this->cons[$idx] = $con;
$this->disconnect[$idx] = null;
-
+
// now we have to listen to everything...
// @fixme refactor this nicer. :P
$host = $con->getServer();
@@ -587,7 +586,15 @@ class StompQueueManager extends QueueManager
return false;
}
- $ok = $handler->handle($item);
+ // If there's an exception when handling,
+ // log the error and let it get requeued.
+
+ try {
+ $ok = $handler->handle($item);
+ } catch (Exception $e) {
+ $this->_log(LOG_ERR, "Exception on queue $queue: " . $e->getMessage());
+ $ok = false;
+ }
if (!$ok) {
$this->_log(LOG_WARNING, "Failed handling $info");
@@ -646,7 +653,7 @@ class StompQueueManager extends QueueManager
$this->begin($idx);
return $shutdown;
}
-
+
/**
* Set us up with queue subscriptions for a new site added at runtime,
* triggered by a broadcast to the 'statusnet-control' topic.