'page' => array( 'LEFT JOIN',
array( 'log_namespace=page_namespace',
'log_title=page_title' ) ) ) );
- $index = array( 'logging' => 'times' ); // default, may change
$this->addFields( array(
'log_type',
$this->addWhereFld( 'log_action', $action );
} elseif ( !is_null( $params['type'] ) ) {
$this->addWhereFld( 'log_type', $params['type'] );
- $index['logging'] = 'type_time';
}
$this->addTimestampWhereRange(
$user = $params['user'];
if ( !is_null( $user ) ) {
$userid = User::idFromName( $user );
- if ( !$userid ) {
- $this->dieUsage( "User name $user not found", 'param_user' );
+ if ( $userid ) {
+ $this->addWhereFld( 'log_user', $userid );
+ } else {
+ $this->addWhereFld( 'log_user_text', IP::sanitizeIP( $user ) );
}
- $this->addWhereFld( 'log_user', $userid );
- $index['logging'] = 'user_time';
}
$title = $params['title'];
}
$this->addWhereFld( 'log_namespace', $titleObj->getNamespace() );
$this->addWhereFld( 'log_title', $titleObj->getDBkey() );
-
- // Use the title index in preference to the user index if there is a conflict
- $index['logging'] = is_null( $user ) ? 'page_time' : array( 'page_time', 'user_time' );
}
$prefix = $params['prefix'];
$this->addWhere( 'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() ) );
}
- $this->addOption( 'USE INDEX', $index );
-
// Paranoia: avoid brute force searches (bug 17342)
if ( !is_null( $title ) ) {
$this->addWhere( $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0' );
/* Fetch userid at first, if known, provides awesome query plan afterwards */
$userid = User::idFromName( $name );
if ( !$userid ) {
- /* It should be nicer to abort query at all,
- but for now it won't pass anywhere behind the optimizer */
- $this->mConds[] = "NULL";
+ $this->mConds['log_user_text'] = IP::sanitizeIP( $name );
} else {
$this->mConds['log_user'] = $userid;
- // Paranoia: avoid brute force searches (bug 17342)
- $user = $this->getUser();
- if ( !$user->isAllowed( 'deletedhistory' ) ) {
- $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0';
- } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
- $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) .
- ' != ' . LogPage::SUPPRESSED_USER;
- }
- $this->performer = $usertitle->getText();
}
+ // Paranoia: avoid brute force searches (bug 17342)
+ $user = $this->getUser();
+ if ( !$user->isAllowed( 'deletedhistory' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0';
+ } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) .
+ ' != ' . LogPage::SUPPRESSED_USER;
+ }
+ $this->performer = $usertitle->getText();
}
/**