From 196be4e6fb65e294f31b7599818e9aa2d13baa81 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 7 Sep 2011 12:10:26 -0400 Subject: [PATCH] move notices-rendered code into upgrade script --- scripts/fixup_notices_rendered.php | 51 ------------------ scripts/upgrade.php | 86 ++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 51 deletions(-) delete mode 100755 scripts/fixup_notices_rendered.php create mode 100755 scripts/upgrade.php diff --git a/scripts/fixup_notices_rendered.php b/scripts/fixup_notices_rendered.php deleted file mode 100755 index cfbdc7479b..0000000000 --- a/scripts/fixup_notices_rendered.php +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env php -. - */ - -// Abort if called from a web server -if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { - print "This script must be run from the command line\n"; - exit(); -} - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); -define('LACONICA', true); // compatibility - -require_once(INSTALLDIR . '/lib/common.php'); - -common_log(LOG_INFO, 'Starting to render old notices.'); - -$start_at = ($argc > 1) ? $argv[1] : null; - -$notice = new Notice(); -if ($start_at) { - $notice->whereAdd('id >= ' . $start_at); -} -$cnt = $notice->find(); - -while ($notice->fetch()) { - common_log(LOG_INFO, 'Pre-rendering notice #' . $notice->id); - $original = clone($notice); - $notice->rendered = common_render_content($notice->content, $notice); - $result = $notice->update($original); - if (!$result) { - common_log_db_error($notice, 'UPDATE', __FILE__); - } -} diff --git a/scripts/upgrade.php b/scripts/upgrade.php new file mode 100755 index 0000000000..2c34ae0e47 --- /dev/null +++ b/scripts/upgrade.php @@ -0,0 +1,86 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'x::'; +$longoptions = array('extensions='); + +$helptext = << $def) { + $schemaUpdater->register($table, $def); + } + $schemaUpdater->checkSchema(); +} + +function updateSchemaPlugins() +{ + printfnq("Upgrading plugin schema"); + + Event::handle('CheckSchema'); +} + +function fixupNoticesRendered() +{ + printfnq("Ensuring all notices have rendered HTML"); + + $notice = new Notice(); + + $notice->whereAdd('rendered IS NULL'); + $notice->find(); + + while ($notice->fetch()) { + $original = clone($notice); + $notice->rendered = common_render_content($notice->content, $notice); + $notice->update($original); + } +} + +main(); -- 2.39.5