public function processPostCollection(array $context, array $collection, $indentLevel = 0)
 {
     $indent = str_repeat(':', $indentLevel);
     $output = '';
     foreach ($collection as $postId) {
         $revisionId = reset($context['posts'][$postId]);
         $revision = $context['revisions'][$revisionId];
         // Skip moderated posts
         if ($revision['isModerated']) {
             continue;
         }
         $user = User::newFromName($revision['author']['name'], false);
         $postId = Flow\Model\UUID::create($postId);
         $content = $revision['content']['content'];
         $contentFormat = $revision['content']['format'];
         if ($contentFormat !== 'wikitext') {
             $content = Utils::convert($contentFormat, 'wikitext', $content, $this->pageTitle);
         }
         $thisPost = $indent . trim($content) . ' ' . $this->getSignature($user, $postId->getTimestamp()) . "\n";
         if ($indentLevel > 0) {
             $thisPost = preg_replace("/\n+/", "\n", $thisPost);
         }
         $output .= str_replace("\n", "\n{$indent}", trim($thisPost)) . "\n";
         if (isset($revision['replies'])) {
             $output .= $this->processPostCollection($context, $revision['replies'], $indentLevel + 1);
         }
         if ($indentLevel == 0) {
             $output .= "\n";
         }
     }
     return $output;
 }
foreach ($it as $batch) {
    foreach ($batch as $rev) {
        $item = ExternalStore::fetchFromURL($rev->rev_content);
        if ($item) {
            // contains valid data
            continue;
        }
        $changeType = $rev->rev_change_type;
        while (is_string($wgFlowActions[$changeType])) {
            $changeType = $wgFlowActions[$changeType];
        }
        if (!in_array($changeType, $moderationChangeTypes)) {
            // doesn't inherit content
            continue;
        }
        $uuid = Flow\Model\UUID::create($rev->rev_id);
        echo "\n********************\n\nProcessing revision " . $uuid->getAlphadecimal() . "\n";
        ++$totalNullContentWithParent;
        $res = iterator_to_array($dbr->select('flow_revision', array('rev_content', 'rev_flags'), array('rev_id' => new \Flow\Model\UUIDBlob($rev->rev_parent_id)), __FILE__));
        // not likely ... but lets be careful
        if (!$res) {
            echo "No parent found?\n";
            $totalBadQueryResult++;
            continue;
        } elseif (count($res) > 1) {
            echo "Multiple parents found?\n";
            $totalBadQueryResult++;
            continue;
        }
        $parent = reset($res);
        $parentItem = ExternalStore::fetchFromURL($parent->rev_content);
<?php

require_once "{$IP}/maintenance/commandLine.inc";
require_once "{$IP}/extensions/Flow/FlowActions.php";
if (!isset($argv[1])) {
    die("Usage: {$argv[0]} <csv>\n\n");
}
if (!is_file($argv[1])) {
    die('Provided CSV file does not exist');
}
$csv = fopen($argv[1], "r");
if (fgetcsv($csv) !== array('uuid', 'esurl', 'flags')) {
    die('Provided CSV file does not have the expected header');
}
$fixed = 0;
$dbw = Flow\Container::get('db.factory')->getDB(DB_MASTER);
while ($row = fgetcsv($csv)) {
    if (count($row) !== 3) {
        var_dump($row);
        die('All rows in CSV file must have 2 entries');
    }
    list($uuid, $esUrl, $flags) = $row;
    if (!$uuid || !$esUrl || !$flags) {
        var_dump($row);
        die('All rows in CSV file must have a uuid, flags and an external store url');
    }
    $uuid = Flow\Model\UUID::create($uuid);
    $dbw->update('flow_revision', array('rev_content' => $esUrl, 'rev_flags' => $flags), array('rev_id' => $uuid->getBinary()));
    ++$fixed;
}
echo "Updated {$fixed} revisions\n\n";