function main()
 {
     global $wgMemc;
     $fname = 'DeleteImageCache::main';
     ini_set('display_errors', false);
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('image', array('img_name'), array("img_timestamp < {$this->until}"), $fname);
     $i = 0;
     $total = $this->getImageCount();
     while ($row = $dbr->fetchObject($res)) {
         if ($i % $this->report == 0) {
             printf("%s: %13s done (%s)\n", wfWikiID(), "{$i}/{$total}", wfPercent($i / $total * 100));
         }
         $md5 = md5($row->img_name);
         $wgMemc->delete(wfMemcKey('Image', $md5));
         if ($this->sleep != 0) {
             usleep($this->sleep);
         }
         ++$i;
     }
 }
 public function execute()
 {
     global $wgMemc;
     $until = preg_replace("/[^\\d]/", '', $this->getOption('until'));
     $sleep = (int) $this->getOption('sleep') * 1000;
     // milliseconds
     ini_set('display_errors', false);
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('image', array('img_name'), array("img_timestamp < {$until}"), __METHOD__);
     $i = 0;
     $total = $this->getImageCount();
     foreach ($res as $row) {
         if ($i % $this->report == 0) {
             $this->output(sprintf("%s: %13s done (%s)\n", wfWikiID(), "{$i}/{$total}", wfPercent($i / $total * 100)));
         }
         $md5 = md5($row->img_name);
         $wgMemc->delete(wfMemcKey('Image', $md5));
         if ($sleep != 0) {
             usleep($sleep);
         }
         ++$i;
     }
 }
 /**
  * Make the editcount-by-namespaces HTML table
  *
  * @access private
  */
 function makeTable()
 {
     global $wgLang, $wgCityId, $wgDBname;
     wfProfileIn(__METHOD__);
     $total = wfMsgHtml('editcount_total');
     $wikiName = $wgDBname;
     /* current wiki */
     $ftotal = $wgLang->formatNum($this->total);
     $percent = $this->total > 0 ? wfPercent($this->total / $this->total * 100, 2) : wfPercent(0);
     // @bug 4400
     /* all wikis */
     $ftotalall = $wgLang->formatNum($this->totalall);
     $percentall = $this->totalall > 0 ? wfPercent($this->totalall / $this->totalall * 100, 2) : wfPercent(0);
     $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $oTmpl->set_vars(array("total" => $total, "ftotal" => $ftotal, "ftotalall" => $ftotalall, "percent" => $percent, "percentall" => $percentall, "wikiName" => $wikiName, "nscount" => $this->nscount, "nstotal" => $this->total, "nscountall" => $this->nscountall, "nstotalall" => $this->totalall, "wgLang" => $wgLang));
     $res = $oTmpl->render("table");
     wfProfileOut(__METHOD__);
     return $res;
 }
Example #4
0
    public function display($expand, $indent = 0.0)
    {
        usort($this->children, 'compare_point');
        $ex = isset($expand[$this->name()]);
        $anchor = str_replace('"', '', $this->name());
        if (!$ex) {
            if (count($this->children)) {
                $url = getEscapedProfileUrl(false, false, $expand + [$this->name() => true]);
                $extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[+]</a>";
            } else {
                $extet = '';
            }
        } else {
            $e = [];
            foreach ($expand as $name => $ep) {
                if ($name != $this->name()) {
                    $e += [$name => $ep];
                }
            }
            $url = getEscapedProfileUrl(false, false, $e);
            $extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[–]</a>";
        }
        ?>
	<tr>
		<th>
			<div style="margin-left: <?php 
        echo (int) $indent;
        ?>
em;">
				<?php 
        echo htmlspecialchars(str_replace(',', ', ', $this->name())) . $extet;
        ?>
			</div>
		</th>
		<?php 
        //@codingStandardsIgnoreStart
        ?>
		<td class="mw-profileinfo-timep"><?php 
        echo @wfPercent($this->time() / self::$totaltime * 100);
        ?>
</td>
		<td class="mw-profileinfo-memoryp"><?php 
        echo @wfPercent($this->memory() / self::$totalmemory * 100);
        ?>
</td>
		<td class="mw-profileinfo-count"><?php 
        echo $this->count();
        ?>
</td>
		<td class="mw-profileinfo-cpr"><?php 
        echo round(sprintf('%.2f', $this->callsPerRequest()), 2);
        ?>
</td>
		<td class="mw-profileinfo-tpc"><?php 
        echo round(sprintf('%.2f', $this->timePerCall()), 2);
        ?>
</td>
		<td class="mw-profileinfo-mpc"><?php 
        echo round(sprintf('%.2f', $this->memoryPerCall() / 1024), 2);
        ?>
</td>
		<td class="mw-profileinfo-tpr"><?php 
        echo @round(sprintf('%.2f', $this->time() / self::$totalcount), 2);
        ?>
</td>
		<td class="mw-profileinfo-mpr"><?php 
        echo @round(sprintf('%.2f', $this->memory() / self::$totalcount / 1024), 2);
        ?>
</td>
		<?php 
        //@codingStandardsIgnoreEnd
        ?>
	</tr>
		<?php 
        if ($ex) {
            foreach ($this->children as $child) {
                $child->display($expand, $indent + 2);
            }
        }
    }
