r45365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45364‎ | r45365 | r45366 >
Date:12:53, 3 January 2009
Author:aaron
Status:ok (Comments)
Tags:
Comment:
(bug 14737) Allow the autoconfirmed timer to run from the first edit
Modified paths:
  • /trunk/phase3/includes/Autopromote.php (modified) (history)
  • /trunk/phase3/includes/Defines.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Defines.php
@@ -226,3 +226,4 @@
227227 define( 'APCOND_INGROUPS', 4 );
228228 define( 'APCOND_ISIP', 5 );
229229 define( 'APCOND_IPINRANGE', 6 );
 230+define( 'APCOND_AGE_FROM_EDIT', 7 );
Index: trunk/phase3/includes/User.php
@@ -2989,10 +2989,28 @@
29902990 * non-existent/anonymous user accounts.
29912991 */
29922992 public function getRegistration() {
2993 - return $this->mId > 0
 2993+ return $this->getId() > 0
29942994 ? $this->mRegistration
29952995 : false;
29962996 }
 2997+
 2998+ /**
 2999+ * Get the timestamp of the first edit
 3000+ *
 3001+ * @return \types{\string,\bool} string Timestamp of first edit, or false for
 3002+ * non-existent/anonymous user accounts.
 3003+ */
 3004+ public function getFirstEditTimestamp() {
 3005+ if( $this->getId() == 0 ) return false; // anons
 3006+ $dbr = wfGetDB( DB_SLAVE );
 3007+ $time = $dbr->selectField( 'revision', 'rev_timestamp',
 3008+ array( 'rev_user' => $this->getId() ),
 3009+ __METHOD__,
 3010+ array( 'ORDER BY' => 'rev_timestamp ASC' )
 3011+ );
 3012+ if( !$time ) return false; // no edits
 3013+ return wfTimestamp( TS_MW, $time );
 3014+ }
29973015
29983016 /**
29993017 * Get the permissions associated with a given list of groups
Index: trunk/phase3/includes/Autopromote.php
@@ -106,6 +106,9 @@
107107 case APCOND_AGE:
108108 $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
109109 return $age >= $cond[1];
 110+ case APCOND_AGE_FROM_EDIT:
 111+ $age = time() - wfTimestampOrNull( TS_UNIX, $user->getFirstEditTimestamp() );
 112+ return $age >= $cond[1];
110113 case APCOND_INGROUPS:
111114 $groups = array_slice( $cond, 1 );
112115 return count( array_intersect( $groups, $user->getGroups() ) ) == count( $groups );

Comments

#Comment by Brion VIBBER (talk | contribs)   01:55, 7 January 2009

Why not use MIN(rev_timestamp) here rather than the order/limit thing?

#Comment by Simetrical (talk | contribs)   23:29, 19 February 2009

This didn't update the DefaultSettings.php documentation for $wgAutopromote.

Status & tagging log