}
    }
    //add this page's data into the batch to be processed later
    $batches[] = "('{$articleData->page_id}', '{$monthCount}', '{$yesterdayCount}', '{$now}')";
    $articleCount++;
    if ($articleCount % BATCHSIZE == 0) {
        $dbw = wfGetDB(DB_MASTER);
        $batchNum = $articleCount / BATCHSIZE;
        $output = $batchNum % 100 == 0;
        processBatch($dbw, $batches, $sqlStart, $sqlEnd, $articleCount, $output);
        usleep(500000);
    }
}
$dbw = wfGetDB(DB_MASTER);
//see if there are any batches left to process
processBatch($dbw, $batches, $sqlStart, $sqlEnd, $articleCount);
$endTime = microtime(true);
echo "Finished " . __FILE__ . " in " . round($endTime - $startTime) . "s\n";
function processBatch(&$dbw, &$batches, $sqlStart, $sqlEnd, $articleCount, $output = true)
{
    $sql = $sqlStart . join(",", $batches) . $sqlEnd;
    $batchNum = $articleCount / BATCHSIZE;
    if ($output) {
        echo "Starting batch #" . $batchNum . " at " . date("r") . "\n";
    }
    try {
        $success = $dbw->query($sql, __METHOD__);
    } catch (Exception $e) {
        print "Exception at " . date("r") . "\n";
        print "PHP memory usage: " . memory_get_usage() . "\n";
        $query = "show processlist";
Example #2
0
/*****************************************************************************
 * The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
 * Version 1.1 ("License"); You may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://opensource.org/licenses/rpl.php. Software distributed under the
 * License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
 * either express or implied.
 *
 * @author:  Mr. Milk (aka Marcelo Leite)
 * @email:   mrmilk@anysoft.com.br
 * @version: 0.9 beta
 * @date:    2007-07-07
 *
 *****************************************************************************/
processBatch();
function parseFile($download = false, $config)
{
    $code = "";
    $stylist = new phpStylist();
    if (!isset($config->file) || $config->file == "") {
        return false;
    }
    $code = loadFile($config->file);
    if (isset($config->iso8859)) {
        $code = utf8_encode($code);
    }
    if (!empty($code)) {
        $stylist->options = $config;
        if (isset($config->indent_with_tabs) && $config->indent_with_tabs) {
            $stylist->indent_char = "\t";