http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90776
Revision: 90776
Author: aaron
Date: 2011-06-25 17:59:42 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
* 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()
Modified Paths:
--------------
trunk/phase3/includes/Autopromote.php
trunk/phase3/includes/User.php
trunk/phase3/includes/Wiki.php
trunk/phase3/includes/cache/HTMLFileCache.php
Modified: trunk/phase3/includes/Autopromote.php
===================================================================
--- trunk/phase3/includes/Autopromote.php 2011-06-25 16:41:29 UTC (rev
90775)
+++ trunk/phase3/includes/Autopromote.php 2011-06-25 17:59:42 UTC (rev
90776)
@@ -33,9 +33,11 @@
* 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;
Modified: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php 2011-06-25 16:41:29 UTC (rev 90775)
+++ trunk/phase3/includes/User.php 2011-06-25 17:59:42 UTC (rev 90776)
@@ -1110,11 +1110,11 @@
* 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 @@
'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(),
Modified: trunk/phase3/includes/Wiki.php
===================================================================
--- trunk/phase3/includes/Wiki.php 2011-06-25 16:41:29 UTC (rev 90775)
+++ trunk/phase3/includes/Wiki.php 2011-06-25 17:59:42 UTC (rev 90776)
@@ -101,7 +101,7 @@
* - special pages
* - normal pages
*
- * @return Article object
+ * @return void
*/
public function performRequest() {
global $wgServer, $wgUsePathInfo;
@@ -113,22 +113,15 @@
$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 @@
}
// 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 @@
$wgArticle = $article;
$this->performAction( $article );
- wfProfileOut( __METHOD__ );
- return $article;
} elseif ( is_string( $article ) ) {
$output->redirect( $article );
} else {
@@ -221,6 +214,12 @@
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 @@
*
* @param $article Article
*/
- private function performAction( $article ) {
+ private function performAction( Article $article ) {
global $wgSquidMaxage, $wgUseExternalEditor;
wfProfileIn( __METHOD__ );
@@ -416,9 +415,8 @@
$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 @@
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 */ ) ) {
Modified: trunk/phase3/includes/cache/HTMLFileCache.php
===================================================================
--- trunk/phase3/includes/cache/HTMLFileCache.php 2011-06-25 16:41:29 UTC
(rev 90775)
+++ trunk/phase3/includes/cache/HTMLFileCache.php 2011-06-25 17:59:42 UTC
(rev 90776)
@@ -93,16 +93,14 @@
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;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs