From 7065450f03078fb1ac2105b75f9c7a4e052bca9c Mon Sep 17 00:00:00 2001 From: James Walker Date: Tue, 20 Jul 2010 17:34:58 -0700 Subject: normalizing tags for status_network --- scripts/settag.php | 12 +++--------- scripts/setup_status_network.sh | 6 ++++-- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/settag.php b/scripts/settag.php index d1b06ff10..ca260f7bf 100644 --- a/scripts/settag.php +++ b/scripts/settag.php @@ -39,11 +39,10 @@ if (count($args) < 1) { } $nickname = $args[0]; - $sn = Status_network::memGet('nickname', $nickname); if (empty($sn)) { - print "No such site.\n"; + print "No such site ($nickname).\n"; exit(-1); } @@ -54,16 +53,13 @@ if (count($args) == 1) { exit(0); } $tag = $args[1]; - $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); + $result = $sn->setTags($tags); if (!$result) { print "Couldn't update.\n"; exit(-1); @@ -78,9 +74,7 @@ if ($i !== false) { exit(-1); } else { $tags[] = $tag; - $orig = clone($sn); - $sn->tags = implode('|', $tags); - $result = $sn->update($orig); + $result = $sn->setTags($tags); if (!$result) { print "Couldn't update.\n"; exit(-1); diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh index 4ebb696c7..3dd739030 100755 --- a/scripts/setup_status_network.sh +++ b/scripts/setup_status_network.sh @@ -44,8 +44,8 @@ mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS GRANT ALL ON $database.* TO '$username'@'localhost' IDENTIFIED BY '$password'; GRANT ALL ON $database.* TO '$username'@'%' IDENTIFIED BY '$password'; -INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created, tags) -VALUES ('$nickname', '$DBHOSTNAME', '$username', '$password', '$database', '$sitename', now(), '$tags'); +INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created) +VALUES ('$nickname', '$DBHOSTNAME', '$username', '$password', '$database', '$sitename', now()); ENDOFCOMMANDS @@ -56,6 +56,8 @@ done php $PHPBASE/scripts/checkschema.php -s"$server" +php $PHPBASE/scripts/settag.php -s"$server" "$nickname" "$tags" + php $PHPBASE/scripts/registeruser.php \ -s"$server" \ -n"$nickname" \ -- cgit v1.2.3 From dd7647aa9538abdc24edf9c89b8e563bbdbb519e Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 28 Jul 2010 11:49:09 -0400 Subject: script to normalize status_network tags --- scripts/fixup_status_network.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/fixup_status_network.php (limited to 'scripts') diff --git a/scripts/fixup_status_network.php b/scripts/fixup_status_network.php new file mode 100644 index 000000000..dae492a86 --- /dev/null +++ b/scripts/fixup_status_network.php @@ -0,0 +1,32 @@ +#!/usr/bin/env php +. + */ + +print "BEGIN\n"; +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +require_once INSTALLDIR.'/scripts/commandline.inc'; + +common_log(LOG_INFO, 'Beginning conversion...'); + +$sn = new Status_network(); +$sn->find(); +while ($sn->fetch()) { + $sn->setTags(explode('|', $sn->tags)); +} -- cgit v1.2.3 From 5daa5bc2af4bb6a56bcd71e8da01115200864ecd Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 28 Jul 2010 12:04:37 -0400 Subject: try/catch just in case.. --- scripts/fixup_status_network.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/fixup_status_network.php b/scripts/fixup_status_network.php index dae492a86..def1eaa88 100644 --- a/scripts/fixup_status_network.php +++ b/scripts/fixup_status_network.php @@ -18,15 +18,20 @@ * along with this program. If not, see . */ -print "BEGIN\n"; define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); require_once INSTALLDIR.'/scripts/commandline.inc'; -common_log(LOG_INFO, 'Beginning conversion...'); +common_log(LOG_INFO, 'Beginning status_network conversion...'); $sn = new Status_network(); $sn->find(); while ($sn->fetch()) { - $sn->setTags(explode('|', $sn->tags)); + try { + $sn->setTags(explode('|', $sn->tags)); + } catch (Exception $e) { + common_log(LOG_ERR, $e->getMessage()); + } } + +common_log(LOG_INFO, 'Completed status_network conversion...'); -- cgit v1.2.3