+ $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'item' );
+ }
+
+ /**
+ * Validate the 'user' parameter and set the value to compare
+ * against `revision`.`rev_user_text`
+ */
+ private function prepareUsername( $user ) {
+ if ( !is_null( $user ) && $user !== '' ) {
+ $name = User::isIP( $user )
+ ? $user
+ : User::getCanonicalName( $user, 'valid' );
+ if ( $name === false ) {
+ $this->dieUsage( "User name {$user} is not valid", 'param_user' );
+ } else {
+ $this->usernames[] = $name;
+ }
+ } else {
+ $this->dieUsage( 'User parameter may not be empty', 'param_user' );
+ }
+ }
+
+ /**
+ * Prepares the query and returns the limit of rows requested
+ */
+ private function prepareQuery() {
+ // We're after the revision table, and the corresponding page
+ // row for anything we retrieve. We may also need the
+ // recentchanges row and/or tag summary row.
+ global $wgUser;
+ $tables = array( 'page', 'revision' ); // Order may change
+ $this->addWhere( 'page_id=rev_page' );
+
+ // Handle continue parameter
+ if ( $this->multiUserMode && !is_null( $this->params['continue'] ) ) {
+ $continue = explode( '|', $this->params['continue'] );
+ if ( count( $continue ) != 2 ) {
+ $this->dieUsage( 'Invalid continue param. You should pass the original ' .
+ 'value returned by the previous query', '_badcontinue' );
+ }
+ $encUser = $this->getDB()->strencode( $continue[0] );
+ $encTS = wfTimestamp( TS_MW, $continue[1] );
+ $op = ( $this->params['dir'] == 'older' ? '<' : '>' );
+ $this->addWhere(
+ "rev_user_text $op '$encUser' OR " .
+ "(rev_user_text = '$encUser' AND " .
+ "rev_timestamp $op= '$encTS')"
+ );
+ }
+
+ if ( !$wgUser->isAllowed( 'hideuser' ) ) {
+ $this->addWhere( $this->getDB()->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
+ }
+ // We only want pages by the specified users.
+ if ( $this->prefixMode ) {
+ $this->addWhere( 'rev_user_text' . $this->getDB()->buildLike( $this->userprefix, $this->getDB()->anyString() ) );
+ } else {
+ $this->addWhereFld( 'rev_user_text', $this->usernames );
+ }