Example #5
0
    function display($expand, $indent = 0.0)
    {
        usort($this->children, 'compare_point');
        $ex = isset($expand[$this->name()]);
        if (!$ex) {
            if (count($this->children)) {
                $url = getEscapedProfileUrl(false, false, $expand + array($this->name() => true));
                $extet = " <a href=\"{$url}\">[+]</a>";
            } else {
                $extet = '';
            }
        } else {
            $e = array();
            foreach ($expand as $name => $ep) {
                if ($name != $this->name()) {
                    $e += array($name => $ep);
                }
            }
            $extet = " <a href=\"" . getEscapedProfileUrl(false, false, $e) . "\">[–]</a>";
        }
        ?>
		<tr>
		<td class="name" style="padding-left: <?php 
        echo $indent;
        ?>
em;">
			<?php 
        echo htmlspecialchars($this->name()) . $extet;
        ?>
		</td>
		<td class="timep"><?php 
        echo @wfPercent($this->time() / self::$totaltime * 100);
        ?>
</td>
		<td class="memoryp"><?php 
        echo @wfPercent($this->memory() / self::$totalmemory * 100);
        ?>
</td>
		<td class="count"><?php 
        echo $this->count();
        ?>
</td>
		<td class="cpr"><?php 
        echo round(sprintf('%.2f', $this->callsPerRequest()), 2);
        ?>
</td>
		<td class="tpc"><?php 
        echo round(sprintf('%.2f', $this->timePerCall()), 2);
        ?>
</td>
		<td class="mpc"><?php 
        echo round(sprintf('%.2f', $this->memoryPerCall() / 1024), 2);
        ?>
</td>
		<td class="tpr"><?php 
        echo @round(sprintf('%.2f', $this->time() / self::$totalcount), 2);
        ?>
</td>
		<td class="mpr"><?php 
        echo @round(sprintf('%.2f', $this->memory() / self::$totalcount / 1024), 2);
        ?>
</td>
		</tr>
		<?php 
        if ($ex) {
            foreach ($this->children as $child) {
                $child->display($expand, $indent + 2);
            }
        }
    }
Example #6
0
 /**
  * @covers ::wfPercent
  */
 public function testWfPercentTest()
 {
     $pcts = array(array(6 / 7, '0.86%', 2, false), array(3 / 3, '1%'), array(22 / 7, '3.14286%', 5), array(3 / 6, '0.5%'), array(1 / 3, '0%', 0), array(10 / 3, '0%', -1), array(3 / 4 / 5, '0.1%', 1), array(6 / 7 * 8, '6.8571428571%', 10));
     foreach ($pcts as $pct) {
         if (!isset($pct[2])) {
             $pct[2] = 2;
         }
         if (!isset($pct[3])) {
             $pct[3] = true;
         }
         $this->assertEquals(wfPercent($pct[0], $pct[2], $pct[3]), $pct[1], $pct[1]);
     }
 }
    function display($indent = 0.0)
    {
        global $expand, $totaltime, $totalcount;
        usort($this->children, "compare_point");
        $extet = '';
        if (isset($expand[$this->name()])) {
            $ex = true;
        } else {
            $ex = false;
        }
        if (!$ex) {
            if (count($this->children)) {
                $url = makeurl(false, false, $expand + array($this->name() => true));
                $extet = " <a href=\"{$url}\">[+]</a>";
            } else {
                $extet = '';
            }
        } else {
            $e = array();
            foreach ($expand as $name => $ep) {
                if ($name != $this->name()) {
                    $e += array($name => $ep);
                }
            }
            $extet = " <a href=\"" . makeurl(false, false, $e) . "\">[&ndash;]</a>";
        }
        ?>
		<tr>
		<td class="time"><tt><?php 
        echo $this->fmttime();
        ?>
</tt></td>
		<td class="timep"><?php 
        echo wfPercent($this->time() / $totaltime * 100);
        ?>
</td>
		<td class="count"><?php 
        echo $this->count();
        ?>
</td>
		<td class="cpr"><?php 
        echo round(sprintf('%.2f', $this->count() / $totalcount), 2);
        ?>
		<td class="name" style="padding-left: <?php 
        echo $indent;
        ?>
em">
			<?php 
        echo htmlspecialchars($this->name()) . $extet;
        ?>
		</td>
		</tr>
		<?php 
        if ($ex) {
            foreach ($this->children as $child) {
                $child->display($indent + 2);
            }
        }
    }
Example #8
0
	<th class="ecrowright"><?php 
