r35867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35866‎ | r35867 | r35868 >
Date:16:56, 4 June 2008
Author:brion
Status:old
Tags:
Comment:
Revert r35857, 35858, 35859 for the moment. Some notes:

* Calling $user->isActiveUser() looks a bit redundant. :) Consider either shortening it to isActive() or changing the last word to be clearer, say $user->isActiveEditor()
* $wgActiveUserEditcount <- consider fully casing here; "editcount" isn't a word. :D -> $wgActiveUserEditCount
* $oldTime is dumped into SQL without any escaping or quoting. This will happen to work on MySQL but will fail on PostgreSQL, and is generally a bad practice. Use addQuotes() to ensure the formatted timestamp string is escaped and quoted for your raw SQL construct
* the database result object is not freed, which will leak resources if used in a long-running script
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2445,29 +2445,6 @@
24462446 function isNewbie() {
24472447 return !$this->isAllowed( 'autoconfirmed' );
24482448 }
2449 -
2450 - /**
2451 - * Is the user active? We check to see if they've made at least
2452 - * X number of edits in the last Y days.
2453 - *
2454 - * @return bool true if the user is active, false if not
2455 - */
2456 - public function isActiveUser() {
2457 - global $wgActiveUserEditcount, $wgActiveUserDays;
2458 - $dbr = wfGetDB( DB_SLAVE );
2459 -
2460 - // Stolen without shame from RC
2461 - $cutoff_unixtime = time() - ( $wgActiveUserDays * 86400 );
2462 - $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
2463 - $oldTime = $dbr->timestamp( $cutoff_unixtime );
2464 -
2465 - $res = $dbr->select( 'revision', '1',
2466 - array( 'rev_user_text' => $this->getName(), "rev_timestamp > $oldTime"),
2467 - __METHOD__,
2468 - array('LIMIT' => $wgActiveUserEditcount ) );
2469 -
2470 - return $dbr->numRows($res) == $wgActiveUserEditcount ? true : false;
2471 - }
24722449
24732450 /**
24742451 * Check to see if the given clear-text password is one of the accepted passwords
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1280,14 +1280,6 @@
12811281 */
12821282 $wgDeleteRevisionsLimit = 0;
12831283
1284 -/**
1285 - * Used to figure out if a user is "active" or not. User::isActiveUser()
1286 - * sees if a user has made at least $wgActiveUserEditcount number of edits
1287 - * within the last $wgActiveUserDays days.
1288 - */
1289 -$wgActiveUserEditcount = 30;
1290 -$wgActiveUserDays = 30;
1291 -
12921284 # Proxy scanner settings
12931285 #
12941286
Index: trunk/phase3/RELEASE-NOTES
@@ -49,9 +49,6 @@
5050 (default 100) with the new subpage-move functionality of Special:Movepage
5151 * Hooks display in Special:Version is now disabled by default, use
5252 $wgSpecialVersionShowHooks = true; to enable it.
53 -* $wgActiveUserEditcount sets the number of edits that must be performed over
54 - a certain number of days to be considered active
55 -* $wgActiveUserDays is that number of days
5653
5754 === New features in 1.13 ===
5855
@@ -138,9 +135,6 @@
139136 * (bug 14263) Show a diff of the revert on rollback notification page.
140137 * (bug 13434) Show a warning when hash identical files exist
141138 * Sidebar is now cached for all languages
142 -* The User class now contains a public function called isActiveUser. Figures
143 - out if a user is active based on at least $wgActiveUserEditcount number of
144 - edits in the last $wgActiveUserDays days.
145139
146140 === Bug fixes in 1.13 ===
147141

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r35857Implement User::isUserActive(). Potentially very useful for bugs 13225 and 13...demon13:15, 4 June 2008

Status & tagging log