X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMediaWiki.php;h=3fe656e1d5e64aa695027bea9b0c970d6cdd40d4;hb=4ff813680;hp=87468bd2bf0710546a3e61cd7cfa68827bf0186e;hpb=d5aac726d092b30545f92a8936b3ddbe907213d7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 87468bd2bf..3fe656e1d5 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -59,7 +59,7 @@ class MediaWiki { $request = $this->context->getRequest(); $curid = $request->getInt( 'curid' ); $title = $request->getVal( 'title' ); - $action = $request->getVal( 'action', 'view' ); + $action = $request->getVal( 'action' ); if ( $request->getCheck( 'search' ) ) { // Compatibility with old search URLs which didn't use Special:Search @@ -157,7 +157,6 @@ class MediaWiki { private function performRequest() { global $wgTitle; - wfProfileIn( __METHOD__ ); $request = $this->context->getRequest(); $requestTitle = $title = $this->context->getTitle(); @@ -169,14 +168,13 @@ class MediaWiki { } $unused = null; // To pass it by reference - wfRunHooks( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) ); + Hooks::run( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) ); // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. if ( is_null( $title ) || ( $title->getDBkey() == '' && !$title->isExternal() ) || $title->isSpecial( 'Badtitle' ) ) { $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) ); - wfProfileOut( __METHOD__ ); throw new BadTitleError(); } @@ -201,7 +199,6 @@ class MediaWiki { $this->context->setTitle( $badTitle ); $wgTitle = $badTitle; - wfProfileOut( __METHOD__ ); throw new PermissionsError( 'read', $permErrors ); } @@ -225,7 +222,6 @@ class MediaWiki { $output->redirect( $url, 301 ); } else { $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) ); - wfProfileOut( __METHOD__ ); throw new BadTitleError(); } // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant @@ -233,7 +229,7 @@ class MediaWiki { && ( $request->getVal( 'title' ) === null || $title->getPrefixedDBkey() != $request->getVal( 'title' ) ) && !count( $request->getValueNames( array( 'action', 'title' ) ) ) - && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) + && Hooks::run( 'TestCanonicalRedirect', array( $request, $title, $output ) ) ) { if ( $title->isSpecialPage() ) { list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); @@ -283,7 +279,6 @@ class MediaWiki { } elseif ( is_string( $article ) ) { $output->redirect( $article ); } else { - wfProfileOut( __METHOD__ ); throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL" ); } @@ -294,7 +289,6 @@ class MediaWiki { $user->addAutopromoteOnceGroups( 'onView' ); } - wfProfileOut( __METHOD__ ); } /** @@ -304,7 +298,6 @@ class MediaWiki { * @return mixed An Article, or a string to redirect to another URL */ private function initializeArticle() { - wfProfileIn( __METHOD__ ); $title = $this->context->getTitle(); if ( $this->context->canUseWikiPage() ) { @@ -322,7 +315,6 @@ class MediaWiki { // NS_MEDIAWIKI has no redirects. // It is also used for CSS/JS, so performance matters here... if ( $title->getNamespace() == NS_MEDIAWIKI ) { - wfProfileOut( __METHOD__ ); return $article; } @@ -342,7 +334,7 @@ class MediaWiki { // Give extensions a change to ignore/handle redirects as needed $ignoreRedirect = $target = false; - wfRunHooks( 'InitializeArticleMaybeRedirect', + Hooks::run( 'InitializeArticleMaybeRedirect', array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) ); // Follow redirects only for... redirects. @@ -353,7 +345,6 @@ class MediaWiki { if ( is_string( $target ) ) { if ( !$this->config->get( 'DisableHardRedirects' ) ) { // we'll need to redirect - wfProfileOut( __METHOD__ ); return $target; } } @@ -374,7 +365,6 @@ class MediaWiki { } } - wfProfileOut( __METHOD__ ); return $article; } @@ -385,17 +375,15 @@ class MediaWiki { * @param Title $requestTitle The original title, before any redirects were applied */ private function performAction( Page $page, Title $requestTitle ) { - wfProfileIn( __METHOD__ ); $request = $this->context->getRequest(); $output = $this->context->getOutput(); $title = $this->context->getTitle(); $user = $this->context->getUser(); - if ( !wfRunHooks( 'MediaWikiPerformAction', + if ( !Hooks::run( 'MediaWikiPerformAction', array( $output, $page, $title, $user, $request, $this ) ) ) { - wfProfileOut( __METHOD__ ); return; } @@ -412,16 +400,14 @@ class MediaWiki { } $action->show(); - wfProfileOut( __METHOD__ ); return; } - if ( wfRunHooks( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) { + if ( Hooks::run( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) { $output->setStatusCode( 404 ); $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); } - wfProfileOut( __METHOD__ ); } /** @@ -446,7 +432,7 @@ class MediaWiki { $this->triggerJobs(); $this->restInPeace(); } catch ( Exception $e ) { - MWExceptionHandler::handle( $e ); + MWExceptionHandler::handleException( $e ); } } @@ -456,7 +442,6 @@ class MediaWiki { * @return bool */ private function checkMaxLag() { - wfProfileIn( __METHOD__ ); $maxLag = $this->context->getRequest()->getVal( 'maxlag' ); if ( !is_null( $maxLag ) ) { list( $host, $lag ) = wfGetLB()->getMaxLag(); @@ -472,25 +457,21 @@ class MediaWiki { echo "Waiting for a database server: $lag seconds lagged\n"; } - wfProfileOut( __METHOD__ ); exit; } } - wfProfileOut( __METHOD__ ); return true; } private function main() { global $wgTitle; - wfProfileIn( __METHOD__ ); $request = $this->context->getRequest(); // Send Ajax requests to the Ajax dispatcher. - if ( $this->config->get( 'UseAjax' ) && $request->getVal( 'action', 'view' ) == 'ajax' ) { - + if ( $this->config->get( 'UseAjax' ) && $request->getVal( 'action' ) === 'ajax' ) { // Set a dummy title, because $wgTitle == null might break things $title = Title::makeTitle( NS_MAIN, 'AJAX' ); $this->context->setTitle( $title ); @@ -498,7 +479,6 @@ class MediaWiki { $dispatcher = new AjaxDispatcher( $this->config ); $dispatcher->performAction( $this->context->getUser() ); - wfProfileOut( __METHOD__ ); return; } @@ -530,7 +510,7 @@ class MediaWiki { $redirUrl = preg_replace( '#^http://#', 'https://', $oldUrl ); // ATTENTION: This hook is likely to be removed soon due to overall design of the system. - if ( wfRunHooks( 'BeforeHttpsRedirect', array( $this->context, &$redirUrl ) ) ) { + if ( Hooks::run( 'BeforeHttpsRedirect', array( $this->context, &$redirUrl ) ) ) { if ( $request->wasPosted() ) { // This is weird and we'd hope it almost never happens. This @@ -551,13 +531,11 @@ class MediaWiki { $output->addVaryHeader( 'X-Forwarded-Proto' ); $output->redirect( $redirUrl ); $output->output(); - wfProfileOut( __METHOD__ ); return; } } 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 ); @@ -572,12 +550,9 @@ class MediaWiki { $this->context->getWikiPage()->doViewUpdates( $this->context->getUser() ); // Tell OutputPage that output is taken care of $this->context->getOutput()->disable(); - wfProfileOut( 'main-try-filecache' ); - wfProfileOut( __METHOD__ ); return; } } - wfProfileOut( 'main-try-filecache' ); } // Actually do the work of the request and build up any output @@ -593,7 +568,6 @@ class MediaWiki { // Output everything! $this->context->getOutput()->output(); - wfProfileOut( __METHOD__ ); } /** @@ -627,7 +601,6 @@ class MediaWiki { return; // recursion guard } - $section = new ProfileSection( __METHOD__ ); if ( $jobRunRate < 1 ) { $max = mt_getrandmax(); @@ -682,7 +655,7 @@ class MediaWiki { } $url = wfAppendQuery( wfScript( 'index' ), $query ); - $req = "POST $url HTTP/1.1\r\nHost: {$info['host']}\r\nConnection: Close\r\n\r\n"; + $req = "POST $url HTTP/1.1\r\nHost: {$info['host']}\r\nConnection: Close\r\nContent-Length: 0\r\n\r\n"; wfDebugLog( 'runJobs', "Running $n job(s) via '$url'\n" ); // Send a cron API request to be performed in the background.