echo $percentall;
?>
</th>
</tr>
<?php 
foreach ($nscount as $ns => $edits) {
    /* current wiki */
    $fedits = $wgLang->formatNum($edits);
    $fns = $ns == NS_MAIN ? wfMsg('blanknamespace') : $wgLang->getFormattedNsText($ns);
    $percent = $edits > 0 && $nstotal > 0 ? wfPercent($edits / $nstotal * 100) : wfPercent(0);
    $fpercent = $wgLang->formatNum($percent);
    /* all wikis */
    $editsall = array_key_exists($ns, $nscountall) ? $nscountall[$ns] : 0;
    $feditsall = array_key_exists($ns, $nscountall) ? $wgLang->formatNum($nscountall[$ns]) : 0;
    $percentall = $editsall > 0 && $nstotalall > 0 ? wfPercent($editsall / $nstotalall * 100) : wfPercent(0);
    $fpercentall = $wgLang->formatNum($percentall);
    ?>
<tr>
	<td class="ecrowcenter"><?php 
    echo $fns;
    ?>
</td>
	<td class="ecrowright"><?php 
    echo $fedits;
    ?>
</td>
	<td class="ecrowright"><?php 
    echo $fpercent;
    ?>
</td>
Example #9
0
 /**
  * @covers ::wfPercent
  */
 public function testWfPercentTest()
 {
     $pcts = [[6 / 7, '0.86%', 2, false], [3 / 3, '1%'], [22 / 7, '3.14286%', 5], [3 / 6, '0.5%'], [1 / 3, '0%', 0], [10 / 3, '0%', -1], [3 / 4 / 5, '0.1%', 1], [6 / 7 * 8, '6.8571428571%', 10]];
     foreach ($pcts as $pct) {
         if (!isset($pct[2])) {
             $pct[2] = 2;
         }
         if (!isset($pct[3])) {
             $pct[3] = true;
         }
         $this->assertEquals(wfPercent($pct[0], $pct[2], $pct[3]), $pct[1], $pct[1]);
     }
 }
Example #10
0
	<td class="ecrowright" style="border-top:0; border-bottom: 0;">&nbsp;</td>
	<td class="ecrowright"><?php 
    echo $feditsall;
    ?>
</td>
	<td class="ecrowright"><?php 
    echo $fpercentall;
    ?>
</td>
</tr>
<?php 
}
if ($arcount > 0) {
    /* current wiki total number of archived revisions */
    $farcount = $wgLang->formatNum($arcount);
    $percent = $arcount > 0 && $wikitotal > 0 ? wfPercent($arcount / $wikitotal * 100) : wfPercent(0);
    $fpercent = $wgLang->formatNum($percent);
    ?>
<tr>
	<td class="ecrowcenter"><?php 
    echo wfMessage('editcount_archived_revisions')->escaped();
    ?>
</td>
	<td class="ecrowright"><?php 
    echo $farcount;
    ?>
</td>
	<td class="ecrowright"><?php 
    echo $fpercent;
    ?>
</td>
 /**
  * Make the editcount-by-namespaces HTML table
  *
  * @access private
  */
 function makeTable()
 {
     global $wgLang;
     $total = wfMsgHtml('editcount_total');
     $ftotal = $wgLang->formatNum($this->total);
     $percent = $this->total > 0 ? wfPercent($this->total / $this->total * 100, 2) : wfPercent(0);
     // @bug 4400
     $ret = "<table border='1' style='background-color: #fff; border: 1px #aaa solid; border-collapse: collapse;'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{$total}</th>\n\t\t\t\t\t<th>{$ftotal}</th>\n\t\t\t\t\t<th>{$percent}</th>\n\t\t\t\t</tr>\n\t\t";
     foreach ($this->nscount as $ns => $edits) {
         $fedits = $wgLang->formatNum($edits);
         $fns = $ns == NS_MAIN ? wfMsg('blanknamespace') : $wgLang->getFormattedNsText($ns);
         $percent = wfPercent($edits / $this->total * 100);
         $fpercent = $wgLang->formatNum($percent);
         $ret .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$fns}</td>\n\t\t\t\t\t<td>{$fedits}</td>\n\t\t\t\t\t<td>{$fpercent}</td>\n\t\t\t\t</tr>\n\t\t\t";
     }
     $ret .= "</table>\n\t\t";
     return $ret;
 }
Example #12
0
 private function reportPercentage($success, $total)
 {
     $ratio = wfPercent(100 * $success / $total);
     print $this->term->color(1) . "Passed {$success} of {$total} tests ({$ratio})";
     if ($this->skipped) {
         print ", skipped {$this->skipped}";
     }
     print "... ";
     if ($success == $total) {
         print $this->term->color(32) . "ALL TESTS PASSED!";
     } else {
         $failed = $total - $success;
         print $this->term->color(31) . "{$failed} tests failed!";
     }
     print $this->term->reset() . "\n";
     return $success == $total;
 }