require_once '../commandLine.inc';
    require_once 'ExternalStoreDB.php';
    require_once 'resolveStubs.php';
    $fname = 'moveToExternal';
    if (!isset($args[0])) {
        print "Usage: php moveToExternal.php [-m <maxid>] <cluster>\n";
        exit;
    }
    $cluster = $args[0];
    $dbw =& wfGetDB(DB_MASTER);
    if (isset($options['m'])) {
        $maxID = $options['m'];
    } else {
        $maxID = $dbw->selectField('text', 'MAX(old_id)', false, $fname);
    }
    moveToExternal($cluster, $maxID);
}
function moveToExternal($cluster, $maxID)
{
    $fname = 'moveToExternal';
    $dbw =& wfGetDB(DB_MASTER);
    print "Moving {$maxID} text rows to external storage\n";
    $ext = new ExternalStoreDB();
    for ($id = 1; $id <= $maxID; $id++) {
        if (!($id % REPORTING_INTERVAL)) {
            print "{$id}\n";
            wfWaitForSlaves(5);
        }
        $row = $dbw->selectRow('text', array('old_flags', 'old_text'), array('old_id' => $id, "old_flags NOT LIKE '%external%'"), $fname);
        if (!$row) {
            # Non-existent or already done
Beispiel #2
0
<?php

ini_set("include_path", dirname(__FILE__) . "/../");
if (!defined('MEDIAWIKI')) {
    require_once dirname(__FILE__) . '/../commandLine.inc';
    require_once 'ExternalStoreDB.php';
    moveToExternal();
}
function moveToExternal()
{
    $fname = __METHOD__;
    $dbw = wfGetDB(DB_MASTER);
    $dbr = wfGetDB(DB_SLAVE);
    $ext = new ExternalStoreDB();
    $numMoved = 0;
    $numStubs = 0;
    $res = $dbr->query("SELECT * FROM revision r1 FORCE INDEX (PRIMARY), text t2\n\t\tWHERE old_id = rev_text_id\n\t\tAND old_flags LIKE '%external%'\n\t\tORDER BY rev_timestamp, rev_id", $fname);
    $ext = new ExternalStoreDB();
    while ($row = $dbr->fetchObject($res)) {
        $url = $row->old_text;
        $id = $row->old_id;
        /**
         * do the trick with spliiting string and rejoining without external
         * flag
         */
        $flags = explode(",", $row->old_flags);
        $ftmp = array();
        foreach ($flags as $f) {
            $f = trim($f);
            if ($f === "external") {
                continue;