summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/status_network.ini1
-rw-r--r--index.php13
-rwxr-xr-xscripts/queuedaemon.php8
-rw-r--r--scripts/settag.php84
4 files changed, 103 insertions, 3 deletions
diff --git a/classes/status_network.ini b/classes/status_network.ini
index 8123265e4..adb71cba7 100644
--- a/classes/status_network.ini
+++ b/classes/status_network.ini
@@ -11,6 +11,7 @@ theme = 2
logo = 2
created = 142
modified = 384
+tags = 34
[status_network__keys]
nickname = K
diff --git a/index.php b/index.php
index 5520d690b..605b380bf 100644
--- a/index.php
+++ b/index.php
@@ -146,7 +146,7 @@ function formatBacktraceLine($n, $line)
return $out;
}
-function checkMirror($action_obj, $args)
+function setupRW()
{
global $config;
@@ -161,6 +161,11 @@ function checkMirror($action_obj, $args)
foreach ($alwaysRW as $table) {
$config['db']['table_'.$table] = 'rw';
}
+}
+
+function checkMirror($action_obj, $args)
+{
+ global $config;
if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) {
if (is_array(common_config('db', 'mirror'))) {
@@ -237,9 +242,13 @@ function main()
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
+ // Make sure RW database is setup
+
+ setupRW();
+
// XXX: we need a little more structure in this script
- // get and cache current user
+ // get and cache current user (may hit RW!)
$user = common_current_user();
diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php
index c2e2351c3..30a8a9602 100755
--- a/scripts/queuedaemon.php
+++ b/scripts/queuedaemon.php
@@ -109,7 +109,13 @@ class QueueDaemon extends SpawningDaemon
$master = new QueueMaster($this->get_id());
$master->init($this->all);
- $master->service();
+ try {
+ $master->service();
+ } catch (Exception $e) {
+ common_log(LOG_ERR, "Unhandled exception: " . $e->getMessage() . ' ' .
+ str_replace("\n", " ", $e->getTraceAsString()));
+ return self::EXIT_ERR;
+ }
$this->log(LOG_INFO, 'finished servicing the queue');
diff --git a/scripts/settag.php b/scripts/settag.php
new file mode 100644
index 000000000..e91d5eb50
--- /dev/null
+++ b/scripts/settag.php
@@ -0,0 +1,84 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$shortoptions = 'd';
+$longoptions = array('delete');
+
+$helptext = <<<END_OF_SETTAG_HELP
+settag.php [options] <site> <tag>
+Set the tag <tag> for site <site>.
+
+With -d, delete the tag.
+
+END_OF_SETTAG_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+if (count($args) != 2) {
+ show_help();
+ exit(1);
+}
+
+$nickname = $args[0];
+$tag = strtolower($args[1]);
+
+$sn = Status_network::memGet('nickname', $nickname);
+
+if (empty($sn)) {
+ print "No such site.\n";
+ exit(-1);
+}
+
+$tags = $sn->getTags();
+
+$i = array_search($tag, $tags);
+
+if ($i !== false) {
+ if (have_option('d', 'delete')) { // Delete
+ unset($tags[$i]);
+
+ $orig = clone($sn);
+ $sn->tags = implode('|', $tags);
+ $result = $sn->update($orig);
+ if (!$result) {
+ print "Couldn't update.\n";
+ exit(-1);
+ }
+ } else {
+ print "Already set.\n";
+ exit(-1);
+ }
+} else {
+ if (have_option('d', 'delete')) { // Delete
+ print "No such tag.\n";
+ exit(-1);
+ } else {
+ $tags[] = $tag;
+ $orig = clone($sn);
+ $sn->tags = implode('|', $tags);
+ $result = $sn->update($orig);
+ if (!$result) {
+ print "Couldn't update.\n";
+ exit(-1);
+ }
+ }
+}