fixup_hashtags.php 1.59 KB
Newer Older
1 2 3
#!/usr/bin/env php
<?php
/*
4
 * StatusNet - the distributed open-source microblogging tool
5
 * Copyright (C) 2008, 2009, StatusNet, Inc.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * 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/>.
 */

21
// Abort if called from a web server
22 23 24 25 26
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
    print "This script must be run from the command line\n";
    exit();
}

27
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
28
define('STATUSNET', true);
29
define('LACONICA', true); // compatibility
30 31 32 33 34 35 36 37 38

require_once(INSTALLDIR . '/lib/common.php');

common_log(LOG_INFO, 'Starting to do old notices.');

$notice = new Notice();
$cnt = $notice->find();

while ($notice->fetch()) {
Evan Prodromou's avatar
Evan Prodromou committed
39
    common_log(LOG_INFO, 'Getting tags for notice #' . $notice->id);
40
    $notice->saveTags();
41 42 43 44 45 46
    $original = clone($notice);
    $notice->rendered = common_render_content($notice->content, $notice);
    $result = $notice->update($original);
    if (!$result) {
        common_log_db_error($notice, 'UPDATE', __FILE__);
    }
47
}