summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2010-02-10 11:09:03 +0000
committerSarven Capadisli <csarven@status.net>2010-02-10 11:09:03 +0000
commit3d0bc1a3dd16826bf89286f37aa3778e93a34b6b (patch)
tree917cbd6dde0d9b47497def39e9dcf12e5433e544 /lib
parentf3c2dfacf4b3b1ce44edcb82d8e76e75e2b7c9fa (diff)
parente8428d1d525677fa116236735a43e7b49e8a3fd3 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php1
-rw-r--r--lib/cache.php4
-rw-r--r--lib/error.php10
-rw-r--r--lib/httpclient.php5
-rw-r--r--lib/mysqlschema.php1
-rw-r--r--lib/right.php1
-rw-r--r--lib/statusnet.php11
-rw-r--r--lib/util.php3
8 files changed, 32 insertions, 4 deletions
diff --git a/lib/api.php b/lib/api.php
index 7d94eaee4..b987badc0 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -77,6 +77,7 @@ class ApiAction extends Action
function prepare($args)
{
+ StatusNet::setApi(true); // reduce exception reports to aid in debugging
parent::prepare($args);
$this->format = $this->arg('format');
diff --git a/lib/cache.php b/lib/cache.php
index 635c96ad4..df6fc3649 100644
--- a/lib/cache.php
+++ b/lib/cache.php
@@ -47,6 +47,8 @@ class Cache
var $_items = array();
static $_inst = null;
+ const COMPRESSED = 1;
+
/**
* Singleton constructor
*
@@ -133,7 +135,7 @@ class Cache
*
* @param string $key The key to use for lookups
* @param string $value The value to store
- * @param integer $flag Flags to use, mostly ignored
+ * @param integer $flag Flags to use, may include Cache::COMPRESSED
* @param integer $expiry Expiry value, mostly ignored
*
* @return boolean success flag
diff --git a/lib/error.php b/lib/error.php
index 87a4d913b..a6a29119f 100644
--- a/lib/error.php
+++ b/lib/error.php
@@ -56,6 +56,7 @@ class ErrorAction extends Action
$this->code = $code;
$this->message = $message;
+ $this->minimal = StatusNet::isApi();
// XXX: hack alert: usually we aren't going to
// call this page directly, but because it's
@@ -102,7 +103,14 @@ class ErrorAction extends Action
function showPage()
{
- parent::showPage();
+ if ($this->minimal) {
+ // Even more minimal -- we're in a machine API
+ // and don't want to flood the output.
+ $this->extraHeaders();
+ $this->showContent();
+ } else {
+ parent::showPage();
+ }
// We don't want to have any more output after this
exit();
diff --git a/lib/httpclient.php b/lib/httpclient.php
index 3f8262076..4c3af8d7d 100644
--- a/lib/httpclient.php
+++ b/lib/httpclient.php
@@ -81,12 +81,13 @@ class HTTPResponse extends HTTP_Request2_Response
}
/**
- * Check if the response is OK, generally a 200 status code.
+ * Check if the response is OK, generally a 200 or other 2xx status code.
* @return bool
*/
function isOk()
{
- return ($this->getStatus() == 200);
+ $status = $this->getStatus();
+ return ($status >= 200 && $status < 300);
}
}
diff --git a/lib/mysqlschema.php b/lib/mysqlschema.php
index 1f7c3d092..485096ac4 100644
--- a/lib/mysqlschema.php
+++ b/lib/mysqlschema.php
@@ -213,6 +213,7 @@ class MysqlSchema extends Schema
$sql .= "); ";
+ common_log(LOG_INFO, $sql);
$res = $this->conn->query($sql);
if (PEAR::isError($res)) {
diff --git a/lib/right.php b/lib/right.php
index 5e66eae0e..4e9c5a918 100644
--- a/lib/right.php
+++ b/lib/right.php
@@ -57,5 +57,6 @@ class Right
const EMAILONREPLY = 'emailonreply';
const EMAILONSUBSCRIBE = 'emailonsubscribe';
const EMAILONFAVE = 'emailonfave';
+ const MAKEGROUPADMIN = 'makegroupadmin';
}
diff --git a/lib/statusnet.php b/lib/statusnet.php
index beeb26ccc..4f82fdaa6 100644
--- a/lib/statusnet.php
+++ b/lib/statusnet.php
@@ -30,6 +30,7 @@ global $config, $_server, $_path;
class StatusNet
{
protected static $have_config;
+ protected static $is_api;
/**
* Configure and instantiate a plugin into the current configuration.
@@ -147,6 +148,16 @@ class StatusNet
return self::$have_config;
}
+ public function isApi()
+ {
+ return self::$is_api;
+ }
+
+ public function setApi($mode)
+ {
+ self::$is_api = $mode;
+ }
+
/**
* Build default configuration array
* @return array
diff --git a/lib/util.php b/lib/util.php
index 9e8ac26ad..879834a3d 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -658,6 +658,9 @@ function common_valid_profile_tag($str)
function common_at_link($sender_id, $nickname)
{
$sender = Profile::staticGet($sender_id);
+ if (!$sender) {
+ return $nickname;
+ }
$recipient = common_relative_profile($sender, common_canonical_nickname($nickname));
if ($recipient) {
$user = User::staticGet('id', $recipient->id);