#!/usr/bin/env php . */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'x::'; $longoptions = array('extensions='); $helptext = << $def) { $schemaUpdater->register($table, $def); } $schemaUpdater->checkSchema(); printfnq("DONE.\n"); } function updateSchemaPlugins() { printfnq("Upgrading plugin schema..."); Event::handle('CheckSchema'); printfnq("DONE.\n"); } function fixupNoticeRendered() { 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); } printfnq("DONE.\n"); } function fixupNoticeConversation() { printfnq("Ensuring all notices have a conversation ID..."); $notice = new Notice(); $notice->whereAdd('conversation is null'); $notice->orderBy('id'); // try to get originals before replies $notice->find(); while ($notice->fetch()) { try { $cid = null; $orig = clone($notice); if (empty($notice->reply_to)) { $notice->conversation = $notice->id; } else { $reply = Notice::staticGet('id', $notice->reply_to); if (empty($reply)) { $notice->conversation = $notice->id; } else if (empty($reply->conversation)) { $notice->conversation = $notice->id; } else { $notice->conversation = $reply->conversation; } unset($reply); $reply = null; } $result = $notice->update($orig); $orig = null; unset($orig); } catch (Exception $e) { printv("Error setting conversation: " . $e->getMessage()); } } printfnq("DONE.\n"); } main();