* 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() ) {
'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(),
* - special pages
* - normal pages
*
- * @return Article object
+ * @return void
*/
public function performRequest() {
global $wgServer, $wgUsePathInfo;
$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' );
}
// 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
$wgArticle = $article;
$this->performAction( $article );
- wfProfileOut( __METHOD__ );
- return $article;
} elseif ( is_string( $article ) ) {
$output->redirect( $article );
} else {
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__ );
}
*
* @param $article Article
*/
- private function performAction( $article ) {
+ private function performAction( Article $article ) {
global $wgSquidMaxage, $wgUseExternalEditor;
wfProfileIn( __METHOD__ );
$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;
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 */ ) ) {