80 $pattern =
false, $conds = [], $year =
false, $month =
false, $day =
false,
81 $tagFilter =
'',
$action =
'', $logId = 0
83 parent::__construct( $list->getContext() );
84 $this->mConds = $conds;
86 $this->mLogEventsList = $list;
95 $this->mTagFilter = (string)$tagFilter;
101 $query = parent::getDefaultQuery();
116 foreach ( $filterTypes as
$type => $hide ) {
118 $this->mConds[] =
'log_type != ' . $this->mDb->addQuotes(
$type );
125 if ( count( $this->types ) ) {
129 $wpfilters = $this->
getRequest()->getArray(
"wpfilters" );
130 $filterLogTypes = $this->
getConfig()->get(
'FilterLogTypes' );
132 foreach ( $filterLogTypes as
$type => $default ) {
134 if ( $wpfilters ===
null ) {
135 $hide = $this->
getRequest()->getBool(
"hide_{$type}_log", $default );
137 $hide = !in_array(
$type, $wpfilters );
140 $filters[
$type] = $hide;
155 $restrictions = $this->
getConfig()->get(
'LogRestrictions' );
159 $needReindex =
false;
161 if ( isset( $restrictions[
$type] )
162 && !MediaWikiServices::getInstance()
163 ->getPermissionManager()
164 ->userHasRight( $user, $restrictions[
$type] )
170 if ( $needReindex ) {
178 $audience =
$types ?
'user' :
'public';
179 $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience, $user );
180 if ( $hideLogs !==
false ) {
181 $this->mConds[] = $hideLogs;
184 $this->mConds[
'log_type'] =
$types;
186 if ( count(
$types ) == 1 ) {
187 $this->typeCGI =
$types[0];
202 $usertitle = Title::makeTitleSafe(
NS_USER, $name );
203 if ( $usertitle ===
null ) {
208 $name = $usertitle->getText();
211 $this->mConds[] = ActorMigration::newMigration()->getWhere(
217 $this->performer = $name;
229 if ( $page instanceof
Title ) {
232 $title = Title::newFromText( $page );
233 if ( strlen( $page ) == 0 || !
$title instanceof
Title ) {
242 $interwikiDelimiter = $this->
getConfig()->get(
'UserrightsInterwikiDelimiter' );
244 $doUserRightsLogLike =
false;
245 if ( $this->types == [
'rights' ] ) {
247 if ( count( $parts ) == 2 ) {
248 list( $name, $database ) = array_map(
'trim', $parts );
249 if ( strstr( $database,
'*' ) ) {
250 $doUserRightsLogLike =
true;
268 $this->mConds[
'log_namespace'] = $ns;
269 if ( $doUserRightsLogLike ) {
270 $params = [ $name . $interwikiDelimiter ];
271 foreach ( explode(
'*', $database ) as $databasepart ) {
272 $params[] = $databasepart;
273 $params[] = $db->anyString();
275 array_pop( $params );
276 $this->mConds[] =
'log_title' . $db->buildLike( ...$params );
278 $this->mConds[] =
'log_title' . $db->buildLike(
$title->
getDBkey(), $db->anyString() );
294 if (
$type ===
'' ) {
298 $actions = $this->
getConfig()->get(
'ActionFilteredLogs' );
299 if ( isset( $actions[
$type] ) ) {
301 $this->mLogEventsList->setAllowedActions( array_keys( $actions[
$type] ) );
318 $this->mConds[
'log_id'] = $logId;
327 $basic = DatabaseLogEntry::getSelectQueryData();
329 $tables = $basic[
'tables'];
330 $fields = $basic[
'fields'];
331 $conds = $basic[
'conds'];
332 $options = $basic[
'options'];
333 $joins = $basic[
'join_conds'];
335 # Add log_search table if there are conditions on it.
336 # This filters the results to only include log rows that have
337 # log_search records with the specified ls_field and ls_value values.
338 if ( array_key_exists(
'ls_field', $this->mConds ) ) {
339 $tables[] =
'log_search';
340 $options[
'IGNORE INDEX'] = [
'log_search' =>
'ls_log_id' ];
341 $options[
'USE INDEX'] = [
'logging' =>
'PRIMARY' ];
345 # Since (ls_field,ls_value,ls_logid) is unique, if the condition is
346 # to match a specific (ls_field,ls_value) tuple, then there will be
347 # no duplicate log rows. Otherwise, we need to remove the duplicates.
348 $options[] =
'DISTINCT';
351 # Don't show duplicate rows when using log_search
352 $joins[
'log_search'] = [
'JOIN',
'ls_log_id=log_id' ];
358 if ( $this->mTagFilter ===
'' && !array_key_exists(
'ls_field', $this->mConds ) ) {
359 $options[] =
'STRAIGHT_JOIN';
361 if ( $this->performer !==
'' || $this->types !== [] ) {
364 $options[
'IGNORE INDEX'] = [
'logging' => [
'times' ] ];
367 $options[
'MAX_EXECUTION_TIME'] = $this->
getConfig()->get(
'MaxExecutionTimeForExpensiveQueries' );
372 'conds' => array_merge( $conds, $this->mConds ),
373 'options' => $options,
374 'join_conds' => $joins,
376 # Add ChangeTags filter query
378 $info[
'join_conds'], $info[
'options'], $this->mTagFilter );
390 array_key_exists( $field, $this->mConds ) &&
391 ( !is_array( $this->mConds[$field] ) || count( $this->mConds[$field] ) == 1 )
396 return 'log_timestamp';
400 # Do a link batch query
403 foreach ( $this->mResult as $row ) {
404 $lb->
add( $row->log_namespace, $row->log_title );
405 $lb->addObj( Title::makeTitleSafe(
NS_USER, $row->user_name ) );
406 $lb->addObj( Title::makeTitleSafe(
NS_USER_TALK, $row->user_name ) );
408 foreach ( $formatter->getPreloadTitles() as
$title ) {
413 $this->mResult->seek( 0 );
420 return $this->mLogEventsList->logLine( $row );
472 $this->mDb->setBigSelects();
474 $this->mDb->setBigSelects(
'default' );
481 if ( $this->actionRestrictionsEnforced ) {
484 $this->actionRestrictionsEnforced =
true;
486 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
487 if ( !$permissionManager->userHasRight( $user,
'deletedhistory' ) ) {
489 } elseif ( !$permissionManager->userHasAnyRight( $user,
'suppressrevision',
'viewsuppressed' ) ) {
500 if ( $this->performerRestrictionsEnforced ) {
503 $this->performerRestrictionsEnforced =
true;
505 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
506 if ( !$permissionManager->userHasRight( $user,
'deletedhistory' ) ) {
508 } elseif ( !$permissionManager->userHasAnyRight( $user,
'suppressrevision',
'viewsuppressed' ) ) {
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getUser()
Stable to override.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getDBkey()
Get the main part with underscores.
getPrefixedText()
Get the prefixed title with spaces.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.