diff --git a/scripts/fixup_group_uri.php b/scripts/fixup_group_uri.php deleted file mode 100644 index 90938dac3e..0000000000 --- a/scripts/fixup_group_uri.php +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env php -. - */ - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); - -$shortoptions = 'i:n:a'; -$longoptions = array('id=', 'nickname=', 'all', 'dry-run'); - -$helptext = <<whereAdd('uri IS NULL'); - if ($group->find()) { - while ($group->fetch()) { - updateGroupUri($group); - } - } - } else { - show_help(); - exit(1); - } -} catch (Exception $e) { - print $e->getMessage()."\n"; - exit(1); -} - -function updateGroupUri($group) -{ - if (!have_option('q', 'quiet')) { - print "Updating URI for group '".$group->nickname."' (".$group->id.")..."; - } - - if (empty($group->uri)) { - // Using clone here was screwing up the group->find() iteration - $orig = User_group::staticGet('id', $group->id); - - $group->uri = $group->getUri(); - if (have_option('dry_run')) { - echo " would have set $group->uri "; - } else { - if (!$group->update($orig)) { - throw new Exception("Can't update uri for group " . $group->nickname . "."); - } - echo " set $group->uri "; - } - } else { - print " already set, keeping $group->uri "; - } - - if (have_option('v', 'verbose')) { - print "DONE."; - } - if (!have_option('q', 'quiet') || have_option('v', 'verbose')) { - print "\n"; - } -} diff --git a/scripts/upgrade.php b/scripts/upgrade.php index ab1d29e417..6878d0e52d 100755 --- a/scripts/upgrade.php +++ b/scripts/upgrade.php @@ -40,6 +40,7 @@ function main() fixupNoticeRendered(); fixupNoticeConversation(); + fixupGroupURI(); } function tableDefs() @@ -134,4 +135,22 @@ function fixupNoticeConversation() printfnq("DONE.\n"); } +function fixupGroupURI() +{ + printfnq("Ensuring all groups have an URI..."); + + $group = new User_group(); + $group->whereAdd('uri IS NULL'); + + if ($group->find()) { + while ($group->fetch()) { + $orig = User_group::staticGet('id', $group->id); + $group->uri = $group->getUri(); + $group->update($orig); + } + } + + printfnq("DONE.\n"); +} + main();