block/unblock log; split off profiling into Profiling.php and broke it (turn it off for now)

This commit is contained in:
Tim Starling 2003-10-16 13:30:45 +00:00
parent deebd655d4
commit d8cc830c4a
13 changed files with 305 additions and 106 deletions

View file

@ -35,17 +35,18 @@ class Article {
function getContent( $noredir = false )
{
global $action,$section,$count; # From query string
wfProfileIn( "Article::getContent" );
$fname = "Article::getContent";
wfProfileIn( $fname );
if ( 0 == $this->getID() ) {
if ( "edit" == $action ) {
wfProfileOut( $fname );
return ""; # was "newarticletext", now moved above the box)
}
wfProfileOut();
wfProfileOut( $fname );
return wfMsg( "noarticletext" );
} else {
$this->loadContent( $noredir );
wfProfileOut();
if(
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
@ -54,22 +55,29 @@ class Article {
$action=="view"
)
{
wfProfileOut( $fname );
return $this->mContent . "\n" .wfMsg("anontalkpagetext"); }
else {
if($action=="edit") {
if($section!="") {
if($section=="new") { return ""; }
if($section=="new") {
wfProfileOut( $fname );
return "";
}
$secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
$this->mContent, -1,
PREG_SPLIT_DELIM_CAPTURE);
if($section==0) {
wfProfileOut( $fname );
return trim($secs[0]);
} else {
wfProfileOut( $fname );
return trim($secs[$section*2-1] . $secs[$section*2]);
}
}
}
wfProfileOut( $fname );
return $this->mContent;
}
}
@ -248,7 +256,8 @@ class Article {
global $wgUser, $wgOut, $wgLang;
global $oldid, $diff; # From query
global $wgLinkCache;
wfProfileIn( "Article::view" );
$fname = "Article::view";
wfProfileIn( $fname );
$wgOut->setArticleFlag( true );
$wgOut->setRobotpolicy( "index,follow" );
@ -260,7 +269,7 @@ class Article {
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
$de = new DifferenceEngine( $oldid, $diff );
$de->showDiffPage();
wfProfileOut();
wfProfileOut( $fname );
return;
}
$text = $this->getContent(); # May change wgTitle!
@ -287,7 +296,7 @@ class Article {
$wgOut->addWikiText( $text );
$this->viewUpdates();
wfProfileOut();
wfProfileOut( $fname );
}
# Theoretically we could defer these whole insert and update
@ -538,7 +547,8 @@ class Article {
# If page hasn't changed, client can cache this
$wgOut->checkLastModified( $this->getTimestamp() );
wfProfileIn( "Article::history" );
$fname = "Article::history";
wfProfileIn( $fname );
$wgOut->setPageTitle( $this->mTitle->getPRefixedText() );
$wgOut->setSubtitle( wfMsg( "revhistory" ) );
@ -547,7 +557,7 @@ class Article {
if( $this->mTitle->getArticleID() == 0 ) {
$wgOut->addHTML( wfMsg( "nohistory" ) );
wfProfileOut();
wfProfileOut( $fname );
return;
}
@ -567,7 +577,7 @@ class Article {
$revs = wfNumRows( $res );
if( $this->mTitle->getArticleID() == 0 ) {
$wgOut->addHTML( wfMsg( "nohistory" ) );
wfProfileOut();
wfProfileOut( $fname );
return;
}
@ -595,7 +605,7 @@ class Article {
$s .= $sk->endHistoryList();
$s .= $numbar;
$wgOut->addHTML( $s );
wfProfileOut();
wfProfileOut( $fname );
}
function protect( $limit = "sysop" )

View file

@ -140,30 +140,6 @@ function wfDebug( $text, $logonly = false )
}
}
if( !isset( $wgProfiling ) )
$wgProfiling = false;
$wgProfileStack = array();
$wgProfileWorkStack = array();
if( $wgProfiling ) {
function wfProfileIn( $functionname )
{
global $wgProfileStack, $wgProfileWorkStack;
array_push( $wgProfileWorkStack, "$functionname " .
count( $wgProfileWorkStack ) . " " . microtime() );
}
function wfProfileOut() {
global $wgProfileStack, $wgProfileWorkStack;
$bit = array_pop( $wgProfileWorkStack );
$bit .= " " . microtime();
array_push( $wgProfileStack, $bit );
}
} else {
function wfProfileIn( $functionname ) { }
function wfProfileOut( ) { }
}
function wfReadOnly()
{
global $wgReadOnlyFile;

View file

@ -79,13 +79,17 @@ class LinkCache {
if ( 0 != $id ) { return $id; }
global $wgMemc, $wgDBname;
wfProfileIn( "LinkCache::addLink-checkdatabase" );
$fname = "LinkCache::addLink-checkdatabase";
wfProfileIn( $fname );
$nt = Title::newFromDBkey( $title );
$ns = $nt->getNamespace();
$t = $nt->getDBkey();
if ( "" == $t ) { return 0; }
if ( "" == $t ) {
wfProfileOut( $fname);
return 0;
}
$id = $wgMemc->get( $key = "$wgDBname:lc:title:$title" );
if( $id === FALSE ) {
@ -103,13 +107,14 @@ class LinkCache {
}
if ( 0 == $id ) { $this->addBadLink( $title ); }
else { $this->addGoodLink( $id, $title ); }
wfProfileOut();
wfProfileOut( $fname );
return $id;
}
function preFill( $fromtitle )
{
wfProfileIn( "LinkCache::preFill" );
$fname = "LinkCache::preFill";
wfProfileIn( $fname );
# Note -- $fromtitle is a Title *object*
$dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
$sql = "SELECT HIGH_PRIORITY cur_id,cur_namespace,cur_title
@ -138,7 +143,7 @@ class LinkCache {
$this->mOldGoodLinks = $this->mGoodLinks;
$this->mPreFilled = true;
wfProfileOut();
wfProfileOut( $fname );
}
function getGoodAdditions()

View file

@ -136,7 +136,7 @@ class LinksUpdate {
$sql = "COMMIT";
wfQuery( $sql, DB_WRITE, $fname );
}
wfProfileOut();
wfProfileOut( $fname );
}
function doDumbUpdate()
@ -211,7 +211,7 @@ class LinksUpdate {
$sql = "COMMIT";
wfQuery( $sql, DB_WRITE, $fname );
}
wfProfileOut();
wfProfileOut( $fname );
}
function fixBrokenLinks() {

View file

@ -55,7 +55,6 @@ class MagicWord {
$this->mRegex = "/{$this->mBaseRegex}/{$case}";
$this->mRegexStart = "/^{$this->mBaseRegex}/{$case}";
$this->mVariableRegex = str_replace( "\\$1", "([A-Za-z0-9]*)", $this->mRegex );
wfDebug( "{$this->mVariableRegex}\n" );
}
function getRegex()

View file

@ -133,7 +133,8 @@ class OutputPage {
function addWikiText( $text, $linestart = true )
{
global $wgUseTeX;
wfProfileIn( "OutputPage::addWikiText" );
$fname = "OutputPage::addWikiText";
wfProfileIn( $fname );
$unique = "3iyZiyA7iMwg5rhxP0Dcc9oTnj8qD1jm1Sfv4";
$unique2 = "4LIQ9nXtiYFPCSfitVwDw7EYwQlL4GeeQ7qSO";
$unique3 = "fPaA8gDfdLBqzj68Yjg9Hil3qEF8JGO0uszIp";
@ -209,7 +210,7 @@ class OutputPage {
$escapedChars, $nwlist[$i] ), $text, 1 );
}
$this->addHTML( $text );
wfProfileOut();
wfProfileOut( $fname );
}
function sendCacheControl() {
@ -328,27 +329,7 @@ class OutputPage {
$elapsed = $now - $start;
if ( "" != $wgDebugLogFile ) {
$prof = "";
if( $wgProfiling and count( $wgProfileStack ) ) {
$lasttime = $start;
foreach( $wgProfileStack as $ile ) {
# "foo::bar 99 0.12345 1 0.23456 2"
if( preg_match( '/^(\S+)\s+([0-9]+)\s+([0-9\.]+)\s+([0-9\.]+)\s+([0-9\.]+)\s+([0-9\.]+)/', $ile, $m ) ) {
$thisstart = (float)$m[3] + (float)$m[4] - $start;
$thisend = (float)$m[5] + (float)$m[6] - $start;
$thiselapsed = $thisend - $thisstart;
$thispercent = $thiselapsed / $elapsed * 100.0;
$prof .= sprintf( "\tat %04.3f in %04.3f (%2.1f%%) - %s %s\n",
$thisstart, $thiselapsed, $thispercent,
str_repeat( "*", $m[2] ), $m[1] );
$lasttime = $thistime;
#$prof .= "\t(^ $ile)\n";
} else {
$prof .= "\t?broken? $ile\n";
}
}
}
$prof = wfGetProfilingOutput( $start, $elapsed );
if( $forward = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] )
$forward = " forwarded for $forward";
@ -734,7 +715,8 @@ $t[] = "</table>" ;
function doWikiPass2( $text, $linestart )
{
global $wgUser, $wgLang, $wgUseDynamicDates;
wfProfileIn( "OutputPage::doWikiPass2" );
$fname = "OutputPage::doWikiPass2";
wfProfileIn( $fname );
$text = $this->removeHTMLtags( $text );
$text = $this->replaceVariables( $text );
@ -762,7 +744,7 @@ $t[] = "</table>" ;
$text = $sk->transformContent( $text );
$text .= $this->categoryMagic () ;
wfProfileOut();
wfProfileOut( $fname );
return $text;
}
@ -840,14 +822,15 @@ $t[] = "</table>" ;
/* private */ function replaceExternalLinks( $text )
{
wfProfileIn( "OutputPage::replaceExternalLinks" );
$fname = "OutputPage::replaceExternalLinks";
wfProfileIn( $fname );
$text = $this->subReplaceExternalLinks( $text, "http", true );
$text = $this->subReplaceExternalLinks( $text, "https", true );
$text = $this->subReplaceExternalLinks( $text, "ftp", false );
$text = $this->subReplaceExternalLinks( $text, "gopher", false );
$text = $this->subReplaceExternalLinks( $text, "news", false );
$text = $this->subReplaceExternalLinks( $text, "mailto", false );
wfProfileOut();
wfProfileOut( $fname );
return $text;
}
@ -935,7 +918,7 @@ $t[] = "</table>" ;
$e1 = "/^([{$tc}]+)\\|([^]]+)]](.*)\$/sD";
$e2 = "/^([{$tc}]+)]](.*)\$/sD";
wfProfileOut();
wfProfileOut( "$fname-setup" );
foreach ( $a as $line ) {
wfProfileIn( "$fname-loop" );
@ -952,7 +935,7 @@ $t[] = "</table>" ;
else { # Invalid form; output directly
$s .= "[[" . $line ;
wfProfileOut();
wfProfileOut( "$fname-loop" );
continue;
}
if(substr($m[1],0,1)=="/") { # subpage
@ -1021,9 +1004,9 @@ $t[] = "</table>" ;
if ( "" == $text ) { $text = $link; }
$s .= $sk->makeLink( $link, $text, "", $trail );
}
wfProfileOut();
wfProfileOut( "$fname-loop" );
}
wfProfileOut();
wfProfileOut( $fname );
return $s;
}
@ -1106,7 +1089,8 @@ $t[] = "</table>" ;
/* private */ function doBlockLevels( $text, $linestart )
{
wfProfileIn( "OutputPage::doBlockLevels" );
$fname = "OutputPage::doBlockLevels";
wfProfileIn( $fname );
# Parsing through the text line by line. The main thing
# happening here is handling of block-level elements p, pre,
# and making lists from lines starting with * # : etc.
@ -1205,14 +1189,15 @@ $t[] = "</table>" ;
}
$this->mLastSection = "";
}
wfProfileOut();
wfProfileOut( $fname );
return $text;
}
/* private */ function replaceVariables( $text )
{
global $wgLang;
wfProfileIn( "OutputPage:replaceVariables" );
$fname = "OutputPage:replaceVariables";
wfProfileIn( $fname );
/* As with sigs, use server's local time --
ensure this is appropriate for your audience! */
@ -1257,13 +1242,14 @@ $t[] = "</table>" ;
$mw =& MagicWord::get( MAG_MSGNW );
$text = $mw->substituteCallback( $text, "replaceMsgVarNw" );
wfProfileOut();
wfProfileOut( $fname );
return $text;
}
/* private */ function removeHTMLtags( $text )
{
wfProfileIn( "OutputPage::removeHTMLtags" );
$fname = "OutputPage::removeHTMLtags";
wfProfileIn( $fname );
$htmlpairs = array( # Tags that must be closed
"b", "i", "u", "font", "big", "small", "sub", "sup", "h1",
"h2", "h3", "h4", "h5", "h6", "cite", "code", "em", "s",
@ -1350,7 +1336,7 @@ $t[] = "</table>" ;
$text .= "</$t>\n";
if ( $t == "table" ) { $tagstack = array_pop( $tablestack ); }
}
wfProfileOut();
wfProfileOut( $fname );
return $text;
}

179
includes/Profiling.php Executable file
View file

@ -0,0 +1,179 @@
<?
# This file is only included if profiling is enabled
$wgDebugProfiling = true;
function wfProfileIn( $functionname )
{
global $wgProfiler;
$wgProfiler->profileIn( $functionname );
}
function wfProfileOut( $functionname = "missing" )
{
global $wgProfiler;
$wgProfiler->profileOut( $functionname );
}
function wfGetProfilingOutput( $start, $elapsed ) {
global $wgProfiler;
return $wgProfiler->getOutput( $start, $elapsed );
}
function wfProfileClose()
{
global $wgProfiler;
$wgProfiler->close();
}
class Profiler
{
var $mStack = array(), $mWorkStack = array(), $mCollated = array();
var $mCalls = array(), $mTotals = array();
/*
function Profiler()
{
$this->mProfileStack = array();
$this->mWorkStack = array();
$this->mCollated = array();
}
*/
function profileIn( $functionname )
{
array_push( $this->mWorkStack, array($functionname, count( $this->mWorkStack ), microtime() ) );
}
function profileOut( $functionname)
{
global $wgDebugProfiling;
$bit = array_pop( $this->mWorkStack );
if ( $wgDebugProfiling ) {
if ( $functionname == "close" ) {
wfDebug( "Profile section ended by close(): {$bit[0]}\n" );
} elseif ( $bit[0] != $functionname ) {
wfDebug( "Profiling error: in({$bit[0]}), out($functionname)\n" );
}
}
array_push( $bit, microtime() );
array_push( $this->mStack, $bit );
}
function close()
{
while ( count( $this->mWorkStack ) ) {
$this->profileOut( "close" );
}
}
function getOutput( $scriptStart, $scriptElapsed )
{
set_time_limit( 0 );
$width = 80;
$format = "%-39s %6.2f / %6.2f = %6.2f %6.2f%%\n";
$prof = "";
if( !count( $this->mStack ) ) {
return "No profiling output\n";
}
$this->mCollated = array();
$top = $this->doLevel( 0, true );
$this->merge( "WIKI.PHTML", $top, $scriptElapsed );
$this->mCollated = array_reverse( $this->mCollated, true );
/*
# Calculate totals
foreach ( $this->mCollated as $f1 => $f1data ) {
$total = 0;
foreach ( $f1data as $f2 => $t ) {
$total += $t;
}
$this->mCollated[$f1][0] = $total;
}
*/
# Output
foreach ( $this->mCollated as $f1 => $f1data ) {
$prof .= "\n" . str_repeat( "-", $width ) . "\n";
$t = $this->mTotals[$f1] * 1000;
$calls = $this->mCalls[$f1];
if ( $calls == 0 ) {
$calls = 1;
}
$each = $t / $calls;
$percent = $this->mTotals[$f1] / $scriptElapsed * 100;
$prof .= sprintf( $format, "| $f1", $t, $calls, $each, $percent );
$prof .= str_repeat( "-", $width ) . "\n";
foreach ( $f1data as $f2 => $t ) {
$percent = $t / $this->mTotals[$f1] * 100;
$t *= 1000;
$calls = $this->mCalls[$f1];
if ( $calls == 0 ) {
$calls = 1;
}
$each = $t / $calls;
$percent = $this->mTotals[$f1] / $scriptElapsed * 100;
$prof .= sprintf( $format, $f2, $t, $calls, $each, $percent );
}
}
$prof .= str_repeat( "-", $width ) . "\n";
return $prof;
}
function doLevel( $p, $fTop )
{
$level = false;
$getOut = false;
$hotArray = false;
$tempArray = array();
do {
$fname = $this->mStack[$p][0];
$thislevel = $this->mStack[$p][1];
$start = (float)$this->mStack[$p][2] + (float)$this->mStack[$p][3];
$end = (float)$this->mStack[$p][4] + (float)$this->mStack[$p][5];
$elapsed = $end - $start;
if ( $hotArray !== false ) {
# Just dropped down a level
# Therefore this entry is the parent of $hotArray
$this->merge( $fname, $hotArray, $elapsed );
$hotArray = false;
}
if ( $level === false ) {
$level = $thislevel;
}
if ( $thislevel == $level ) {
$tempArray[$fname] += $elapsed;
#$this->mTotals[$fname] += elapsed;
$this->mCalls[$fname] ++;
} elseif ($thislevel > $level ) {
$hotArray = $this->doLevel( $p, false );
} else {
$getOut = true;
}
# Special case: top of hierarchy
# File starts with lvl 1 entry, then drops back to lvl 0
if ( $fTop && $getOut ) {
$hotArray = $tempArray;
$getOut = false;
}
$p++;
} while ( !$getOut && $p < count( $this->mStack ) );
return $tempArray;
}
function merge( $f1, $a, $parentTime )
{
foreach ( $a as $f2 => $elapsed ) {
$this->mCollated[$f1][$f2] += $elapsed;
}
$this->mTotals[$f1] += $parentTime;
}
}
$wgProfiler = new Profiler();
?>

View file

@ -48,6 +48,18 @@ if( ! class_exists( $wgLangClass ) ) {
}
$wgLang = new $wgLangClass();
if( !isset( $wgProfiling ) )
$wgProfiling = false;
if ( $wgProfiling ) {
include_once( "$IP/Profiling.php" );
} else {
function wfProfileIn( $fn ) {}
function wfProfileOut( $fn = "" ) {}
function wfGetProfilingOutput( $s, $e ) {}
function wfProfileClose() {}
}
$wgUser = User::loadFromSession();
$wgDeferredUpdateList = array();
$wgLinkCache = new LinkCache();

View file

@ -70,16 +70,18 @@ class Skin {
function initPage()
{
global $wgOut, $wgStyleSheetPath;
wfProfileIn( "Skin::initPage" );
$fname = "Skin::initPage";
wfProfileIn( $fname );
$wgOut->addLink( "shortcut icon", "", "/favicon.ico" );
if ( $wgOut->isPrintable() ) { $ss = "wikiprintable.css"; }
else { $ss = $this->getStylesheet(); }
$wgOut->addLink( "stylesheet", "", "{$wgStyleSheetPath}/{$ss}" );
wfProfileOut();
wfProfileOut( $fname );
}
function outputPage( &$out ) {
wfProfileIn( "Skin::outputPage" );
$this->initPage();
$out->out( $out->headElement() );
@ -98,9 +100,8 @@ class Skin {
$out->out( $out->mBodytext );
$out->out( $this->afterContent() );
wfProfileOut();
wfProfileOut(); # A hack - we can't report after here
wfProfileClose();
$out->out( $out->reportTime() );
$out->out( "\n</body></html>" );
@ -238,7 +239,8 @@ class Skin {
function doBeforeContent()
{
global $wgUser, $wgOut, $wgTitle, $wgLang;
wfProfileIn( "Skin::doBeforeContent" );
$fname = "Skin::doBeforeContent";
wfProfileIn( $fname );
$s = "";
$qb = $this->qbSetting();
@ -290,7 +292,7 @@ class Skin {
$s .= $this->pageSubtitle() ;
$s .= getCategories(); // For some odd reason, zhis can't be a function of the object
$s .= "\n<p>";
wfProfileOut();
wfProfileOut( $fname );
return $s;
}
@ -326,7 +328,8 @@ class Skin {
function doAfterContent()
{
global $wgUser, $wgOut, $wgLang;
wfProfileIn( "Skin::doAfterContent" );
$fname = "Skin::doAfterContent";
wfProfileIn( $fname );
$s = "\n</div><br clear=all>\n";
@ -358,7 +361,7 @@ class Skin {
$s .= "</tr></table>\n</div>\n</div>\n";
if ( 0 != $qb ) { $s .= $this->quickBar(); }
wfProfileOut();
wfProfileOut( $fname );
return $s;
}
@ -482,7 +485,7 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
if( $wgShowIPinHeader ) {
$n = getenv( "REMOTE_ADDR" );
$tl = $this->makeKnownLink( $wgLang->getNsText(
$tl = $this->makeKnownLink( $wgLang->getNsText(
Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
$wgLang->getNsText( Namespace::getTalk( 0 ) ) );
@ -638,7 +641,9 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
{
global $wgOut, $wgTitle, $wgUser, $action, $wgLang;
global $wpPreview;
wfProfileIn( "Skin::quickBar" );
$fname = "Skin::quickBar";
wfProfileIn( $fname );
$tns=$wgTitle->getNamespace();
$s = "\n<div id='quickbar'>";
@ -655,11 +660,10 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
}
// only show watchlist link if logged in
if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
$s .= "\n<br><hr class='sep'>";
if ( wfMsg ( "currentevents" ) != "-" ) $s .= $sep . $this->makeKnownLink( wfMsg( "currentevents" ), "" ) ;
$s .= "\n<br><hr class='sep'>";
$articleExists = $wgTitle->getArticleId();
if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
if ( $wgOut->isArticle() || $action =="edit" || $action =="history" || $wpPreview) {
if($wgOut->isArticle()) {
$s .= "<strong>" . $this->editThisPage() . "</strong>";
} else { # backlink to the article in edit or history mode
@ -761,7 +765,7 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
. $sep . $this->bugReportsLink();
$s .= "\n<br></div>\n";
wfProfileOut();
wfProfileOut( $fname );
return $s;
}
@ -983,7 +987,7 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
if ( !$wgUseNewInterlanguage ) return "";
$ns = $wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
if ( $ns != 0 AND $ns != 1 ) return "" ;
$pn = "Intl" ;
$pn = "Intl" ;
$x = "mode=addlink&xt=".$wgTitle->getDBkey() ;
return $this->makeKnownLink( $wgLang->specialPage( $pn ),
wfMsg( "intl" ) , $x );
@ -1100,7 +1104,7 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
# a final pass through here for things like table backgrounds.
#
function transformContent( $text )
{
{
return $text;
}
@ -1578,7 +1582,7 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
"diff={$oldid}&oldid={$diffid}" ); # Finagle's law
}
if ( 0 == $u ) {
$ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
$ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
$ut, "target=" . $ut );
} else { $ul = $this->makeLink( $wgLang->getNsText(
Namespace::getUser() ) . ":{$ut}", $ut ); }
@ -1665,7 +1669,7 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
}
if ( 0 == $u ) {
$ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
$ul = $this->makeKnownLink( $wgLang->specialPage( "Contributions" ),
$ut, "target=" . $ut );
} else { $ul = $this->makeLink( $wgLang->getNsText(
Namespace::getUser() ) . ":{$ut}", $ut ); }

View file

@ -83,11 +83,18 @@ class IPBlockForm {
return;
}
# Create block
# Note: for a user block, ipb_address is only for display purposes
$ban = new Block( $wpBlockAddress, $userId, $wgUser->getID(),
wfStrencode( $wpBlockReason ), wfTimestampNow(), 0 );
$ban->insert();
# Make log entry
$log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
$action = str_replace( "$1", $wpBlockAddress, wfMsg( "blocklogentry" ) );
$log->addEntry( $action, $wpBlockReason );
# Report to the user
$success = wfLocalUrl( $wgLang->specialPage( "Blockip" ),
"action=success&ip={$wpBlockAddress}" );
$wgOut->redirect( $success );

View file

@ -36,6 +36,7 @@ class IPUnblockForm {
if ( ! $wpUnblockAddress ) { $wpUnblockAddress = $ip; }
$ipa = wfMsg( "ipaddress" );
$ipr = wfMsg( "ipbreason" );
$ipus = wfMsg( "ipusubmit" );
$action = wfLocalUrlE( $wgLang->specialPage( "Ipblocklist" ),
"action=submit" );
@ -51,6 +52,10 @@ class IPUnblockForm {
<td align=left>
<input tabindex=1 type=text size=20 name=\"wpUnblockAddress\" value=\"{$wpUnblockAddress}\">
</td></tr><tr>
<td align=right>{$ipr}:</td>
<td align=left>
<input tabindex=1 type=text size=40 name=\"wpUnblockReason\" value=\"{$wpUnblockReason}\">
</td></tr><tr>
<td>&nbsp;</td><td align=left>
<input tabindex=2 type=submit name=\"wpBlock\" value=\"{$ipus}\">
</td></tr></table>
@ -61,7 +66,7 @@ class IPUnblockForm {
function doSubmit()
{
global $wgOut, $wgUser, $wgLang;
global $wpUnblockAddress;
global $wpUnblockAddress, $wpUnblockReason;
$block = new Block();
$wpUnblockAddress = trim( $wpUnblockAddress );
@ -72,8 +77,16 @@ class IPUnblockForm {
$block->mAddress = $wpUnblockAddress;
}
# Delete block (if it exists)
# We should probably check for errors rather than just declaring success
$block->delete();
# Make log entry
$log = new LogPage( wfMsg( "blocklogpage" ), wfMsg( "blocklogtext" ) );
$action = str_replace( "$1", $wpUnblockAddress, wfMsg( "unblocklogentry" ) );
$log->addEntry( $action, $wpUnblockReason );
# Report to the user
$success = wfLocalUrl( $wgLang->specialPage( "Ipblocklist" ),
"action=success&ip=" . urlencode($wpUnblockAddress) );
$wgOut->redirect( $success );

View file

@ -31,7 +31,8 @@ class Title {
function newFromText( $text )
{
wfProfileIn( "Title::newFromText" );
$fname = "Title::newFromText";
wfProfileIn( $fname );
# Note - mixing latin1 named entities and unicode numbered
# ones will result in a bad link.
@ -45,8 +46,8 @@ class Title {
$t = new Title();
$t->mDbkeyform = str_replace( " ", "_", $text );
wfProfileOut( $fname );
if( $t->secureAndSplit() ) {
wfProfileOut();
return $t;
} else {
return NULL;
@ -352,7 +353,8 @@ class Title {
/* private */ function secureAndSplit()
{
global $wgLang, $wgLocalInterwiki;
wfProfileIn( "Title::secureAndSplit" );
$fname = "Title::secureAndSplit";
wfProfileIn( $fname );
$validNamespaces = $wgLang->getNamespaces();
unset( $validNamespaces[0] );
@ -365,7 +367,7 @@ class Title {
$l = strlen( $t );
if ( $l && ( "_" == $t{$l-1} ) ) { $t = substr( $t, 0, $l-1 ); }
if ( "" == $t ) {
wfProfileOut();
wfProfileOut( $fname );
return false;
}
@ -424,7 +426,7 @@ class Title {
$this->mUrlform = wfUrlencode( $t );
$this->mTextform = str_replace( "_", " ", $t );
wfProfileOut();
wfProfileOut( $fname );
return true;
}
}

View file

@ -1146,6 +1146,12 @@ to a previously blocked IP address or username.",
"unblocklink" => "unblock",
"contribslink" => "contribs",
"autoblocker" => "Autoblocked because you share an IP address with \"$1\". Reason \"$2\".",
"blocklogpage" => "Block_log",
"blocklogentry" => 'blocked "$1"',
"blocklogtext" => "This is a log of user blocking and unblocking actions. Automatically
blocked IP addresses are not be listed. See the [[Special:Ipblocklist|IP block list]] for
the list of currently operational bans and blocks.",
"unblocklogentry" => 'unblocked "$1"',
# Developer tools
#