summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-06 12:44:19 -0800
committerBrion Vibber <brion@pobox.com>2010-12-06 12:44:19 -0800
commit2617c40e048aee071b72b4b5f664fab36e6c632d (patch)
tree3cf44db45e87eefe00a3e2de0993394dc6620986
parent89f5dd4c182e470f063c760daf59b858cd92f9bf (diff)
parent76f3dc32e0e1aa933931b7cc59030ae20bb4f89b (diff)
Merge branch 'master' of gitorious.org:statusnet/mainline into 0.9.x
Conflicts: classes/User.php
-rw-r--r--classes/User.php32
-rw-r--r--lib/router.php3
-rw-r--r--lib/util.php4
3 files changed, 35 insertions, 4 deletions
diff --git a/classes/User.php b/classes/User.php
index 041c64c38..8a3190cbf 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -929,6 +929,38 @@ class User extends Memcached_DataObject
}
/**
+ * This is kind of a hack for using external setup code that's trying to
+ * build single-user sites.
+ *
+ * Will still return a username if the config singleuser/nickname is set
+ * even if the account doesn't exist, which normally indicates that the
+ * site is horribly misconfigured.
+ *
+ * At the moment, we need to let it through so that router setup can
+ * complete, otherwise we won't be able to create the account.
+ *
+ * This will be easier when we can more easily create the account and
+ * *then* switch the site to 1user mode without jumping through hoops.
+ *
+ * @return string
+ * @throws ServerException if no valid single user account is present
+ * @throws ServerException if called when not in single-user mode
+ */
+ static function singleUserNickname()
+ {
+ try {
+ $user = User::singleUser();
+ return $user->nickname;
+ } catch (Exception $e) {
+ if (common_config('singleuser', 'enabled') && common_config('singleuser', 'nickname')) {
+ common_log(LOG_WARN, "Warning: code attempting to pull single-user nickname when the account does not exist. If this is not setup time, this is probably a bug.");
+ return common_config('singleuser', 'nickname');
+ }
+ throw $e;
+ }
+ }
+
+ /**
* Find and shorten links in the given text using this user's URL shortening
* settings.
*
diff --git a/lib/router.php b/lib/router.php
index a0ea996ec..8670519ff 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -798,8 +798,7 @@ class Router
if (common_config('singleuser', 'enabled')) {
- $user = User::singleUser();
- $nickname = $user->nickname;
+ $nickname = User::singleUserNickname();
foreach (array('subscriptions', 'subscribers',
'all', 'foaf', 'xrds',
diff --git a/lib/util.php b/lib/util.php
index 26b20b5e1..da36121ff 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1075,9 +1075,9 @@ function common_tag_link($tag)
$canonical = common_canonical_tag($tag);
if (common_config('singleuser', 'enabled')) {
// regular TagAction isn't set up in 1user mode
- $user = User::singleUser();
+ $nickname = User::singleUserNickname();
$url = common_local_url('showstream',
- array('nickname' => $user->nickname,
+ array('nickname' => $nickname,
'tag' => $canonical));
} else {
$url = common_local_url('tag', array('tag' => $canonical));