diff options
Diffstat (limited to 'includes/api/ApiQueryLogEvents.php')
-rw-r--r-- | includes/api/ApiQueryLogEvents.php | 85 |
1 files changed, 57 insertions, 28 deletions
diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 83c73b83..864aaa03 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -59,18 +59,21 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->addWhere($hideLogs); // Order is significant here - $this->addTables(array('user', 'page', 'logging')); + $this->addTables(array('logging', 'user', 'page')); + $this->addOption('STRAIGHT_JOIN'); $this->addJoinConds(array( + 'user' => array('JOIN', + 'user_id=log_user'), 'page' => array('LEFT JOIN', array( 'log_namespace=page_namespace', 'log_title=page_title')))); - $this->addWhere('user_id=log_user'); - $this->addOption('USE INDEX', array('logging' => 'times')); // default, may change + $index = 'times'; // default, may change $this->addFields(array ( 'log_type', 'log_action', 'log_timestamp', + 'log_deleted', )); $this->addFieldsIf('log_id', $this->fld_ids); @@ -81,20 +84,17 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->addFieldsIf('log_title', $this->fld_title); $this->addFieldsIf('log_comment', $this->fld_comment); $this->addFieldsIf('log_params', $this->fld_details); - - $this->addWhereFld('log_deleted', 0); if( !is_null($params['type']) ) { $this->addWhereFld('log_type', $params['type']); - $this->addOption('USE INDEX', array('logging' => array('type_time'))); + $index = 'type_time'; } $this->addWhereRange('log_timestamp', $params['dir'], $params['start'], $params['end']); $limit = $params['limit']; $this->addOption('LIMIT', $limit +1); - - $index = false; + $user = $params['user']; if (!is_null($user)) { $userid = User::idFromName($user); @@ -113,14 +113,19 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->addWhereFld('log_title', $titleObj->getDBkey()); // Use the title index in preference to the user index if there is a conflict - $index = 'page_time'; - } - if ( $index ) { - $this->addOption( 'USE INDEX', array( 'logging' => $index ) ); + $index = is_null($user) ? 'page_time' : array('page_time','user_time'); } + $this->addOption( 'USE INDEX', array( 'logging' => $index ) ); + + // Paranoia: avoid brute force searches (bug 17342) + if (!is_null($title)) { + $this->addWhere('log_deleted & ' . LogPage::DELETED_ACTION . ' = 0'); + } + if (!is_null($user)) { + $this->addWhere('log_deleted & ' . LogPage::DELETED_USER . ' = 0'); + } - $data = array (); $count = 0; $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { @@ -131,13 +136,18 @@ class ApiQueryLogEvents extends ApiQueryBase { } $vals = $this->extractRowInfo($row); - if($vals) - $data[] = $vals; + if(!$vals) + continue; + $fit = $this->getResult()->addValue(array('query', $this->getModuleName()), null, $vals); + if(!$fit) + { + $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->log_timestamp)); + break; + } } $db->freeResult($res); - $this->getResult()->setIndexedTagName($data, 'item'); - $this->getResult()->addValue('query', $this->getModuleName(), $data); + $this->getResult()->setIndexedTagName_internal(array('query', $this->getModuleName()), 'item'); } public static function addLogParams($result, &$vals, $params, $type, $ts) { @@ -150,9 +160,12 @@ class ApiQueryLogEvents extends ApiQueryBase { $vals2 = array(); ApiQueryBase :: addTitleInfo($vals2, $title, "new_"); $vals[$type] = $vals2; - $params = null; } } + if (isset ($params[1]) && $params[1]) { + $vals[$type]['suppressedredirect'] = ''; + } + $params = null; break; case 'patrol': $vals2 = array(); @@ -191,8 +204,12 @@ class ApiQueryLogEvents extends ApiQueryBase { } if ($this->fld_title) { - $title = Title :: makeTitle($row->log_namespace, $row->log_title); - ApiQueryBase :: addTitleInfo($vals, $title); + if (LogEventsList::isDeleted($row, LogPage::DELETED_ACTION)) { + $vals['actionhidden'] = ''; + } else { + $title = Title :: makeTitle($row->log_namespace, $row->log_title); + ApiQueryBase :: addTitleInfo($vals, $title); + } } if ($this->fld_type) { @@ -201,21 +218,33 @@ class ApiQueryLogEvents extends ApiQueryBase { } if ($this->fld_details && $row->log_params !== '') { - self::addLogParams($this->getResult(), $vals, - $row->log_params, $row->log_type, - $row->log_timestamp); + if (LogEventsList::isDeleted($row, LogPage::DELETED_ACTION)) { + $vals['actionhidden'] = ''; + } else { + self::addLogParams($this->getResult(), $vals, + $row->log_params, $row->log_type, + $row->log_timestamp); + } } if ($this->fld_user) { - $vals['user'] = $row->user_name; - if(!$row->log_user) - $vals['anon'] = ''; + if (LogEventsList::isDeleted($row, LogPage::DELETED_USER)) { + $vals['userhidden'] = ''; + } else { + $vals['user'] = $row->user_name; + if(!$row->log_user) + $vals['anon'] = ''; + } } if ($this->fld_timestamp) { $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->log_timestamp); } if ($this->fld_comment && isset($row->log_comment)) { - $vals['comment'] = $row->log_comment; + if (LogEventsList::isDeleted($row, LogPage::DELETED_COMMENT)) { + $vals['commenthidden'] = ''; + } else { + $vals['comment'] = $row->log_comment; + } } return $vals; @@ -290,6 +319,6 @@ class ApiQueryLogEvents extends ApiQueryBase { } public function getVersion() { - return __CLASS__ . ': $Id: ApiQueryLogEvents.php 44234 2008-12-04 15:59:26Z catrope $'; + return __CLASS__ . ': $Id: ApiQueryLogEvents.php 47904 2009-03-01 11:02:49Z catrope $'; } } |