* Follow-up r90749

** Tweaked addAutopromoteOnceGroups() calls for performance
** Some doc tweaks and fixes
* Added NS_SPECIAL short-circuit on $wgTitle for file cache and removed unnecessary "is null" check
* Pushed "$action != 'raw'" check into HTMLFileCache
* Removed useless return value from performRequest()
* Added type hint to performAction()
This commit is contained in:
Aaron Schulz 2011-06-25 17:59:42 +00:00
parent 3326066328
commit 16eb5f6e41
4 changed files with 29 additions and 31 deletions

View file

@ -33,9 +33,11 @@ class Autopromote {
* Does not return groups the user already belongs to or has once belonged.
*
* @param $user The user to get the groups for
* @param $event String 'onEdit' or 'onView' (each one has groups/criteria)
*
* @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
*
* @return array Groups the user should be promoted to.
*
* @see $wgAutopromoteOnce
*/
public static function getAutopromoteOnceGroups( User $user, $event ) {
global $wgAutopromoteOnce;

View file

@ -1110,11 +1110,11 @@ class User {
* will not be re-added automatically. The user will also not lose the
* group if they no longer meet the criteria.
*
* @param $event String 'onEdit' or 'onView' (each one has groups/criteria)
* @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
*
* @return array Array of groups the user has been promoted to.
*
* @see $wgAutopromote
* @see $wgAutopromoteOnce
*/
public function addAutopromoteOnceGroups( $event ) {
if ( $this->getId() ) {
@ -2346,7 +2346,7 @@ class User {
'ug_user' => $this->getID(),
'ug_group' => $group,
), __METHOD__ );
//remember that the user has had this group
// Remember that the user was in this group
$dbw->insert( 'user_former_groups',
array(
'ufg_user' => $this->getID(),

View file

@ -101,7 +101,7 @@ class MediaWiki {
* - special pages
* - normal pages
*
* @return Article object
* @return void
*/
public function performRequest() {
global $wgServer, $wgUsePathInfo;
@ -113,22 +113,15 @@ class MediaWiki {
$output = $this->context->getOutput();
$user = $this->context->getUser();
# Promote user to any groups they meet the criteria for
$user->addAutopromoteOnceGroups( 'onView' );
if ( $request->getVal( 'printable' ) === 'yes' ) {
$output->setPrintable();
}
wfRunHooks( 'BeforeInitialize', array(
&$title,
null,
&$output,
&$user,
$request,
$this
) );
$pageView = false; // was an article or special page viewed?
wfRunHooks( 'BeforeInitialize',
array( &$title, null, &$output, &$user, $request, $this ) );
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if ( $title instanceof BadTitle ) {
throw new ErrorPageError( 'badtitle', 'badtitletext' );
@ -196,13 +189,15 @@ class MediaWiki {
}
// Special pages
} elseif ( NS_SPECIAL == $title->getNamespace() ) {
// actions that need to be made when we have a special pages
$pageView = true;
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath( $title, $this->context );
} else {
// ...otherwise treat it as an article view. The article
// may be a redirect to another article or URL.
$article = $this->initializeArticle();
if ( is_object( $article ) ) {
$pageView = true;
/**
* $wgArticle is deprecated, do not use it. This will possibly be removed
* entirely in 1.20 or 1.21
@ -212,8 +207,6 @@ class MediaWiki {
$wgArticle = $article;
$this->performAction( $article );
wfProfileOut( __METHOD__ );
return $article;
} elseif ( is_string( $article ) ) {
$output->redirect( $article );
} else {
@ -221,6 +214,12 @@ class MediaWiki {
throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" );
}
}
if ( $pageView ) {
// Promote user to any groups they meet the criteria for
$user->addAutopromoteOnceGroups( 'onView' );
}
wfProfileOut( __METHOD__ );
}
@ -406,7 +405,7 @@ class MediaWiki {
*
* @param $article Article
*/
private function performAction( $article ) {
private function performAction( Article $article ) {
global $wgSquidMaxage, $wgUseExternalEditor;
wfProfileIn( __METHOD__ );
@ -416,9 +415,8 @@ class MediaWiki {
$title = $this->context->getTitle();
$user = $this->context->getUser();
if ( !wfRunHooks( 'MediaWikiPerformAction', array(
$output, $article, $title,
$user, $request, $this ) ) )
if ( !wfRunHooks( 'MediaWikiPerformAction',
array( $output, $article, $title, $user, $request, $this ) ) )
{
wfProfileOut( __METHOD__ );
return;
@ -561,11 +559,11 @@ class MediaWiki {
return;
}
if ( $wgUseFileCache && $wgTitle !== null ) {
if ( $wgUseFileCache && $wgTitle->getNamespace() != NS_SPECIAL ) {
wfProfileIn( 'main-try-filecache' );
// Raw pages should handle cache control on their own,
// even when using file cache. This reduces hits from clients.
if ( $action != 'raw' && HTMLFileCache::useFileCache() ) {
if ( HTMLFileCache::useFileCache() ) {
/* Try low-level file cache hit */
$cache = new HTMLFileCache( $wgTitle, $action );
if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) {

View file

@ -93,16 +93,14 @@ class HTMLFileCache {
foreach( $queryVals as $query => $val ) {
if( $query == 'title' || $query == 'curid' ) {
continue;
}
// Normal page view in query form can have action=view.
// Raw hits for pages also stored, like .css pages for example.
elseif( $query == 'action' && ($val == 'view' || $val == 'raw') ) {
} elseif( $query == 'action' && $val == 'view' ) {
continue;
} elseif( $query == 'usemsgcache' && $val == 'yes' ) {
continue;
}
// Below are header setting params
elseif( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' ) {
} elseif( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' ) {
continue;
} else {
return false;