require __DIR__ . '/includes/WebStart.php';
-wfProfileIn( 'api.php' );
$starttime = microtime( true );
// URL safety checks
// Log what the user did, for book-keeping purposes.
$endtime = microtime( true );
-wfProfileOut( 'api.php' );
wfLogProfilingData();
'ProfilerOutputDb' => __DIR__ . '/includes/profiler/output/ProfilerOutputDb.php',
'ProfilerOutputText' => __DIR__ . '/includes/profiler/output/ProfilerOutputText.php',
'ProfilerOutputUdp' => __DIR__ . '/includes/profiler/output/ProfilerOutputUdp.php',
+ 'ProfilerSectionOnly' => __DIR__ . '/includes/profiler/ProfilerSectionOnly.php',
'ProfilerStub' => __DIR__ . '/includes/profiler/ProfilerStub.php',
'ProfilerXhprof' => __DIR__ . '/includes/profiler/ProfilerXhprof.php',
'Protect' => __DIR__ . '/maintenance/protect.php',
define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
require __DIR__ . '/includes/WebStart.php';
-wfProfileIn( 'img_auth.php' );
# Set action base paths so that WebRequest::getPathInfo()
# recognizes the "X" as the 'title' in ../img_auth.php/X urls.
$wgActionPaths = array( "$wgUploadPath/" );
wfImageAuthMain();
-wfProfileOut( 'img_auth.php' );
wfLogProfilingData();
// Commit and close up!
$factory = wfGetLBFactory();
return true;
}
-
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow(
'category',
__METHOD__
);
-
if ( !$row ) {
# Okay, there were no contents. Nothing to initialize.
if ( $this->mTitle ) {
)
);
-
return $result;
}
}
}
-
$dbw = wfGetDB( DB_MASTER );
$dbw->startAtomic( __METHOD__ );
);
$dbw->endAtomic( __METHOD__ );
-
# Now we should update our local counts.
$this->mPages = $result->pages;
$this->mSubcats = $result->subcats;
*/
$wgUDPProfilerFormatString = null;
-/**
- * Output debug message on every wfProfileIn/wfProfileOut
- */
-$wgDebugFunctionEntry = false;
-
/**
* Destination for wfIncrStats() data...
* 'cache' to go into the system cache, if enabled (memcached)
return;
}
- wfProfileIn( __METHOD__ . "-business-end" );
-
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
$this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
if ( 'save' == $this->formtype ) {
if ( !$this->attemptSave() ) {
- wfProfileOut( __METHOD__ . "-business-end" );
return;
}
}
if ( 'initial' == $this->formtype || $this->firsttime ) {
if ( $this->initialiseForm() === false ) {
$this->noSuchSectionPage();
- wfProfileOut( __METHOD__ . "-business-end" );
return;
}
}
$this->showEditForm();
- wfProfileOut( __METHOD__ . "-business-end" );
}
/**
function importFormData( &$request ) {
global $wgContLang, $wgUser;
-
# Section edit can come from either the form or a link
$this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
// Skip this if wpTextbox2 has input, it indicates that we came
// from a conflict page with raw page text, not a custom form
// modified by subclasses
- wfProfileIn( get_class( $this ) . "::importContentFormData" );
$textbox1 = $this->importContentFormData( $request );
if ( $textbox1 !== null ) {
$this->textbox1 = $textbox1;
}
-
- wfProfileOut( get_class( $this ) . "::importContentFormData" );
}
# Truncate for whole multibyte characters
protected function getContentObject( $def_content = null ) {
global $wgOut, $wgRequest, $wgUser, $wgContLang;
-
$content = false;
// For message page not locally set, use the i18n message.
$status = Status::newGood();
- wfProfileIn( __METHOD__ . '-checks' );
-
if ( !Hooks::run( 'EditPage::attemptSave', array( $this ) ) ) {
wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
$status->fatal( 'hookaborted' );
$status->value = self::AS_HOOK_ERROR;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
);
$status->fatal( 'spamprotectionmatch', false );
$status->value = self::AS_SPAM_ERROR;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
$ex->getMessage()
);
$status->value = self::AS_PARSE_ERROR;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
$code = $wgUser->isAnon() ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED;
$status->setResult( false, $code );
- wfProfileOut( __METHOD__ . '-checks' );
-
return $status;
}
wfDebugLog( 'SpamRegex', "$ip spam regex hit [[$pdbk]]: \"$match\"" );
$status->fatal( 'spamprotectionmatch', $match );
$status->value = self::AS_SPAM_ERROR;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
if ( !Hooks::run(
# Error messages etc. could be handled within the hook...
$status->fatal( 'hookaborted' );
$status->value = self::AS_HOOK_ERROR;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
} elseif ( $this->hookError != '' ) {
# ...or the hook could be expecting us to produce an error
$status->fatal( 'hookaborted' );
$status->value = self::AS_HOOK_ERROR_EXPECTED;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
$wgUser->spreadAnyEditBlock();
# Check block state against master, thus 'false'.
$status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
// Error will be displayed by showEditForm()
$this->tooBig = true;
$status->setResult( false, self::AS_CONTENT_TOO_BIG );
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
if ( !$wgUser->isAllowed( 'edit' ) ) {
if ( $wgUser->isAnon() ) {
$status->setResult( false, self::AS_READ_ONLY_PAGE_ANON );
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
} else {
$status->fatal( 'readonlytext' );
$status->value = self::AS_READ_ONLY_PAGE_LOGGED;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
}
&& !$wgUser->isAllowed( 'editcontentmodel' )
) {
$status->setResult( false, self::AS_NO_CHANGE_CONTENT_MODEL );
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
if ( wfReadOnly() ) {
$status->fatal( 'readonlytext' );
$status->value = self::AS_READ_ONLY_PAGE;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
if ( $wgUser->pingLimiter() || $wgUser->pingLimiter( 'linkpurge', 0 ) ) {
$status->fatal( 'actionthrottledtext' );
$status->value = self::AS_RATE_LIMITED;
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
# confirmation
if ( $this->wasDeletedSinceLastEdit() && !$this->recreate ) {
$status->setResult( false, self::AS_ARTICLE_WAS_DELETED );
- wfProfileOut( __METHOD__ . '-checks' );
return $status;
}
- wfProfileOut( __METHOD__ . '-checks' );
-
# Load the page data from the master. If anything changes in the meantime,
# we detect it by using page_latest like a token in a 1 try compare-and-swap.
$this->mArticle->loadPageData( 'fromdbmaster' );
}
# All's well
- wfProfileIn( __METHOD__ . '-sectionanchor' );
$sectionanchor = '';
if ( $this->section == 'new' ) {
$this->summary = $this->newSectionSummary( $sectionanchor );
}
}
$result['sectionanchor'] = $sectionanchor;
- wfProfileOut( __METHOD__ . '-sectionanchor' );
// Save errors may fall down to the edit form, but we've now
// merged the section into full text. Clear the section field
function showEditForm( $formCallback = null ) {
global $wgOut, $wgUser;
-
# need to parse the preview early so that we know which templates are used,
# otherwise users with "show preview after edit box" will get a blank list
# we parse this near the beginning so that setHeaders can do the title
return '';
}
-
$limitReport = Html::rawElement( 'div', array( 'class' => 'mw-limitReportExplanation' ),
wfMessage( 'limitreport-title' )->parseAsBlock()
);
Html::closeElement( 'table' ) .
Html::closeElement( 'div' );
-
return $limitReport;
}
global $wgOut, $wgUser, $wgRawHtml, $wgLang;
global $wgAllowUserCss, $wgAllowUserJs;
-
if ( $wgRawHtml && !$this->mTokenOk ) {
// Could be an offsite preview attempt. This is very unsafe if
// HTML is enabled, as it could be an attack.
}
if ( $oldid ) {
- wfProfileIn( __METHOD__ . "-dodiff" );
#$diffText = $de->getDiff( wfMessage( 'revisionasof',
# $wgLang->timeanddate( $timestamp ),
$diffText = UtfNormal::cleanUp( $diffText );
$diffText = self::applyDiffStyle( $diffText );
}
- wfProfileOut( __METHOD__ . "-dodiff" );
} else {
$rev = Revision::newFromId( $newid );
if ( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) {
public function getText( $element = null ) {
if ( $this->doc ) {
- wfProfileIn( __METHOD__ . '-dom' );
if ( $element !== null && !( $element instanceof DOMElement ) ) {
$element = $this->doc->getElementById( $element );
}
$body->appendChild( $element );
}
$html = $this->doc->saveHTML();
- wfProfileOut( __METHOD__ . '-dom' );
- wfProfileIn( __METHOD__ . '-fixes' );
$html = $this->fixLibXml( $html );
if ( wfIsWindows() ) {
// Cleanup for CRLF misprocessing of unknown origin on Windows.
// XML code paths if possible and fix there.
$html = str_replace( ' ', '', $html );
}
- wfProfileOut( __METHOD__ . '-fixes' );
} else {
$html = $this->html;
}
$html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
$html = $this->onHtmlReady( $html );
- wfProfileIn( __METHOD__ . '-flatten' );
if ( $this->elementsToFlatten ) {
$elements = implode( '|', $this->elementsToFlatten );
$html = preg_replace( "#</?($elements)\\b[^>]*>#is", '', $html );
}
- wfProfileOut( __METHOD__ . '-flatten' );
return $html;
}
*/
public static function request( $method, $url, $options = array() ) {
wfDebug( "HTTP: $method: $url\n" );
- wfProfileIn( __METHOD__ . "-$method" );
$options['method'] = strtoupper( $method );
if ( $status->isOK() ) {
$content = $req->getContent();
}
- wfProfileOut( __METHOD__ . "-$method" );
return $content;
}
$this->parseHeader();
$this->setStatus();
-
return $this->status;
}
}
fclose( $fh );
-
return $this->status;
}
}
$target = self::normaliseSpecialPage( $target );
# If we don't know whether the page exists, let's find out.
- wfProfileIn( __METHOD__ . '-checkPageExistence' );
if ( !in_array( 'known', $options ) && !in_array( 'broken', $options ) ) {
if ( $target->isKnown() ) {
$options[] = 'known';
$options[] = 'broken';
}
}
- wfProfileOut( __METHOD__ . '-checkPageExistence' );
$oldquery = array();
if ( in_array( "forcearticlepath", $options ) && $query ) {
$defaults = array();
if ( !in_array( 'noclasses', $options ) ) {
- wfProfileIn( __METHOD__ . '-getClasses' );
# Now build the classes.
$classes = array();
if ( $classes != array() ) {
$defaults['class'] = implode( ' ', $classes );
}
- wfProfileOut( __METHOD__ . '-getClasses' );
}
# Get a default title attribute.
) {
wfDeprecated( __METHOD__, '1.21' );
-
if ( $text == '' ) {
$text = self::linkText( $title );
}
private function performRequest() {
global $wgTitle;
-
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
echo "Waiting for a database server: $lag seconds lagged\n";
}
-
exit;
}
}
private function main() {
global $wgTitle;
-
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
}
if ( $this->config->get( 'UseFileCache' ) && $title->getNamespace() >= 0 ) {
- wfProfileIn( 'main-try-filecache' );
if ( HTMLFileCache::useFileCache( $this->context ) ) {
// Try low-level file cache hit
$cache = new HTMLFileCache( $title, $action );
$this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
// Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
- wfProfileOut( 'main-try-filecache' );
return;
}
}
- wfProfileOut( 'main-try-filecache' );
}
// Actually do the work of the request and build up any output
return; // recursion guard
}
-
if ( $jobRunRate < 1 ) {
$max = mt_getrandmax();
if ( mt_rand( 0, $max ) > $max * $jobRunRate ) {
) {
global $wgParser;
-
$popts = $this->parserOptions();
$oldTidy = $popts->setTidy( $tidy );
$popts->setInterfaceMessage( (bool)$interface );
return;
}
-
$response = $this->getRequest()->response();
$config = $this->getConfig();
public function headElement( Skin $sk, $includeStyle = true ) {
global $wgContLang;
-
$userdir = $this->getLanguage()->getDir();
$sitedir = $wgContLang->getDir();
public function insertOn( $dbw ) {
global $wgDefaultExternalStore, $wgContentHandlerUseDB;
-
$this->checkContentModel();
$data = $this->mText;
$wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
}
-
return $text;
}
public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
global $wgContentHandlerUseDB;
-
$fields = array( 'page_latest', 'page_namespace', 'page_title',
'rev_text_id', 'rev_len', 'rev_sha1' );
static $htmlpairsStatic, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags,
$htmllist, $listtags, $htmlsingleallowed, $htmlelementsStatic, $staticInitialised;
-
// Base our staticInitialised variable off of the global config state so that if the globals
// are changed (like in the screwed up test system) we will re-initialise the settings.
$globalContext = implode( '-', compact( 'wgAllowMicrodataAttributes', 'wgAllowImageTag' ) );
if ( $res == self::NOT_MODIFIED ) {
$ok = true; // use client cache
} elseif ( $res == self::READY_STREAM ) {
- wfProfileIn( __METHOD__ . '-send' );
$ok = readfile( $fname );
- wfProfileOut( __METHOD__ . '-send' );
} else {
$ok = false; // failed
}
if ( get_class( $GLOBALS[$this->global] ) != $this->class ) {
$fname = __METHOD__ . '-' . $this->global;
- wfProfileIn( $fname );
$caller = wfGetCaller( $level );
if ( ++$recursionLevel > 2 ) {
- wfProfileOut( $fname );
throw new MWException( "Unstub loop detected on call of "
. "\${$this->global}->$name from $caller\n" );
}
. "\${$this->global}::$name from $caller\n" );
$GLOBALS[$this->global] = $this->_newObject();
--$recursionLevel;
- wfProfileOut( $fname );
return $GLOBALS[$this->global];
}
}
return array( $this->mHasCascadingRestrictions, $pagerestrictions );
}
-
$dbr = wfGetDB( DB_SLAVE );
if ( $this->getNamespace() == NS_FILE ) {
}
global $wgMemc;
- wfProfileIn( __METHOD__ . '-' . $action );
$limits = $wgRateLimits[$action];
$keys = array();
}
}
- wfProfileOut( __METHOD__ . '-' . $action );
return $triggered;
}
public function checkPassword( $password ) {
global $wgAuth, $wgLegacyEncoding;
-
$this->loadPasswords();
// Certain authentication plugins do NOT want to save
require "$IP/StartProfiler.php";
}
-wfProfileIn( 'WebStart.php-conf' );
# Load default settings
require_once "$IP/includes/DefaultSettings.php";
require_once MW_CONFIG_FILE;
}
-wfProfileOut( 'WebStart.php-conf' );
-wfProfileIn( 'WebStart.php-ob_start' );
# Initialise output buffering
# Check that there is no previous output or previously set up buffers, because
# that would cause us to potentially mix gzip and non-gzip output, creating a
require_once "$IP/includes/OutputHandler.php";
ob_start( 'wfOutputHandler' );
}
-wfProfileOut( 'WebStart.php-ob_start' );
if ( !defined( 'MW_NO_SETUP' ) ) {
require_once "$IP/includes/Setup.php";
$attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
}
if ( $contents ) {
- wfProfileIn( __METHOD__ . '-norm' );
$contents = $wgContLang->normalize( $contents );
- wfProfileOut( __METHOD__ . '-norm' );
}
return self::element( $element, $attribs, $contents );
}
$s = $this->getCredits( -1 );
}
-
return Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $s );
}
}
}
-
return $s;
}
return; // Client cache fresh and headers sent, nothing more to do.
}
-
$this->preCacheMessages();
$config = $this->context->getConfig();
__METHOD__
);
-
return $result;
}
* Profiling: total module execution time
*/
private $mTimeIn = 0, $mModuleTime = 0;
+ /** @var ScopedCallback */
+ private $profile;
+ /** @var ScopedCallback */
+ private $dbProfile;
/**
* Get the name of the module as shown in the profiler log
ApiBase::dieDebug( __METHOD__, 'Called twice without calling profileOut()' );
}
$this->mTimeIn = microtime( true );
- wfProfileIn( $this->getModuleProfileName() );
+ $this->profile = Profiler::instance()->scopedProfileIn( $this->getModuleProfileName() );
}
/**
$this->mModuleTime += microtime( true ) - $this->mTimeIn;
$this->mTimeIn = 0;
- wfProfileOut( $this->getModuleProfileName() );
+ Profiler::instance()->scopedProfileOut( $this->profile );
}
/**
ApiBase::dieDebug( __METHOD__, 'Called twice without calling profileDBOut()' );
}
$this->mDBTimeIn = microtime( true );
- wfProfileIn( $this->getModuleProfileName( true ) );
+
+ $this->dbProfile = Profiler::instance()->scopedProfileIn( $this->getModuleProfileName( true ) );
}
/**
$this->mDBTime += $time;
$this->getMain()->mDBTime += $time;
- wfProfileOut( $this->getModuleProfileName( true ) );
+ Profiler::instance()->scopedProfileOut( $this->dbProfile );
}
/**
$popts->setIsSectionPreview( $params['sectionpreview'] );
$popts->setEditSection( !$params['disableeditsection'] );
-
return $popts;
}
public function addLinkObj( $nt ) {
global $wgContentHandlerUseDB;
-
$key = $nt->getPrefixedDBkey();
if ( $this->isBadLink( $key ) || $nt->isExternal() ) {
$id = 0;
}
-
return $id;
}
*/
public function getItem( $code, $key ) {
if ( !isset( $this->loadedItems[$code][$key] ) ) {
- wfProfileIn( __METHOD__ . '-load' );
$this->loadItem( $code, $key );
- wfProfileOut( __METHOD__ . '-load' );
}
if ( $key === 'fallback' && isset( $this->shallowFallbacks[$code] ) ) {
if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) &&
!isset( $this->loadedItems[$code][$key] )
) {
- wfProfileIn( __METHOD__ . '-load' );
$this->loadSubitem( $code, $key, $subkey );
- wfProfileOut( __METHOD__ . '-load' );
}
if ( isset( $this->data[$code][$key][$subkey] ) ) {
}
}
-
// The JSON format only supports messages, none of the other variables, so wrap the data
return array( 'messages' => $data );
}
$deps['plurals'] = new FileDependency( "$IP/languages/data/plurals.xml" );
$deps['plurals-mw'] = new FileDependency( "$IP/languages/data/plurals-mediawiki.xml" );
-
return $data;
}
$codeSequence = array_merge( array( $code ), $coreData['fallbackSequence'] );
$messageDirs = $this->getMessagesDirs();
- wfProfileIn( __METHOD__ . '-fallbacks' );
-
# Load non-JSON localisation data for extensions
$extensionData = array_combine(
$codeSequence,
}
}
- wfProfileOut( __METHOD__ . '-fallbacks' );
-
# Add cache dependencies for any referenced globals
$deps['wgExtensionMessagesFiles'] = new GlobalDependency( 'wgExtensionMessagesFiles' );
// $wgMessagesDirs is used in LocalisationCache::getMessagesDirs()
}
# Save to the persistent cache
- wfProfileIn( __METHOD__ . '-write' );
$this->store->startWrite( $code );
foreach ( $allData as $key => $value ) {
if ( in_array( $key, self::$splitKeys ) ) {
}
}
$this->store->finishWrite();
- wfProfileOut( __METHOD__ . '-write' );
# Clear out the MessageBlobStore
# HACK: If using a null (i.e. disabled) storage backend, we
# Hash of the contents is stored in memcache, to detect if local cache goes
# out of date (e.g. due to replace() on some other server)
if ( $wgUseLocalMessageCache ) {
- wfProfileIn( __METHOD__ . '-fromlocal' );
$hash = $this->mMemc->get( wfMemcKey( 'messages', $code, 'hash' ) );
if ( $hash ) {
$this->mCache[$code] = $cache;
}
}
- wfProfileOut( __METHOD__ . '-fromlocal' );
}
if ( !$success ) {
# the lock can't be acquired, wait for the other thread to finish
# and then try the global cache a second time.
for ( $failedAttempts = 0; $failedAttempts < 2; $failedAttempts++ ) {
- wfProfileIn( __METHOD__ . '-fromcache' );
$cache = $this->mMemc->get( $cacheKey );
if ( !$cache ) {
$where[] = 'global cache is empty';
$success = true;
}
- wfProfileOut( __METHOD__ . '-fromcache' );
-
if ( $success ) {
# Done, no need to retry
break;
$this->saveToLocal( $serialized, $hash, $code );
}
-
return $success;
}
function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) {
global $wgContLang;
-
if ( is_int( $key ) ) {
// Fix numerical strings that somehow become ints
// on their way here
$res = $parser->parse( $text, $title, $popts, $linestart );
$this->mInParser = false;
-
return $res;
}
$cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $baseRC, $watched );
$this->addCacheEntry( $cacheEntry );
-
return $ret;
}
$this->rcCacheIndex++;
-
return $r;
}
$r .= "</td></tr></table>\n";
-
return $r;
}
return '';
}
-
$blockOut = '';
foreach ( $this->rc_cache as $block ) {
if ( count( $block ) < 2 ) {
}
}
-
return '<div>' . $blockOut . '</div>';
}
return false;
}
-
$dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
$this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
$newContent = new static( $text );
-
return $newContent;
}
*/
public function getSkin() {
if ( $this->skin === null ) {
- wfProfileIn( __METHOD__ . '-createskin' );
$skin = null;
Hooks::run( 'RequestContextCreateSkin', array( $this, &$skin ) );
// After all that set a context on whatever skin got created
$this->skin->setContext( $this );
- wfProfileOut( __METHOD__ . '-createskin' );
}
return $this->skin;
$this->mPassword = $password;
$this->mDBname = $dbName;
- wfProfileIn( "dbconnect-$server" );
-
# The kernel's default SYN retransmission period is far too slow for us,
# so we use a short timeout plus a manual retry. Retrying means that a small
# but finite rate of SYN packet loss won't cause user-visible errors.
try {
$this->mConn = $this->mysqlConnect( $realServer );
} catch ( Exception $ex ) {
- wfProfileOut( "dbconnect-$server" );
$this->restoreErrorHandler();
throw $ex;
}
$error = $this->restoreErrorHandler();
- wfProfileOut( "dbconnect-$server" );
-
# Always log connection errors
if ( !$this->mConn ) {
if ( !$error ) {
"Server: $server, User: $user, Password: " .
substr( $password, 0, 3 ) . "..., error: " . $error . "\n" );
-
$this->reportConnectionError( $error );
}
wfDebug( "Error selecting database $dbName on server {$this->mServer} " .
"from client host " . wfHostname() . "\n" );
-
$this->reportConnectionError( "Error selecting database $dbName" );
}
}
}
}
-
return $status;
}
return $this->reportConnectionError();
}
-
return $conn;
}
return array( 0 => 0 );
}
-
$expiry = 5;
$requestRate = 10;
public static function doUpdates( $commit = '' ) {
global $wgDeferredUpdateList;
-
$updates = array_merge( $wgDeferredUpdateList, self::$updates );
// No need to get master connections in case of empty updates array
return;
}
-
$page = WikiPage::newFromID( $this->id, WikiPage::READ_LATEST );
foreach ( SearchEngine::getSearchTypes() as $type ) {
$text = $wgContLang->normalizeForSearch( $text );
$lc = SearchEngine::legalSearchChars() . '&#;';
- wfProfileIn( __METHOD__ . '-regexps' );
$text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
' ', $wgContLang->lc( " " . $text . " " ) ); # Strip HTML markup
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
# Strip wiki '' and '''
$text = preg_replace( "/''[']*/", " ", $text );
- wfProfileOut( __METHOD__ . '-regexps' );
return $text;
}
self::HTCPPurge( $urlArr );
}
-
// Remove duplicate URLs
$urlArr = array_unique( $urlArr );
// Maximum number of parallel connections per squid
if ( $wgExternalDiffEngine == 'wikidiff2' && function_exists( 'wikidiff2_do_diff' ) ) {
# Better external diff engine, the 2 may some day be dropped
# This one does the escaping and segmenting itself
- wfProfileIn( 'wikidiff2_do_diff' );
$text = wikidiff2_do_diff( $otext, $ntext, 2 );
$text .= $this->debug( 'wikidiff2' );
- wfProfileOut( 'wikidiff2_do_diff' );
return $text;
}
fclose( $tempFile1 );
fclose( $tempFile2 );
$cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 );
- wfProfileIn( __METHOD__ . "-shellexec" );
$difftext = wfShellExec( $cmd );
$difftext .= $this->debug( "external $wgExternalDiffEngine" );
- wfProfileOut( __METHOD__ . "-shellexec" );
unlink( $tempName1 );
unlink( $tempName2 );
wfDebug( __METHOD__ . ": $this->path NOT FOUND!\n" );
}
-
return $info;
}
$this->sha1Base36 = wfBaseConvert( $this->sha1Base36, 16, 36, 31 );
}
-
return $this->sha1Base36;
}
}
}
}
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$stat = $this->doGetFileStat( $params );
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
$stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
return $stat['map'];
}
}
- wfProfileIn( __METHOD__ . '-miss' );
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$fields = $this->doGetFileXAttributes( $params );
$fields = is_array( $fields ) ? self::normalizeXAttributes( $fields ) : false;
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
- wfProfileOut( __METHOD__ . '-miss' );
$this->cheapCache->set( $path, 'xattr', array( 'map' => $fields, 'latest' => $latest ) );
return $fields;
return $stat['hash'];
}
}
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$hash = $this->doGetFileSha1Base36( $params );
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
$this->cheapCache->set( $path, 'sha1', array( 'hash' => $hash, 'latest' => $latest ) );
return $hash;
if ( $res == StreamFile::NOT_MODIFIED ) {
// do nothing; client cache is up to date
} elseif ( $res == StreamFile::READY_STREAM ) {
- wfProfileIn( __METHOD__ . '-send-' . $this->name );
$status = $this->doStreamFile( $params );
- wfProfileOut( __METHOD__ . '-send-' . $this->name );
if ( !$status->isOK() ) {
// Per bug 41113, nasty things can happen if bad cache entries get
// stuck in cache. It's also possible that this error can come up
return null;
}
- wfProfileIn( __METHOD__ . "-{$this->name}-miss" );
list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array(
'method' => 'HEAD',
'url' => $this->storageUrl( $auth, $container ),
'headers' => $this->authTokenHeaders( $auth )
) );
- wfProfileOut( __METHOD__ . "-{$this->name}-miss" );
if ( $rcode === 204 ) {
$stat = array(
}
} while ( false );
-
return is_object( $thumb ) ? $thumb : false;
}
}
// Actually render the thumbnail...
- wfProfileIn( __METHOD__ . '-doTransform' );
$thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
- wfProfileOut( __METHOD__ . '-doTransform' );
$tmpFile->bind( $thumb ); // keep alive with $thumb
if ( !$thumb ) { // bad params?
wfIncrStats( 'image_cache_miss' );
}
-
return $this->dataLoaded;
}
}
if ( !$props ) {
- wfProfileIn( __METHOD__ . '-getProps' );
if ( $this->repo->isVirtualUrl( $srcPath )
|| FileBackend::isStoragePath( $srcPath )
) {
} else {
$props = FSFile::getPropsFromPath( $srcPath );
}
- wfProfileOut( __METHOD__ . '-getProps' );
}
$options = array();
$dbw->begin( __METHOD__ );
if ( !$props ) {
- wfProfileIn( __METHOD__ . '-getProps' );
$props = $this->repo->getFileProps( $this->getVirtualUrl() );
- wfProfileOut( __METHOD__ . '-getProps' );
}
# Imports or such might force a certain timestamp; otherwise we generate
// Page exists, do RC entry now (otherwise we wait for later).
$logEntry->publish( $logId );
}
- wfProfileIn( __METHOD__ . '-edit' );
if ( $exists ) {
# Create a null revision
$dbw->commit( __METHOD__ ); // commit before anything bad can happen
}
- wfProfileOut( __METHOD__ . '-edit' );
-
if ( $reupload ) {
# Delete old thumbnails
- wfProfileIn( __METHOD__ . '-purge' );
$this->purgeThumbnails();
- wfProfileOut( __METHOD__ . '-purge' );
# Remove the old file from the squid cache
SquidUpdate::purge( array( $this->getURL() ) );
}
# Hooks, hooks, the magic of hooks...
- wfProfileIn( __METHOD__ . '-hooks' );
Hooks::run( 'FileUpload', array( $this, $reupload, $descTitle->exists() ) );
- wfProfileOut( __METHOD__ . '-hooks' );
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
}
-
return true;
}
$this->runJobsLog( $job->toString() . " STARTING" );
// Run the job...
- wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
$jobStartTime = microtime( true );
try {
++$jobsRun;
MWExceptionHandler::logException( $e );
}
$timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 );
- wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
$timeMsTotal += $timeMs;
// Mark the job as done on success or when the job cannot be retried
}
}
+ /**
+ * @return array
+ * @since 1.25
+ */
+ public function getAllKeys() {
+ return array_keys( $this->cache );
+ }
+
/**
* Clear one or several cache entries, or all cache entries
*
$this->complete[$func]['subcalls'] = array();
}
- foreach( $this->hieraData as $key => $stats ) {
+ foreach ( $this->hieraData as $key => $stats ) {
list( $parent, $child ) = self::splitKey( $key );
if ( $parent !== null ) {
// Track call tree information
return $version;
}
-}
\ No newline at end of file
+}
global $wgEnotifWatchlist;
global $wgEnotifMinorEdits, $wgEnotifUserTalk;
-
# The following code is only run, if several conditions are met:
# 1. EmailNotification for pages (other than user_talk pages) must be enabled
# 2. minor edits (changes) are only regarded if the global flag indicates so
array( $this->escapeMagickOutput( $params['dstPath'] ) ) ) );
wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
- wfProfileIn( 'convert' );
$retval = 0;
$err = wfShellExecWithStderr( $cmd, $retval, $env );
- wfProfileOut( 'convert' );
if ( $retval !== 0 ) {
$this->logErrorForExternalProcess( $retval, $err, $cmd );
$cmd = str_replace( '%h', wfEscapeShellArg( $params['physicalHeight'] ),
str_replace( '%w', wfEscapeShellArg( $params['physicalWidth'] ), $cmd ) ); # Size
wfDebug( __METHOD__ . ": Running custom convert command $cmd\n" );
- wfProfileIn( 'convert' );
$retval = 0;
$err = wfShellExecWithStderr( $cmd, $retval );
- wfProfileOut( 'convert' );
if ( $retval !== 0 ) {
$this->logErrorForExternalProcess( $retval, $err, $cmd );
" -rotate " . wfEscapeShellArg( "-$rotation" ) . " " .
wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) );
wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
- wfProfileIn( 'convert' );
$retval = 0;
$err = wfShellExecWithStderr( $cmd, $retval );
- wfProfileOut( 'convert' );
if ( $retval !== 0 ) {
$this->logErrorForExternalProcess( $retval, $err, $cmd );
$cmd .= " | {$wgDjvuPostProcessor}";
}
$cmd .= ' > ' . wfEscapeShellArg( $dstPath ) . ') 2>&1';
- wfProfileIn( 'ddjvu' );
wfDebug( __METHOD__ . ": $cmd\n" );
$retval = '';
$err = wfShellExec( $cmd, $retval );
- wfProfileOut( 'ddjvu' );
$removed = $this->removeBadFile( $dstPath, $retval );
if ( $retval != 0 || $removed ) {
if ( isset( $wgDjvuDump ) ) {
# djvudump is faster as of version 3.5
# http://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583
- wfProfileIn( 'djvudump' );
$cmd = wfEscapeShellArg( $wgDjvuDump ) . ' ' . wfEscapeShellArg( $this->mFilename );
$dump = wfShellExec( $cmd );
$xml = $this->convertDumpToXML( $dump );
- wfProfileOut( 'djvudump' );
} elseif ( isset( $wgDjvuToXML ) ) {
- wfProfileIn( 'djvutoxml' );
$cmd = wfEscapeShellArg( $wgDjvuToXML ) . ' --without-anno --without-text ' .
wfEscapeShellArg( $this->mFilename );
$xml = wfShellExec( $cmd );
- wfProfileOut( 'djvutoxml' );
} else {
$xml = null;
}
# Text layer
if ( isset( $wgDjvuTxt ) ) {
- wfProfileIn( 'djvutxt' );
$cmd = wfEscapeShellArg( $wgDjvuTxt ) . ' --detail=page ' . wfEscapeShellArg( $this->mFilename );
wfDebug( __METHOD__ . ": $cmd\n" );
$retval = '';
$txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) );
- wfProfileOut( 'djvutxt' );
if ( $retval == 0 ) {
# Strip some control characters
$txt = preg_replace( "/[\013\035\037]/", "", $txt );
public function fetchExtendedMetadata( File $file ) {
global $wgMemc;
-
// If revision deleted, exit immediately
if ( $file->isDeleted( File::DELETED_FILE ) ) {
$wgMemc->set( $cacheKey, $valueToCache, $maxCacheTime );
}
-
return $extendedMetadata;
}
return $file->getExtendedMetadata() ?: array();
}
-
$uploadDate = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
$fileMetadata = array(
}
}
-
return $fileMetadata;
}
}
}
-
return $extendedMetadata;
}
" -outfile " . wfEscapeShellArg( $params['dstPath'] ) .
" " . wfEscapeShellArg( $params['srcPath'] );
wfDebug( __METHOD__ . ": running jpgtran: $cmd\n" );
- wfProfileIn( 'jpegtran' );
$retval = 0;
$err = wfShellExecWithStderr( $cmd, $retval );
- wfProfileOut( 'jpegtran' );
if ( $retval !== 0 ) {
$this->logErrorForExternalProcess( $retval, $err, $cmd );
$env['LANG'] = $lang;
}
- wfProfileIn( 'rsvg' );
wfDebug( __METHOD__ . ": $cmd\n" );
$err = wfShellExecWithStderr( $cmd, $retval, $env );
- wfProfileOut( 'rsvg' );
}
}
$removed = $this->removeBadFile( $dstPath, $retval );
} elseif ( function_exists( 'wincache_ucache_get' ) ) {
$id = 'wincache';
} else {
- if ( $fallback ) {
+ if ( $fallback !== null ) {
return self::newFromId( $fallback );
}
throw new MWException( "CACHE_ACCEL requested but no suitable object " .
return $this->mContent;
}
-
$content = $this->fetchContentObject();
if ( !$content ) {
$this->mContent = ContentHandler::getContentText( $content );
ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
-
return $this->mContent;
}
return $this->mContentObject;
}
-
$this->mContentLoaded = true;
$this->mContent = null;
Hooks::run( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) );
-
return $this->mContentObject;
}
public function view() {
global $wgUseFileCache, $wgUseETag, $wgDebugToolbar, $wgMaxRedirects;
-
# Get variables from query string
# As side effect this will load the revision and update the title
# in a revision ID is passed in the request, so this should remain
return false;
}
-
// New page patrol: Get the timestamp of the oldest revison which
// the revision table holds for the given page. Then we look
// whether it's within the RC lifespan and if it is, we try
$pool = new PoolWorkArticleView( $this, $parserOptions, $oldid, $useParserCache );
$pool->execute();
-
return $pool->getParserOutput();
}
) {
global $wgContentHandlerUseDB;
-
$content = $revision->getContent();
$len = $content ? $content->getSize() : 0;
$rt = $content ? $content->getUltimateRedirectTarget() : null;
throw new MWException( 'Something is trying to edit an article with an empty title' );
}
-
if ( !$content->getContentHandler()->canBeUsedOn( $this->getTitle() ) ) {
return Status::newFatal( 'content-not-allowed-here',
ContentHandler::getLocalizedName( $content->getModel() ),
public function doEditUpdates( Revision $revision, User $user, array $options = array() ) {
global $wgEnableParserCache;
-
$options += array(
'changed' => true,
'created' => false,
$this->replaceInternal( $text );
$this->replaceInterwiki( $text );
-
}
/**
$linkCache = LinkCache::singleton();
$output = $this->parent->getOutput();
- wfProfileIn( __METHOD__ . '-check' );
$dbr = wfGetDB( DB_SLAVE );
$threshold = $this->parent->getOptions()->getStubThreshold();
//pass an array of page_ids to an extension
Hooks::run( 'GetLinkColours', array( $linkcolour_ids, &$colours ) );
}
- wfProfileOut( __METHOD__ . '-check' );
# Do a second query for different language variants of links and categories
if ( $wgContLang->hasVariants() ) {
}
# Construct search and replace arrays
- wfProfileIn( __METHOD__ . '-construct' );
$replacePairs = array();
foreach ( $this->internals as $ns => $entries ) {
foreach ( $entries as $index => $entry ) {
}
}
$replacer = new HashtableReplacer( $replacePairs, 1 );
- wfProfileOut( __METHOD__ . '-construct' );
# Do the thing
- wfProfileIn( __METHOD__ . '-replace' );
$text = preg_replace_callback(
'/(<!--LINK .*?-->)/',
$replacer->cb(),
$text
);
- wfProfileOut( __METHOD__ . '-replace' );
}
/**
}
$this->mFirstCall = false;
-
CoreParserFunctions::register( $this );
CoreTagHooks::register( $this );
$this->initialiseVariables();
global $wgShowHostnames;
$fname = __METHOD__ . '-' . wfGetCaller();
- wfProfileIn( $fname );
if ( $clearState ) {
$magicScopeVariable = $this->lock();
$this->mRevisionSize = $oldRevisionSize;
$this->mInputSize = false;
$this->currentRevisionCache = null;
- wfProfileOut( $fname );
return $this->mOutput;
}
$out = '';
}
-
return $out;
}
public function replaceInternalLinks2( &$s ) {
global $wgExtraInterlanguageLinkPrefixes;
- wfProfileIn( __METHOD__ . '-setup' );
static $tc = false, $e1, $e1_img;
# the % is needed to support urlencoded titles as well
if ( !$tc ) {
}
if ( is_null( $this->mTitle ) ) {
- wfProfileOut( __METHOD__ . '-setup' );
throw new MWException( __METHOD__ . ": \$this->mTitle is null\n" );
}
$nottalk = !$this->mTitle->isTalkPage();
}
$useSubpages = $this->areSubpagesAllowed();
- wfProfileOut( __METHOD__ . '-setup' );
// @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
# Loop for each link
}
if ( $useLinkPrefixExtension ) {
- wfProfileIn( __METHOD__ . '-prefixhandling' );
if ( preg_match( $e2, $s, $m ) ) {
$prefix = $m[2];
$s = $m[1];
$prefix = $first_prefix;
$first_prefix = false;
}
- wfProfileOut( __METHOD__ . '-prefixhandling' );
}
$might_be_img = false;
- wfProfileIn( __METHOD__ . "-e1" );
if ( preg_match( $e1, $line, $m ) ) { # page with normal text or alt
$text = $m[2];
# If we get a ] at the beginning of $m[3] that means we have a link that's something like:
$trail = "";
} else { # Invalid form; output directly
$s .= $prefix . '[[' . $line;
- wfProfileOut( __METHOD__ . "-e1" );
continue;
}
- wfProfileOut( __METHOD__ . "-e1" );
- wfProfileIn( __METHOD__ . "-misc" );
$origLink = $m[1];
# should be external links.
if ( preg_match( '/^(?i:' . $this->mUrlProtocols . ')/', $origLink ) ) {
$s .= $prefix . '[[' . $line;
- wfProfileOut( __METHOD__ . "-misc" );
continue;
}
$link = substr( $link, 1 );
}
- wfProfileOut( __METHOD__ . "-misc" );
- wfProfileIn( __METHOD__ . "-title" );
$nt = Title::newFromText( $this->mStripState->unstripNoWiki( $link ) );
if ( $nt === null ) {
$s .= $prefix . '[[' . $line;
- wfProfileOut( __METHOD__ . "-title" );
continue;
}
$ns = $nt->getNamespace();
$iw = $nt->getInterwiki();
- wfProfileOut( __METHOD__ . "-title" );
if ( $might_be_img ) { # if this is actually an invalid link
- wfProfileIn( __METHOD__ . "-might_be_img" );
if ( $ns == NS_FILE && $noforce ) { # but might be an image
$found = false;
while ( true ) {
$holders->merge( $this->replaceInternalLinks2( $text ) );
$s .= "{$prefix}[[$link|$text";
# note: no $trail, because without an end, there *is* no trail
- wfProfileOut( __METHOD__ . "-might_be_img" );
continue;
}
} else { # it's not an image, so output it raw
$s .= "{$prefix}[[$link|$text";
# note: no $trail, because without an end, there *is* no trail
- wfProfileOut( __METHOD__ . "-might_be_img" );
continue;
}
- wfProfileOut( __METHOD__ . "-might_be_img" );
}
$wasblank = ( $text == '' );
# Link not escaped by : , create the various objects
if ( $noforce && !$nt->wasLocalInterwiki() ) {
# Interwikis
- wfProfileIn( __METHOD__ . "-interwiki" );
if (
$iw && $this->mOptions->getInterwikiMagic() && $nottalk && (
Language::fetchLanguageName( $iw, null, 'mw' ) ||
$s = rtrim( $s . $prefix );
$s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail;
- wfProfileOut( __METHOD__ . "-interwiki" );
continue;
}
- wfProfileOut( __METHOD__ . "-interwiki" );
if ( $ns == NS_FILE ) {
- wfProfileIn( __METHOD__ . "-image" );
if ( !wfIsBadImage( $nt->getDBkey(), $this->mTitle ) ) {
if ( $wasblank ) {
# if no parameters were passed, $text
} else {
$s .= $prefix . $trail;
}
- wfProfileOut( __METHOD__ . "-image" );
continue;
}
if ( $ns == NS_CATEGORY ) {
- wfProfileIn( __METHOD__ . "-category" );
$s = rtrim( $s . "\n" ); # bug 87
if ( $wasblank ) {
*/
$s .= trim( $prefix . $trail, "\n" ) == '' ? '' : $prefix . $trail;
- wfProfileOut( __METHOD__ . "-category" );
continue;
}
}
# NS_MEDIA is a pseudo-namespace for linking directly to a file
# @todo FIXME: Should do batch file existence checks, see comment below
if ( $ns == NS_MEDIA ) {
- wfProfileIn( __METHOD__ . "-media" );
# Give extensions a chance to select the file revision for us
$options = array();
$descQuery = false;
# Cloak with NOPARSE to avoid replacement in replaceExternalLinks
$s .= $prefix . $this->armorLinks(
Linker::makeMediaLinkFile( $nt, $file, $text ) ) . $trail;
- wfProfileOut( __METHOD__ . "-media" );
continue;
}
- wfProfileIn( __METHOD__ . "-always_known" );
# Some titles, such as valid special pages or files in foreign repos, should
# be shown as bluelinks even though they're not included in the page table
#
# Links will be added to the output link list after checking
$s .= $holders->makeHolder( $nt, $text, array(), $trail, $prefix );
}
- wfProfileOut( __METHOD__ . "-always_known" );
}
return $holders;
}
# If we have no prefixes, go to paragraph mode.
if ( 0 == $prefixLength ) {
- wfProfileIn( __METHOD__ . "-paragraph" );
# No prefix (not in list)--go to paragraph mode
# XXX: use a stack for nestable elements like span, table and div
$openmatch = preg_match(
}
}
}
- wfProfileOut( __METHOD__ . "-paragraph" );
}
# somewhere above we forget to get out of pre block (bug 785)
if ( $preCloseMatch && $this->mInPre ) {
* @return string The text of the template
*/
public function braceSubstitution( $piece, $frame ) {
- wfProfileIn( __METHOD__ . '-setup' );
// Flags
# @todo FIXME: If piece['parts'] is null then the call to getLength()
# below won't work b/c this $args isn't an object
$args = ( null == $piece['parts'] ) ? array() : $piece['parts'];
- wfProfileOut( __METHOD__ . '-setup' );
$profileSection = null; // profile templates
# SUBST
- wfProfileIn( __METHOD__ . '-modifiers' );
if ( !$found ) {
$substMatch = $this->mSubstWords->matchStartAndRemove( $part1 );
$forceRawInterwiki = true;
}
}
- wfProfileOut( __METHOD__ . '-modifiers' );
# Parser functions
if ( !$found ) {
- wfProfileIn( __METHOD__ . '-pfunc' );
$colonPos = strpos( $part1, ':' );
if ( $colonPos !== false ) {
try {
$result = $this->callParserFunction( $frame, $func, $funcArgs );
} catch ( Exception $ex ) {
- wfProfileOut( __METHOD__ . '-pfunc' );
throw $ex;
}
# here.
extract( $result );
}
- wfProfileOut( __METHOD__ . '-pfunc' );
}
# Finish mangling title and then check for loops.
# Load from database
if ( !$found && $title ) {
$profileSection = $this->mProfiler->scopedProfileIn( $title->getPrefixedDBkey() );
- wfProfileIn( __METHOD__ . '-loadtpl' );
if ( !$title->isExternal() ) {
if ( $title->isSpecialPage()
&& $this->mOptions->getAllowSpecialInclusion()
. '</span>';
wfDebug( __METHOD__ . ": template loop broken at '$titleText'\n" );
}
- wfProfileOut( __METHOD__ . '-loadtpl' );
}
# If we haven't found text to substitute by now, we're done
}
}
- wfProfileIn( __METHOD__ . '-pfunc-' . $function );
list( $callback, $flags ) = $this->mFunctionHooks[$function];
# Workaround for PHP bug 35229 and similar
if ( !is_callable( $callback ) ) {
- wfProfileOut( __METHOD__ . '-pfunc-' . $function );
throw new MWException( "Tag hook for $function is not callable\n" );
}
$result['text'] = $this->preprocessToDom( $result['text'], $preprocessFlags );
$result['isChildObj'] = true;
}
- wfProfileOut( __METHOD__ . '-pfunc-' . $function );
return $result;
}
$file = $this->fetchFileNoRegister( $title, $options );
$handler = $file ? $file->getHandler() : false;
- wfProfileIn( __METHOD__ . '-getMagicWord' );
$paramMap = array(
'img_alt' => 'gallery-internal-alt',
'img_link' => 'gallery-internal-link',
}
$mwArray = new MagicWordArray( array_keys( $paramMap ) );
- wfProfileOut( __METHOD__ . '-getMagicWord' );
$label = '';
$alt = '';
$wgCleanSignatures, $wgExternalLinkTarget, $wgExpensiveParserFunctionLimit,
$wgMaxGeneratedPPNodeCount, $wgDisableLangConversion, $wgDisableTitleConversion;
-
// *UPDATE* ParserOptions::matches() if any of this changes as needed
$this->mInterwikiMagic = $wgInterwikiMagic;
$this->mAllowExternalImages = $wgAllowExternalImages;
$xml .= "</list>";
- wfProfileIn( __METHOD__ . '-loadXML' );
$dom = new DOMDocument();
wfSuppressWarnings();
$result = $dom->loadXML( $xml );
// don't barf when the XML is >256 levels deep
$result = $dom->loadXML( $xml, 1 << 19 );
}
- wfProfileOut( __METHOD__ . '-loadXML' );
if ( !$result ) {
throw new MWException( 'Parameters passed to ' . __METHOD__ . ' result in invalid XML' );
$cacheable = ( $wgPreprocessorCacheThreshold !== false
&& strlen( $text ) > $wgPreprocessorCacheThreshold );
if ( $cacheable ) {
- wfProfileIn( __METHOD__ . '-cacheable' );
$cacheKey = wfMemcKey( 'preprocess-xml', md5( $text ), $flags );
$cacheValue = $wgMemc->get( $cacheKey );
}
}
if ( $xml === false ) {
- wfProfileIn( __METHOD__ . '-cache-miss' );
$xml = $this->preprocessToXml( $text, $flags );
$cacheValue = sprintf( "%08d", self::CACHE_VERSION ) . $xml;
$wgMemc->set( $cacheKey, $cacheValue, 86400 );
- wfProfileOut( __METHOD__ . '-cache-miss' );
wfDebugLog( "Preprocessor", "Saved preprocessor XML to memcached (key $cacheKey)" );
}
} else {
$max = $this->parser->mOptions->getMaxGeneratedPPNodeCount();
if ( $this->parser->mGeneratedPPNodeCount > $max ) {
if ( $cacheable ) {
- wfProfileOut( __METHOD__ . '-cacheable' );
}
throw new MWException( __METHOD__ . ': generated node count limit exceeded' );
}
- wfProfileIn( __METHOD__ . '-loadXML' );
$dom = new DOMDocument;
wfSuppressWarnings();
$result = $dom->loadXML( $xml );
if ( $result ) {
$obj = new PPNode_DOM( $dom->documentElement );
}
- wfProfileOut( __METHOD__ . '-loadXML' );
if ( $cacheable ) {
- wfProfileOut( __METHOD__ . '-cacheable' );
}
-
if ( !$result ) {
throw new MWException( __METHOD__ . ' generated invalid XML' );
}
$stack->rootAccum .= '</root>';
$xml = $stack->rootAccum;
-
return $xml;
}
}
&& strlen( $text ) > $wgPreprocessorCacheThreshold;
if ( $cacheable ) {
- wfProfileIn( __METHOD__ . '-cacheable' );
$cacheKey = wfMemcKey( 'preprocess-hash', md5( $text ), $flags );
$cacheValue = $wgMemc->get( $cacheKey );
// From the cache
wfDebugLog( "Preprocessor",
"Loaded preprocessor hash from memcached (key $cacheKey)" );
- wfProfileOut( __METHOD__ . '-cacheable' );
return $hash;
}
}
- wfProfileIn( __METHOD__ . '-cache-miss' );
}
$rules = array(
}
if ( !$node ) {
if ( $cacheable ) {
- wfProfileOut( __METHOD__ . '-cache-miss' );
- wfProfileOut( __METHOD__ . '-cacheable' );
}
throw new MWException( __METHOD__ . ': eqpos not found' );
}
if ( $node->name !== 'equals' ) {
if ( $cacheable ) {
- wfProfileOut( __METHOD__ . '-cache-miss' );
- wfProfileOut( __METHOD__ . '-cacheable' );
}
throw new MWException( __METHOD__ . ': eqpos is not equals' );
}
if ( $cacheable ) {
$cacheValue = sprintf( "%08d", self::CACHE_VERSION ) . serialize( $rootNode );
$wgMemc->set( $cacheKey, $cacheValue, 86400 );
- wfProfileOut( __METHOD__ . '-cache-miss' );
- wfProfileOut( __METHOD__ . '-cacheable' );
wfDebugLog( "Preprocessor", "Saved preprocessor Hash to memcached (key $cacheKey)" );
}
* Class for handling function-scope profiling
*
* @since 1.22
+ * @deprecated 1.25 No-op now
*/
class ProfileSection {
- /** @var string $name Method name */
- protected $name;
- /** @var boolean $enabled Is profiling enabled? */
- protected $enabled = false;
-
/**
* Begin profiling of a function and return an object that ends profiling
* of the function when that object leaves scope. As long as the object is
*
* @param string $name Name of the function to profile
*/
- public function __construct( $name ) {
- $this->name = $name;
- // Use Profiler member variable directly to reduce overhead
- if ( Profiler::$__instance === null ) {
- Profiler::instance();
- }
- if ( !( Profiler::$__instance instanceof ProfilerStub ) ) {
- $this->enabled = true;
- Profiler::$__instance->profileIn( $this->name );
- }
- }
-
- function __destruct() {
- if ( $this->enabled ) {
- Profiler::$__instance->profileOut( $this->name );
- }
- }
+ public function __construct( $name ) {}
}
}
}
- /**
- * Called by wfProfieIn()
- *
- * @param string $functionname
- */
- abstract public function profileIn( $functionname );
-
- /**
- * Called by wfProfieOut()
- *
- * @param string $functionname
- */
- abstract public function profileOut( $functionname );
-
/**
* Mark the start of a custom profiling frame (e.g. DB queries).
* The frame ends when the result of this method falls out of scope.
/**
* Begin profiling of a function
* @param string $functionname Name of the function we will profile
+ * @deprecated 1.25
*/
function wfProfileIn( $functionname ) {
- // Use Profiler member variable directly to reduce overhead
- if ( Profiler::$__instance === null ) {
- Profiler::instance();
- }
- if ( !( Profiler::$__instance instanceof ProfilerStub ) ) {
- Profiler::$__instance->profileIn( $functionname );
- }
}
/**
* Stop profiling of a function
* @param string $functionname Name of the function we have profiled
+ * @deprecated 1.25
*/
function wfProfileOut( $functionname = 'missing' ) {
- // Use Profiler member variable directly to reduce overhead
- if ( Profiler::$__instance === null ) {
- Profiler::instance();
- }
- if ( !( Profiler::$__instance instanceof ProfilerStub ) ) {
- Profiler::$__instance->profileOut( $functionname );
- }
}
--- /dev/null
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * Profiler that only tracks explicit profiling sections
+ *
+ * @code
+ * $wgProfiler['class'] = 'ProfilerSectionOnly';
+ * $wgProfiler['output'] = 'text';
+ * $wgProfiler['visible'] = true;
+ * @endcode
+ *
+ * @author Aaron Schulz
+ * @ingroup Profiler
+ * @since 1.25
+ */
+class ProfilerSectionOnly extends Profiler {
+ /** @var SectionProfiler */
+ protected $sprofiler;
+
+ public function __construct( array $params = array() ) {
+ parent::__construct( $params );
+ $this->sprofiler = new SectionProfiler();
+ }
+
+ public function scopedProfileIn( $section ) {
+ return $this->sprofiler->scopedProfileIn( $section );
+ }
+
+ public function close() {
+ }
+
+ public function getFunctionStats() {
+ return $this->sprofiler->getFunctionStats();
+ }
+
+ public function getOutput() {
+ return $this->getFunctionReport();
+ }
+
+ /**
+ * Get a report of profiled functions sorted by inclusive wall clock time
+ * in descending order.
+ *
+ * Each line of the report includes this data:
+ * - Function name
+ * - Number of times function was called
+ * - Total wall clock time spent in function in microseconds
+ * - Minimum wall clock time spent in function in microseconds
+ * - Average wall clock time spent in function in microseconds
+ * - Maximum wall clock time spent in function in microseconds
+ * - Percentage of total wall clock time spent in function
+ * - Total delta of memory usage from start to end of function in bytes
+ *
+ * @return string
+ */
+ protected function getFunctionReport() {
+ $data = $this->getFunctionStats();
+ usort( $data, function( $a, $b ) {
+ if ( $a['real'] === $b['real'] ) {
+ return 0;
+ }
+ return ( $a['real'] > $b['real'] ) ? -1 : 1; // descending
+ } );
+
+ $width = 140;
+ $nameWidth = $width - 65;
+ $format = "%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
+ $out = array();
+ $out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
+ 'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%', 'Mem'
+ );
+ foreach ( $data as $stats ) {
+ $out[] = sprintf( $format,
+ $stats['name'],
+ $stats['calls'],
+ $stats['real'] * 1000,
+ $stats['min_real'] * 1000,
+ $stats['real'] / $stats['calls'] * 1000,
+ $stats['max_real'] * 1000,
+ $stats['%real'],
+ $stats['memory']
+ );
+ }
+ return implode( "\n", $out );
+ }
+}
* @ingroup Profiler
*/
class ProfilerStub extends Profiler {
- public function profileIn( $fn ) {
- }
-
- public function profileOut( $fn ) {
- }
-
public function scopedProfileIn( $section ) {
return new ScopedCallback( null ); // no-op
}
* $wgProfiler['output'] = 'udp';
* @endcode
*
- * Rather than obeying wfProfileIn() and wfProfileOut() calls placed in the
- * application code, ProfilerXhprof profiles all functions using the XHProf
- * PHP extenstion. For PHP5 users, this extension can be installed via PECL or
- * your operating system's package manager. XHProf support is built into HHVM.
+ * ProfilerXhprof profiles all functions using the XHProf PHP extenstion.
+ * For PHP5 users, this extension can be installed via PECL or your operating
+ * system's package manager. XHProf support is built into HHVM.
*
* To restrict the functions for which profiling data is collected, you can
* use either a whitelist ($wgProfiler['include']) or a blacklist
$this->sprofiler = new SectionProfiler();
}
- /**
- * No-op for xhprof profiling.
- *
- * Use the 'include' configuration key instead if you need to constrain
- * the functions that are profiled.
- *
- * @param string $functionname
- */
- public function profileIn( $functionname ) {
- }
-
- /**
- * No-op for xhprof profiling.
- *
- * Use the 'include' configuration key instead if you need to constrain
- * the functions that are profiled.
- *
- * @param string $functionname
- */
- public function profileOut( $functionname ) {
- }
-
public function scopedProfileIn( $section ) {
return $this->sprofiler->scopedProfileIn( $section );
}
}
}
-
-
}
public function getExtractedInfo() {
$this->errors[] = self::formatExceptionNoComment( $e );
}
-
return $result;
}
public function __construct( Config $config = null ) {
global $IP;
-
if ( $config === null ) {
wfDebug( __METHOD__ . ' was called without providing a Config instance' );
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
. 'Edit your <code>LocalSettings.php</code> to enable it.' );
}
-
// Get core test suites
$testModules = array();
$testModules['qunit'] = array();
// See http://bugs.php.net/bug.php?id=36514
ob_start();
-
// Find out which modules are missing and instantiate the others
$modules = array();
$missing = array();
$this->errors[] = self::formatExceptionNoComment( $e );
}
- wfProfileIn( __METHOD__ . '-getModifiedTime' );
-
// To send Last-Modified and support If-Modified-Since, we need to detect
// the last modified time
$mtime = wfTimestamp( TS_UNIX, $this->config->get( 'CacheEpoch' ) );
}
}
- wfProfileOut( __METHOD__ . '-getModifiedTime' );
-
// If there's an If-Modified-Since header, respond with a 304 appropriately
if ( $this->tryRespondLastModified( $context, $mtime ) ) {
return; // output handled (buffers cleared)
no modules were requested. Max made me put this here. */";
}
-
$image = $context->getImageObj();
if ( $image ) {
$data = $image->getImageData( $context );
* @var $module ResourceLoaderModule
*/
- wfProfileIn( __METHOD__ . '-' . $name );
try {
$scripts = '';
if ( $context->shouldIncludeScripts() ) {
unset( $modules[$name] );
}
$isRaw |= $module->isRaw();
- wfProfileOut( __METHOD__ . '-' . $name );
}
// Update module states
return $this->modifiedTime[$context->getHash()];
}
- wfProfileIn( __METHOD__ . '-filemtime' );
$filesMtime = max( array_map( array( __CLASS__, 'safeFilemtime' ), $files ) );
- wfProfileOut( __METHOD__ . '-filemtime' );
$this->modifiedTime[$context->getHash()] = max(
$filesMtime,
/** @var bool */
protected $showSuggestion = true;
+ private $sort = 'relevance';
/** @var array Feature values */
protected $features = array();
$this->showSuggestion = $showSuggestion;
}
+ /**
+ * Get the valid sort directions. All search engines support 'relevance' but others
+ * might support more. The default in all implementations should be 'relevance.'
+ *
+ * @since 1.25
+ * @return array(string) the valid sort directions for setSort
+ */
+ public function getValidSorts() {
+ return array( 'relevance' );
+ }
+
+ /**
+ * Set the sort direction of the search results. Must be one returned by
+ * SearchEngine::getValidSorts()
+ *
+ * @since 1.25
+ * @throws InvalidArgumentException
+ * @param string $sort sort direction for query result
+ */
+ public function setSort( $sort ) {
+ if ( !in_array( $sort, $this->getValidSorts() ) ) {
+ throw new InvalidArgumentException( "Invalid sort: $sort. " .
+ "Must be one of: " . implode( ', ', $this->getValidSorts() ) );
+ }
+ $this->sort = $sort;
+ }
+
+ /**
+ * Get the sort direction of the search results
+ *
+ * @since 1.25
+ * @return string
+ */
+ public function getSort() {
+ return $this->sort;
+ }
+
/**
* Parse some common prefixes: all (search everything)
* or namespace names
$spat .= '/';
$textExt = array(); // text extracts
$otherExt = array(); // other extracts
- wfProfileIn( "$fname-split" );
$start = 0;
$textLen = strlen( $text );
$count = 0; // sequence number to maintain ordering
$all = $textExt + $otherExt; // these have disjunct key sets
- wfProfileOut( "$fname-split" );
-
// prepare regexps
foreach ( $terms as $index => $term ) {
// manually do upper/lowercase stuff for utf-8 since PHP won't do it
$pat1 = "/(" . $phrase . ")/ui";
$pat2 = "/$patPre(" . $anyterm . ")$patPost/ui";
- wfProfileIn( "$fname-extract" );
-
$left = $contextlines;
$snippets = array();
}
}
- wfProfileOut( "$fname-extract" );
-
return $extract;
}
*/
function removeWiki( $text ) {
$fname = __METHOD__;
- wfProfileIn( $fname );
// $text = preg_replace( "/'{2,5}/", "", $text );
// $text = preg_replace( "/\[[a-z]+:\/\/[^ ]+ ([^]]+)\]/", "\\2", $text );
$text = preg_replace( "/('''|<\/?[iIuUbB]>)/", "", $text );
$text = preg_replace( "/''/", "", $text );
- wfProfileOut( $fname );
return $text;
}
$lineno = 0;
$extract = "";
- wfProfileIn( "$fname-extract" );
foreach ( $lines as $line ) {
if ( 0 == $contextlines ) {
break;
$extract .= "${line}\n";
}
- wfProfileOut( "$fname-extract" );
return $extract;
}
function normalizeText( $string ) {
global $wgContLang;
-
$out = parent::normalizeText( $string );
// MySQL fulltext index doesn't grok utf-8, so we
"$1u82e$2",
$out );
-
return $out;
}
private function getCachedNotice( $name ) {
global $wgRenderHashAppend, $parserMemc, $wgContLang;
-
$needParse = false;
if ( $name === 'default' ) {
$user = $this->getUser();
$title = $this->getTitle();
- wfProfileIn( __METHOD__ . '-init' );
$tpl = $this->setupTemplate( $this->template, 'skins' );
- wfProfileOut( __METHOD__ . '-init' );
- wfProfileIn( __METHOD__ . '-stuff' );
$this->thispage = $title->getPrefixedDBkey();
$this->titletxt = $title->getPrefixedText();
$this->userpage = $user->getUserPage()->getPrefixedText();
$this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
}
- wfProfileOut( __METHOD__ . '-stuff' );
-
-
return $tpl;
}
$out = $this->getOutput();
- wfProfileIn( __METHOD__ . '-init' );
$this->initPage( $out );
- wfProfileOut( __METHOD__ . '-init' );
$tpl = $this->prepareQuickTemplate( $out );
// execute template
- wfProfileIn( __METHOD__ . '-execute' );
$res = $tpl->execute();
- wfProfileOut( __METHOD__ . '-execute' );
// result may be an error
$this->printOrError( $res );
$wgShowCreditsIfMax, $wgArticlePath,
$wgScriptPath, $wgServer;
-
$title = $this->getTitle();
$request = $this->getRequest();
$out = $this->getOutput();
$tpl = $this->setupTemplateForOutput();
- wfProfileIn( __METHOD__ . '-stuff2' );
$tpl->set( 'title', $out->getPageTitle() );
$tpl->set( 'pagetitle', $out->getHTMLTitle() );
$tpl->set( 'displaytitle', $out->mPageLinkTitle );
$tpl->set( 'userlangattributes', $attrs );
}
- wfProfileOut( __METHOD__ . '-stuff2' );
-
- wfProfileIn( __METHOD__ . '-stuff3' );
$tpl->set( 'newtalk', $this->getNewtalks() );
$tpl->set( 'logo', $this->logoText() );
}
$tpl->set( 'copyright', $this->getCopyright() );
}
- wfProfileOut( __METHOD__ . '-stuff3' );
- wfProfileIn( __METHOD__ . '-stuff4' );
$tpl->set( 'copyrightico', $this->getCopyrightIcon() );
$tpl->set( 'poweredbyico', $this->getPoweredBy() );
$tpl->set( 'disclaimer', $this->disclaimerLink() );
} else {
$tpl->set( 'language_urls', false );
}
- wfProfileOut( __METHOD__ . '-stuff4' );
- wfProfileIn( __METHOD__ . '-stuff5' );
# Personal toolbar
$tpl->set( 'personal_urls', $this->buildPersonalUrls() );
$content_navigation = $this->buildContentNavigationUrls();
// allow extensions adding stuff after the page content.
// See Skin::afterContentHook() for further documentation.
$tpl->set( 'dataAfterContent', $this->afterContentHook() );
- wfProfileOut( __METHOD__ . '-stuff5' );
return $tpl;
}
protected function buildContentNavigationUrls() {
global $wgDisableLangConversion;
-
// Display tabs for the relevant title rather than always the title itself
$title = $this->getRelevantTitle();
$onPage = $title->equals( $this->getTitle() );
);
}
- wfProfileIn( __METHOD__ . '-edit' );
-
// Checks if user can edit the current page if it exists or create it otherwise
if ( $title->quickUserCan( 'edit', $user )
&& ( $title->exists() || $title->quickUserCan( 'create', $user ) )
'primary' => true, // don't collapse this in vector
);
}
- wfProfileOut( __METHOD__ . '-edit' );
- wfProfileIn( __METHOD__ . '-live' );
// Checks if the page exists
if ( $title->exists() ) {
// Adds history view link
);
}
- wfProfileOut( __METHOD__ . '-live' );
-
// Checks if the user is logged in
if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
/**
}
}
-
return $content_navigation;
}
*/
private function buildContentActionUrls( $content_navigation ) {
-
// content_actions has been replaced with content_navigation for backwards
// compatibility and also for skins that just want simple tabs content_actions
// is now built by flattening the content_navigation arrays into one
}
}
-
return $content_actions;
}
protected function buildNavUrls() {
global $wgUploadNavigationUrl;
-
$out = $this->getOutput();
$request = $this->getRequest();
// Normalise message names so they look like page titles
$messageNames = array_map( array( $this->lang, 'ucfirst' ), $messageNames );
-
return $messageNames;
}
*/
public static function getCustomisedStatuses( $messageNames, $langcode = 'en', $foreign = false ) {
// FIXME: This function should be moved to Language:: or something.
- wfProfileIn( __METHOD__ . '-db' );
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'page',
}
}
- wfProfileOut( __METHOD__ . '-db' );
-
return array( 'pages' => $pageFlags, 'talks' => $talkFlags );
}
$ret = Html::rawElement( 'li', array( 'class' => $classes ), $ret ) . "\n";
}
-
return $ret;
}
$ret = Html::rawElement( 'li', array(), $ret ) . "\n";
-
return $ret;
}
$this->userGroupCache = $cache;
// Add page of groups to link batch
- foreach( $groups as $group => $unused ) {
+ foreach ( $groups as $group => $unused ) {
$groupPage = User::getGroupPage( $group );
if ( $groupPage ) {
$batch->addObj( $groupPage );
$batch->execute();
$this->mResult->seek( 0 );
-
return '';
}
)->escaped();
}
-
// @todo i18n: This should use a comma separator instead of a hard coded comma, right?
return '<li>' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "</li>\n";
}
)->text();
}
-
return $version;
}
}
}
-
return $v;
}
list( $vcsVersion, $vcsLink, $vcsDate ) = $cache->get( $memcKey );
if ( !$vcsVersion ) {
- wfDebug( "Getting VCS info for extension $extensionName" );
+ wfDebug( "Getting VCS info for extension {$extension['name']}" );
$gitInfo = new GitInfo( $extensionPath );
$vcsVersion = $gitInfo->getHeadSHA1();
if ( $vcsVersion !== false ) {
}
$cache->set( $memcKey, array( $vcsVersion, $vcsLink, $vcsDate ), 60 * 60 * 24 );
} else {
- wfDebug( "Pulled VCS info for extension $extensionName from cache" );
+ wfDebug( "Pulled VCS info for extension {$extension['name']} from cache" );
}
}
// ... now get the authors for this extension
$authors = isset( $extension['author'] ) ? $extension['author'] : array();
- $authors = $this->listAuthors( $authors, $extensionName, $extensionPath );
+ $authors = $this->listAuthors( $authors, $extension['name'], $extensionPath );
// Finally! Create the table
$html = Html::openElement( 'tr', array(
'class' => 'mw-version-ext',
- 'id' => "mw-version-ext-{$extensionName}"
+ 'id' => "mw-version-ext-{$extension['name']}"
)
);
return array( 'status' => self::HOOK_ABORTED, 'error' => $error );
}
-
return array( 'status' => self::OK );
}
}
}
-
return true;
}
return array( 'uploadvirus', $virus );
}
-
return true;
}
}
}
-
return $warnings;
}
$this->postProcessUpload();
}
-
return $status;
}
$file = $stash->stashFile( $this->mTempPath, $this->getSourceType() );
$this->mLocalFile = $file;
-
return $file;
}
wfDebug( __METHOD__ . ": FOUND VIRUS! scanner feedback: $output \n" );
}
-
return $output;
}
// entropy so this is also preferable to just trying to read urandom because it may work
// on Windows systems as well.
if ( function_exists( 'mcrypt_create_iv' ) ) {
- wfProfileIn( __METHOD__ . '-mcrypt' );
$rem = $bytes - strlen( $buffer );
$iv = mcrypt_create_iv( $rem, MCRYPT_DEV_URANDOM );
if ( $iv === false ) {
wfDebug( __METHOD__ . ": mcrypt_create_iv generated " . strlen( $iv ) .
" bytes of randomness.\n" );
}
- wfProfileOut( __METHOD__ . '-mcrypt' );
}
}
if ( function_exists( 'openssl_random_pseudo_bytes' )
&& ( !wfIsWindows() || version_compare( PHP_VERSION, '5.3.4', '>=' ) )
) {
- wfProfileIn( __METHOD__ . '-openssl' );
$rem = $bytes - strlen( $buffer );
$openssl_bytes = openssl_random_pseudo_bytes( $rem, $openssl_strong );
if ( $openssl_bytes === false ) {
// using it use it's say on whether the randomness is strong
$this->strong = !!$openssl_strong;
}
- wfProfileOut( __METHOD__ . '-openssl' );
}
}
if ( strlen( $buffer ) < $bytes &&
( function_exists( 'stream_set_read_buffer' ) || $forceStrong )
) {
- wfProfileIn( __METHOD__ . '-fopen-urandom' );
$rem = $bytes - strlen( $buffer );
if ( !function_exists( 'stream_set_read_buffer' ) && $forceStrong ) {
wfDebug( __METHOD__ . ": Was forced to read from /dev/urandom " .
} else {
wfDebug( __METHOD__ . ": /dev/urandom could not be opened.\n" );
}
- wfProfileOut( __METHOD__ . '-fopen-urandom' );
}
// If we cannot use or generate enough data from a secure source
": Falling back to using a pseudo random state to generate randomness.\n" );
}
while ( strlen( $buffer ) < $bytes ) {
- wfProfileIn( __METHOD__ . '-fallback' );
$buffer .= $this->hmac( $this->randomState(), mt_rand() );
// This code is never really cryptographically strong, if we use it
// at all, then set strong to false.
$this->strong = false;
- wfProfileOut( __METHOD__ . '-fallback' );
}
// Once the buffer has been filled up with enough random data to fulfill
wfDebug( __METHOD__ . ": " . strlen( $buffer ) .
" bytes of randomness leftover in the buffer.\n" );
-
return $generated;
}
*/
function replace( $subject ) {
if ( function_exists( 'fss_prep_replace' ) ) {
- wfProfileIn( __METHOD__ . '-fss' );
if ( $this->fss === false ) {
$this->fss = fss_prep_replace( $this->data );
}
$result = fss_exec_replace( $this->fss, $subject );
- wfProfileOut( __METHOD__ . '-fss' );
} else {
- wfProfileIn( __METHOD__ . '-strtr' );
$result = strtr( $subject, $this->data );
- wfProfileOut( __METHOD__ . '-strtr' );
}
return $result;
$this->mTables = array(
'zh-hans' => new ReplacementArray( $zh2Hans ),
'zh-hant' => new ReplacementArray( $zh2Hant ),
- 'zh-cn' => new ReplacementArray( array_merge( $zh2Hans, $zh2CN ) ),
- 'zh-hk' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ),
- 'zh-mo' => new ReplacementArray( array_merge( $zh2Hant, $zh2HK ) ),
- 'zh-my' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ),
- 'zh-sg' => new ReplacementArray( array_merge( $zh2Hans, $zh2SG ) ),
- 'zh-tw' => new ReplacementArray( array_merge( $zh2Hant, $zh2TW ) ),
+ 'zh-cn' => new ReplacementArray( $zh2CN ),
+ 'zh-hk' => new ReplacementArray( $zh2HK ),
+ 'zh-mo' => new ReplacementArray( $zh2HK ),
+ 'zh-my' => new ReplacementArray( $zh2SG ),
+ 'zh-sg' => new ReplacementArray( $zh2SG ),
+ 'zh-tw' => new ReplacementArray( $zh2TW ),
'zh' => new ReplacementArray
);
}
function postLoadTables() {
- $this->mTables['zh-cn']->merge( $this->mTables['zh-hans'] );
- $this->mTables['zh-hk']->merge( $this->mTables['zh-hant'] );
- $this->mTables['zh-mo']->merge( $this->mTables['zh-hant'] );
- $this->mTables['zh-my']->merge( $this->mTables['zh-hans'] );
- $this->mTables['zh-sg']->merge( $this->mTables['zh-hans'] );
- $this->mTables['zh-tw']->merge( $this->mTables['zh-hant'] );
+ $this->mTables['zh-cn']->setArray(
+ $this->mTables['zh-cn']->getArray() + $this->mTables['zh-hans']->getArray()
+ );
+ $this->mTables['zh-hk']->setArray(
+ $this->mTables['zh-hk']->getArray() + $this->mTables['zh-hant']->getArray()
+ );
+ $this->mTables['zh-mo']->setArray(
+ $this->mTables['zh-mo']->getArray() + $this->mTables['zh-hant']->getArray()
+ );
+ $this->mTables['zh-my']->setArray(
+ $this->mTables['zh-my']->getArray() + $this->mTables['zh-hans']->getArray()
+ );
+ $this->mTables['zh-sg']->setArray(
+ $this->mTables['zh-sg']->getArray() + $this->mTables['zh-hans']->getArray()
+ );
+ $this->mTables['zh-tw']->setArray(
+ $this->mTables['zh-tw']->getArray() + $this->mTables['zh-hant']->getArray()
+ );
}
/**
require __DIR__ . '/includes/WebStart.php';
-wfProfileIn( 'load.php' );
// URL safety checks
if ( !$wgRequest->checkUrlExtension() ) {
$resourceLoader = new ResourceLoader( $configFactory->makeConfig( 'main' ) );
$resourceLoader->respond( new ResourceLoaderContext( $resourceLoader, $wgRequest ) );
-wfProfileOut( 'load.php' );
wfLogProfilingData();
// Shut down the database.
$lb->setServerInfo( $i, $server );
}
}
- if ( $d > 2 ) {
- $wgDebugFunctionEntry = true;
- }
}
$__useReadline = function_exists( 'readline_add_history' )
// Standalone icons
//
// Markup:
- // <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-ok">OK</div>
- // <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-ok mw-ui-button mw-ui-progressive">OK</div>
+ // <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-ok">OK</div><br/>
+ // <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-ok mw-ui-button mw-ui-progressive">OK</div><br/>
+ // <button class="mw-ui-icon mw-ui-icon-ok mw-ui-icon-element mw-ui-button mw-ui-quiet" title="">Close</button>
//
// Styleguide 6.1.1.
&.mw-ui-icon-element {
*/
class SiteListFileCacheBuilderTest extends PHPUnit_Framework_TestCase {
- public function testBuild() {
- $cacheFile = $this->getCacheFile();
+ protected function setUp() {
+ $this->cacheFile = $this->getCacheFile();
+ }
- $cacheBuilder = $this->newSiteListFileCacheBuilder( $this->getSites(), $cacheFile );
+ protected function tearDown() {
+ unlink( $this->cacheFile );
+ }
+
+ public function testBuild() {
+ $cacheBuilder = $this->newSiteListFileCacheBuilder( $this->getSites() );
$cacheBuilder->build();
- $contents = file_get_contents( $cacheFile );
+ $contents = file_get_contents( $this->cacheFile );
$this->assertEquals( json_encode( $this->getExpectedData() ), $contents );
}
);
}
- private function newSiteListFileCacheBuilder( SiteList $sites, $cacheFile ) {
+ private function newSiteListFileCacheBuilder( SiteList $sites ) {
return new SiteListFileCacheBuilder(
$this->getSiteSQLStore( $sites ),
- $cacheFile
+ $this->cacheFile
);
}
}
private function getCacheFile() {
- return sys_get_temp_dir() . '/sites-' . time() . '.json';
+ return tempnam( sys_get_temp_dir(), 'mw-test-sitelist' );
}
}
*/
class SiteListFileCacheTest extends PHPUnit_Framework_TestCase {
- public function testGetSites() {
- $cacheFile = $this->getCacheFile();
+ protected function setUp() {
+ $this->cacheFile = $this->getCacheFile();
+ }
+
+ protected function tearDown() {
+ unlink( $this->cacheFile );
+ }
+ public function testGetSites() {
$sites = $this->getSites();
- $cacheBuilder = $this->newSiteListFileCacheBuilder( $sites, $cacheFile );
+ $cacheBuilder = $this->newSiteListFileCacheBuilder( $sites );
$cacheBuilder->build();
- $cache = new SiteListFileCache( $cacheFile );
+ $cache = new SiteListFileCache( $this->cacheFile );
$this->assertEquals( $sites, $cache->getSites() );
}
public function testGetSite() {
- $cacheFile = $this->getCacheFile();
-
$sites = $this->getSites();
- $cacheBuilder = $this->newSiteListFileCacheBuilder( $sites, $cacheFile );
+ $cacheBuilder = $this->newSiteListFileCacheBuilder( $sites );
$cacheBuilder->build();
- $cache = new SiteListFileCache( $cacheFile );
+ $cache = new SiteListFileCache( $this->cacheFile );
$this->assertEquals( $sites->getSite( 'enwiktionary' ), $cache->getSite( 'enwiktionary' ) );
}
- private function newSiteListFileCacheBuilder( SiteList $sites, $cacheFile ) {
+ private function newSiteListFileCacheBuilder( SiteList $sites ) {
return new SiteListFileCacheBuilder(
$this->getSiteSQLStore( $sites ),
- $cacheFile
+ $this->cacheFile
);
}
}
private function getCacheFile() {
- return sys_get_temp_dir() . '/sites-' . time() . '.json';
+ return tempnam( sys_get_temp_dir(), 'mw-test-sitelist' );
}
}