r104621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104620‎ | r104621 | r104622 >
Date:23:49, 29 November 2011
Author:krinkle
Status:ok
Tags:
Comment:
[UserDailyContribs] Don't check wgAuth unless it's configured to do so.
* Although the extension was written specifically for WMF's needs during the UsabilityInitiative. It turns out that it's fairly general and usable for for more than that. Currently it's being used by some banners in CentralNotice to make API requests in order to conditionally show banners containing invitations for surveys.
* Adding this option to allow easier local debugging without to install for example CentralAuth etc.

SCAPTRAP: This new variable must be set to true before deployment, or the world *will* come to an end.
Modified paths:
  • /trunk/extensions/UserDailyContribs/UserDailyContribs.php (modified) (history)
  • /trunk/extensions/UserDailyContribs/api/ApiUserDailyContribs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UserDailyContribs/api/ApiUserDailyContribs.php
@@ -14,8 +14,9 @@
1515 $this->dieUsage( 'Invalid username', 'bad_user' );
1616 }
1717
18 - global $wgAuth;
19 - if ( !$wgAuth->userExists( $userName ) ) {
 18+ global $wgAuth, $wgUserDailyContributionsApiCheckAuthPlugin;
 19+
 20+ if ( $wgUserDailyContributionsApiCheckAuthPlugin && !$wgAuth->userExists( $userName ) ) {
2021 $this->dieUsage( 'Specified user does not exist', 'bad_user' );
2122 }
2223 $now = time();
Index: trunk/extensions/UserDailyContribs/UserDailyContribs.php
@@ -32,6 +32,16 @@
3333 $wgAPIModules['userdailycontribs'] = 'ApiUserDailyContribs';
3434
3535 /**
 36+ * Whether or not API calls should require
 37+ * that the given user name exists in whatever authentication
 38+ * is set up in $wgAuth. Note that by default, on a plain install
 39+ * there is no authentication plugin, hence all checks for existance
 40+ * return to false.
 41+ * If you use CentralAuth you'd probably want to set this to true.
 42+ */
 43+$wgUserDailyContributionsApiCheckAuthPlugin = false;
 44+
 45+/**
3646 * Get the number of revisions a user has made since a given time
3747 *
3848 * @param $time beginning timestamp

Status & tagging log