2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* Implements Special:Recentchanges
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-15 07:16:58 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2010-06-21 12:59:04 +00:00
|
|
|
*/
|
2008-06-26 19:12:52 +00:00
|
|
|
|
2016-04-15 16:29:05 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2018-04-04 12:52:10 +00:00
|
|
|
use Wikimedia\Rdbms\IResultWrapper;
|
2017-03-20 14:26:47 +00:00
|
|
|
use Wikimedia\Rdbms\FakeResultWrapper;
|
2016-04-15 16:29:05 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* A special page that lists last changes made to the wiki
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2013-12-09 11:11:14 +00:00
|
|
|
class SpecialRecentChanges extends ChangesListSpecialPage {
|
2017-05-02 23:39:21 +00:00
|
|
|
|
2017-09-20 00:54:55 +00:00
|
|
|
protected static $savedQueriesPreferenceName = 'rcfilters-saved-queries';
|
2017-11-02 23:15:36 +00:00
|
|
|
protected static $daysPreferenceName = 'rcdays'; // Use general RecentChanges preference
|
|
|
|
|
protected static $limitPreferenceName = 'rcfilters-limit'; // Use RCFilters-specific preference
|
2018-06-18 22:04:47 +00:00
|
|
|
protected static $collapsedPreferenceName = 'rcfilters-rc-collapsed';
|
2017-09-20 00:54:55 +00:00
|
|
|
|
2017-05-02 23:39:21 +00:00
|
|
|
private $watchlistFilterGroupDefinition;
|
|
|
|
|
|
2013-10-09 20:07:14 +00:00
|
|
|
public function __construct( $name = 'Recentchanges', $restriction = '' ) {
|
|
|
|
|
parent::__construct( $name, $restriction );
|
2017-05-02 23:39:21 +00:00
|
|
|
|
|
|
|
|
$this->watchlistFilterGroupDefinition = [
|
|
|
|
|
'name' => 'watchlist',
|
|
|
|
|
'title' => 'rcfilters-filtergroup-watchlist',
|
|
|
|
|
'class' => ChangesListStringOptionsFilterGroup::class,
|
|
|
|
|
'priority' => -9,
|
|
|
|
|
'isFullCoverage' => true,
|
|
|
|
|
'filters' => [
|
|
|
|
|
[
|
|
|
|
|
'name' => 'watched',
|
|
|
|
|
'label' => 'rcfilters-filter-watchlist-watched-label',
|
|
|
|
|
'description' => 'rcfilters-filter-watchlist-watched-description',
|
|
|
|
|
'cssClassSuffix' => 'watched',
|
|
|
|
|
'isRowApplicableCallable' => function ( $ctx, $rc ) {
|
|
|
|
|
return $rc->getAttribute( 'wl_user' );
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'name' => 'watchednew',
|
|
|
|
|
'label' => 'rcfilters-filter-watchlist-watchednew-label',
|
|
|
|
|
'description' => 'rcfilters-filter-watchlist-watchednew-description',
|
|
|
|
|
'cssClassSuffix' => 'watchednew',
|
|
|
|
|
'isRowApplicableCallable' => function ( $ctx, $rc ) {
|
|
|
|
|
return $rc->getAttribute( 'wl_user' ) &&
|
|
|
|
|
$rc->getAttribute( 'rc_timestamp' ) &&
|
|
|
|
|
$rc->getAttribute( 'wl_notificationtimestamp' ) &&
|
|
|
|
|
$rc->getAttribute( 'rc_timestamp' ) >= $rc->getAttribute( 'wl_notificationtimestamp' );
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'name' => 'notwatched',
|
|
|
|
|
'label' => 'rcfilters-filter-watchlist-notwatched-label',
|
|
|
|
|
'description' => 'rcfilters-filter-watchlist-notwatched-description',
|
|
|
|
|
'cssClassSuffix' => 'notwatched',
|
|
|
|
|
'isRowApplicableCallable' => function ( $ctx, $rc ) {
|
|
|
|
|
return $rc->getAttribute( 'wl_user' ) === null;
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'default' => ChangesListStringOptionsFilterGroup::NONE,
|
|
|
|
|
'queryCallable' => function ( $specialPageClassName, $context, $dbr,
|
|
|
|
|
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
|
|
|
|
|
sort( $selectedValues );
|
|
|
|
|
$notwatchedCond = 'wl_user IS NULL';
|
|
|
|
|
$watchedCond = 'wl_user IS NOT NULL';
|
|
|
|
|
$newCond = 'rc_timestamp >= wl_notificationtimestamp';
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'notwatched' ] ) {
|
|
|
|
|
$conds[] = $notwatchedCond;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'watched' ] ) {
|
|
|
|
|
$conds[] = $watchedCond;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'watchednew' ] ) {
|
|
|
|
|
$conds[] = $dbr->makeList( [
|
|
|
|
|
$watchedCond,
|
|
|
|
|
$newCond
|
|
|
|
|
], LIST_AND );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'notwatched', 'watched' ] ) {
|
|
|
|
|
// no filters
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) {
|
|
|
|
|
$conds[] = $dbr->makeList( [
|
|
|
|
|
$notwatchedCond,
|
|
|
|
|
$dbr->makeList( [
|
|
|
|
|
$watchedCond,
|
|
|
|
|
$newCond
|
|
|
|
|
], LIST_AND )
|
|
|
|
|
], LIST_OR );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'watched', 'watchednew' ] ) {
|
|
|
|
|
$conds[] = $watchedCond;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) {
|
|
|
|
|
// no filters
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
];
|
2013-10-09 20:07:14 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
|
|
|
|
* Main execution point
|
|
|
|
|
*
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param string $subpage
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2010-02-10 04:13:43 +00:00
|
|
|
public function execute( $subpage ) {
|
2014-02-02 16:30:44 +00:00
|
|
|
// Backwards-compatibility: redirect to new feed URLs
|
|
|
|
|
$feedFormat = $this->getRequest()->getVal( 'feed' );
|
|
|
|
|
if ( !$this->including() && $feedFormat ) {
|
|
|
|
|
$query = $this->getFeedQuery();
|
|
|
|
|
$query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss';
|
|
|
|
|
$this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
|
2014-03-22 22:51:18 +00:00
|
|
|
|
2014-02-02 16:30:44 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-22 13:47:36 +00:00
|
|
|
// 10 seconds server-side caching max
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
|
$out->setCdnMaxage( 10 );
|
2013-12-22 13:47:36 +00:00
|
|
|
// Check if the client has a cached version
|
2014-02-02 16:30:44 +00:00
|
|
|
$lastmod = $this->checkLastModified();
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $lastmod === false ) {
|
2008-06-17 08:24:00 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 23:58:14 +00:00
|
|
|
$this->addHelpLink(
|
|
|
|
|
'//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
|
|
|
|
|
true
|
|
|
|
|
);
|
2013-12-22 13:47:36 +00:00
|
|
|
parent::execute( $subpage );
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-11 14:49:52 +00:00
|
|
|
* @inheritDoc
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
*/
|
2017-03-31 05:07:31 +00:00
|
|
|
protected function transformFilterDefinition( array $filterDefinition ) {
|
|
|
|
|
if ( isset( $filterDefinition['showHideSuffix'] ) ) {
|
|
|
|
|
$filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-31 05:07:31 +00:00
|
|
|
return $filterDefinition;
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-11 14:49:52 +00:00
|
|
|
* @inheritDoc
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
*/
|
|
|
|
|
protected function registerFilters() {
|
|
|
|
|
parent::registerFilters();
|
|
|
|
|
|
2017-05-02 23:39:21 +00:00
|
|
|
if (
|
|
|
|
|
!$this->including() &&
|
|
|
|
|
$this->getUser()->isLoggedIn() &&
|
|
|
|
|
$this->getUser()->isAllowed( 'viewmywatchlist' )
|
|
|
|
|
) {
|
|
|
|
|
$this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition ] );
|
|
|
|
|
$watchlistGroup = $this->getFilterGroup( 'watchlist' );
|
|
|
|
|
$watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
|
|
|
|
|
$watchlistGroup->getFilter( 'watchednew' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
|
|
|
|
$significance = $this->getFilterGroup( 'significance' );
|
|
|
|
|
$hideMinor = $significance->getFilter( 'hideminor' );
|
|
|
|
|
$hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
|
|
|
|
|
|
|
|
|
|
$automated = $this->getFilterGroup( 'automated' );
|
|
|
|
|
$hideBots = $automated->getFilter( 'hidebots' );
|
|
|
|
|
$hideBots->setDefault( true );
|
|
|
|
|
|
|
|
|
|
$reviewStatus = $this->getFilterGroup( 'reviewStatus' );
|
2017-03-31 05:07:31 +00:00
|
|
|
if ( $reviewStatus !== null ) {
|
|
|
|
|
// Conditional on feature being available and rights
|
2018-04-03 20:53:24 +00:00
|
|
|
if ( $user->getBoolOption( 'hidepatrolled' ) ) {
|
|
|
|
|
$reviewStatus->setDefault( 'unpatrolled' );
|
|
|
|
|
$legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
|
|
|
|
|
$legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
|
|
|
|
|
$legacyHidePatrolled->setDefault( true );
|
|
|
|
|
}
|
2017-03-31 05:07:31 +00:00
|
|
|
}
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
|
|
|
|
|
$changeType = $this->getFilterGroup( 'changeType' );
|
|
|
|
|
$hideCategorization = $changeType->getFilter( 'hidecategorization' );
|
2017-03-31 05:07:31 +00:00
|
|
|
if ( $hideCategorization !== null ) {
|
|
|
|
|
// Conditional on feature being available
|
|
|
|
|
$hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
|
|
|
|
|
}
|
2005-05-04 21:56:14 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2013-12-22 02:17:34 +00:00
|
|
|
/**
|
2016-11-23 19:39:23 +00:00
|
|
|
* Get all custom filters
|
2013-12-22 02:17:34 +00:00
|
|
|
*
|
|
|
|
|
* @return array Map of filter URL param names to properties (msg/default)
|
|
|
|
|
*/
|
|
|
|
|
protected function getCustomFilters() {
|
|
|
|
|
if ( $this->customFilters === null ) {
|
2014-01-08 17:17:08 +00:00
|
|
|
$this->customFilters = parent::getCustomFilters();
|
2016-02-17 09:09:32 +00:00
|
|
|
Hooks::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters ], '1.23' );
|
2013-12-22 02:17:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->customFilters;
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2013-12-09 11:11:14 +00:00
|
|
|
* Process $par and put options found in $opts. Used when including the page.
|
2008-06-26 19:12:52 +00:00
|
|
|
*
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param string $par
|
|
|
|
|
* @param FormOptions $opts
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2008-06-17 08:24:00 +00:00
|
|
|
public function parseParameters( $par, FormOptions $opts ) {
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
parent::parseParameters( $par, $opts );
|
|
|
|
|
|
2008-06-17 08:24:00 +00:00
|
|
|
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $bits as $bit ) {
|
|
|
|
|
if ( is_numeric( $bit ) ) {
|
2013-01-28 21:11:10 +00:00
|
|
|
$opts['limit'] = $bit;
|
2011-05-09 22:57:44 +00:00
|
|
|
}
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$m = [];
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
|
2011-05-09 22:57:44 +00:00
|
|
|
$opts['limit'] = $m[1];
|
|
|
|
|
}
|
2017-07-24 23:38:59 +00:00
|
|
|
if ( preg_match( '/^days=(\d+(?:\.\d+)?)$/', $bit, $m ) ) {
|
2011-05-09 22:57:44 +00:00
|
|
|
$opts['days'] = $m[1];
|
|
|
|
|
}
|
2017-05-08 05:06:12 +00:00
|
|
|
if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
|
2011-10-01 18:20:31 +00:00
|
|
|
$opts['namespace'] = $m[1];
|
|
|
|
|
}
|
2016-08-13 18:23:40 +00:00
|
|
|
if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
|
|
|
|
|
$opts['tagfilter'] = $m[1];
|
|
|
|
|
}
|
2008-06-17 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-11-18 11:37:14 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
2017-08-11 14:49:52 +00:00
|
|
|
* @inheritDoc
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
protected function doMainQuery( $tables, $fields, $conds, $query_options,
|
2017-07-01 08:32:08 +00:00
|
|
|
$join_conds, FormOptions $opts
|
|
|
|
|
) {
|
2013-12-24 11:40:42 +00:00
|
|
|
$dbr = $this->getDB();
|
2014-01-03 14:31:16 +00:00
|
|
|
$user = $this->getUser();
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2017-10-06 17:03:55 +00:00
|
|
|
$rcQuery = RecentChange::getQueryInfo();
|
|
|
|
|
$tables = array_merge( $tables, $rcQuery['tables'] );
|
|
|
|
|
$fields = array_merge( $rcQuery['fields'], $fields );
|
|
|
|
|
$join_conds = array_merge( $join_conds, $rcQuery['joins'] );
|
2014-01-03 14:31:16 +00:00
|
|
|
|
2008-06-17 08:24:00 +00:00
|
|
|
// JOIN on watchlist for users
|
2017-05-02 23:39:21 +00:00
|
|
|
if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
|
2008-06-17 08:24:00 +00:00
|
|
|
$tables[] = 'watchlist';
|
2011-04-19 20:39:08 +00:00
|
|
|
$fields[] = 'wl_user';
|
|
|
|
|
$fields[] = 'wl_notificationtimestamp';
|
2016-02-17 09:09:32 +00:00
|
|
|
$join_conds['watchlist'] = [ 'LEFT JOIN', [
|
2014-01-03 14:31:16 +00:00
|
|
|
'wl_user' => $user->getId(),
|
2013-01-19 11:20:37 +00:00
|
|
|
'wl_title=rc_title',
|
|
|
|
|
'wl_namespace=rc_namespace'
|
2016-02-17 09:09:32 +00:00
|
|
|
] ];
|
2008-06-17 08:24:00 +00:00
|
|
|
}
|
2014-01-03 14:31:16 +00:00
|
|
|
|
2017-05-03 18:58:22 +00:00
|
|
|
// JOIN on page, used for 'last revision' filter highlight
|
|
|
|
|
$tables[] = 'page';
|
|
|
|
|
$fields[] = 'page_latest';
|
|
|
|
|
$join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
|
2014-01-03 14:31:16 +00:00
|
|
|
|
2017-07-26 00:45:00 +00:00
|
|
|
$tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : [];
|
2012-08-04 20:20:00 +00:00
|
|
|
ChangeTags::modifyDisplayQuery(
|
|
|
|
|
$tables,
|
|
|
|
|
$fields,
|
|
|
|
|
$conds,
|
|
|
|
|
$join_conds,
|
|
|
|
|
$query_options,
|
RCFilters: Filter duplicates when filtering for multiple tags
When filtering for multiple tags, add DISTINCT to the query.
To make this not result in terrible query performance, we also
have to add the rc_id to the end of the ORDER BY, and add
a GROUP BY equal to the ORDER BY.
Make ChangeTags::modifyDisplayQuery() take an array of tags
instead of a pipe-separated string. This allows each caller
to explicitly opt into supporting multi-tag filters and the
conditional GROUP BY mess that that entails.
Only support multi-tag filters in SpecialRecentChanges and
SpecialRecentchangesLinked. This means we don't have to adapt
the queries in HistoryAction, ContribsPager, LogPager and
NewPagesPager to deal with a possible DISTINCT modifier.
Example query with no tag filters:
SELECT rc_id, ... FROM recentchanges ... ORDER BY rc_timestamp DESC
Example query with one tag filter:
SELECT rc_id, ... FROM recentchanges JOIN change_tag ON ...
WHERE ... AND ct_tag='foo' ORDER BY rc_timestamp DESC
Example query with two tag filters:
SELECT DISTINCT rc_id, ... FROM recentchanges JOIN change_tag ON ...
WHERE ... AND ct_tag IN ('foo', 'bar') GROUP BY rc_timestamp, rc_id
ORDER BY rc_timestamp DESC, rc_id DESC
Bug: T168501
Change-Id: I54a270a563d99b143b55ce83c7d6f70ac4861c64
2017-07-10 17:14:57 +00:00
|
|
|
$tagFilter
|
2012-08-04 20:20:00 +00:00
|
|
|
);
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2014-06-30 14:48:08 +00:00
|
|
|
if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
|
|
|
|
|
$opts )
|
2013-05-09 14:51:30 +00:00
|
|
|
) {
|
2010-01-29 17:27:30 +00:00
|
|
|
return false;
|
2011-04-19 20:39:08 +00:00
|
|
|
}
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2017-04-10 17:23:45 +00:00
|
|
|
if ( $this->areFiltersInConflict() ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
RCFilters: Filter duplicates when filtering for multiple tags
When filtering for multiple tags, add DISTINCT to the query.
To make this not result in terrible query performance, we also
have to add the rc_id to the end of the ORDER BY, and add
a GROUP BY equal to the ORDER BY.
Make ChangeTags::modifyDisplayQuery() take an array of tags
instead of a pipe-separated string. This allows each caller
to explicitly opt into supporting multi-tag filters and the
conditional GROUP BY mess that that entails.
Only support multi-tag filters in SpecialRecentChanges and
SpecialRecentchangesLinked. This means we don't have to adapt
the queries in HistoryAction, ContribsPager, LogPager and
NewPagesPager to deal with a possible DISTINCT modifier.
Example query with no tag filters:
SELECT rc_id, ... FROM recentchanges ... ORDER BY rc_timestamp DESC
Example query with one tag filter:
SELECT rc_id, ... FROM recentchanges JOIN change_tag ON ...
WHERE ... AND ct_tag='foo' ORDER BY rc_timestamp DESC
Example query with two tag filters:
SELECT DISTINCT rc_id, ... FROM recentchanges JOIN change_tag ON ...
WHERE ... AND ct_tag IN ('foo', 'bar') GROUP BY rc_timestamp, rc_id
ORDER BY rc_timestamp DESC, rc_id DESC
Bug: T168501
Change-Id: I54a270a563d99b143b55ce83c7d6f70ac4861c64
2017-07-10 17:14:57 +00:00
|
|
|
$orderByAndLimit = [
|
|
|
|
|
'ORDER BY' => 'rc_timestamp DESC',
|
|
|
|
|
'LIMIT' => $opts['limit']
|
|
|
|
|
];
|
|
|
|
|
if ( in_array( 'DISTINCT', $query_options ) ) {
|
|
|
|
|
// ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
|
|
|
|
|
// In order to prevent DISTINCT from causing query performance problems,
|
|
|
|
|
// we have to GROUP BY the primary key. This in turn requires us to add
|
|
|
|
|
// the primary key to the end of the ORDER BY, and the old ORDER BY to the
|
|
|
|
|
// start of the GROUP BY
|
|
|
|
|
$orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
|
|
|
|
|
$orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
|
|
|
|
|
}
|
2015-04-26 22:29:57 +00:00
|
|
|
// array_merge() is used intentionally here so that hooks can, should
|
|
|
|
|
// they so desire, override the ORDER BY / LIMIT condition(s); prior to
|
|
|
|
|
// MediaWiki 1.26 this used to use the plus operator instead, which meant
|
|
|
|
|
// that extensions weren't able to change these conditions
|
RCFilters: Filter duplicates when filtering for multiple tags
When filtering for multiple tags, add DISTINCT to the query.
To make this not result in terrible query performance, we also
have to add the rc_id to the end of the ORDER BY, and add
a GROUP BY equal to the ORDER BY.
Make ChangeTags::modifyDisplayQuery() take an array of tags
instead of a pipe-separated string. This allows each caller
to explicitly opt into supporting multi-tag filters and the
conditional GROUP BY mess that that entails.
Only support multi-tag filters in SpecialRecentChanges and
SpecialRecentchangesLinked. This means we don't have to adapt
the queries in HistoryAction, ContribsPager, LogPager and
NewPagesPager to deal with a possible DISTINCT modifier.
Example query with no tag filters:
SELECT rc_id, ... FROM recentchanges ... ORDER BY rc_timestamp DESC
Example query with one tag filter:
SELECT rc_id, ... FROM recentchanges JOIN change_tag ON ...
WHERE ... AND ct_tag='foo' ORDER BY rc_timestamp DESC
Example query with two tag filters:
SELECT DISTINCT rc_id, ... FROM recentchanges JOIN change_tag ON ...
WHERE ... AND ct_tag IN ('foo', 'bar') GROUP BY rc_timestamp, rc_id
ORDER BY rc_timestamp DESC, rc_id DESC
Bug: T168501
Change-Id: I54a270a563d99b143b55ce83c7d6f70ac4861c64
2017-07-10 17:14:57 +00:00
|
|
|
$query_options = array_merge( $orderByAndLimit, $query_options );
|
2014-01-03 15:23:45 +00:00
|
|
|
$rows = $dbr->select(
|
2013-10-07 16:38:25 +00:00
|
|
|
$tables,
|
|
|
|
|
$fields,
|
2015-04-26 22:29:57 +00:00
|
|
|
// rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
|
|
|
|
|
// knowledge to use an index merge if it wants (it may use some other index though).
|
2016-02-17 09:09:32 +00:00
|
|
|
$conds + [ 'rc_new' => [ 0, 1 ] ],
|
2013-10-07 16:38:25 +00:00
|
|
|
__METHOD__,
|
2015-04-26 22:29:57 +00:00
|
|
|
$query_options,
|
2013-10-07 16:38:25 +00:00
|
|
|
$join_conds
|
|
|
|
|
);
|
2014-01-03 15:23:45 +00:00
|
|
|
|
|
|
|
|
return $rows;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-15 02:50:37 +00:00
|
|
|
protected function runMainQueryHook( &$tables, &$fields, &$conds,
|
|
|
|
|
&$query_options, &$join_conds, $opts
|
|
|
|
|
) {
|
2014-06-30 14:48:08 +00:00
|
|
|
return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
|
2014-12-09 07:23:30 +00:00
|
|
|
&& Hooks::run(
|
2014-06-30 14:48:08 +00:00
|
|
|
'SpecialRecentChangesQuery',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
|
2014-06-30 14:48:08 +00:00
|
|
|
'1.23'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-08 00:29:19 +00:00
|
|
|
protected function getDB() {
|
2016-09-05 19:55:19 +00:00
|
|
|
return wfGetDB( DB_REPLICA, 'recentchanges' );
|
2015-04-08 00:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-02 16:30:44 +00:00
|
|
|
public function outputFeedLinks() {
|
|
|
|
|
$this->addFeedLinks( $this->getFeedQuery() );
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-03 15:23:45 +00:00
|
|
|
/**
|
2014-02-02 16:30:44 +00:00
|
|
|
* Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
2014-01-03 15:23:45 +00:00
|
|
|
*/
|
2015-11-21 13:31:06 +00:00
|
|
|
protected function getFeedQuery() {
|
2014-02-02 16:30:44 +00:00
|
|
|
$query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
|
|
|
|
|
// API handles empty parameters in a different way
|
|
|
|
|
return $value !== '';
|
|
|
|
|
} );
|
|
|
|
|
$query['action'] = 'feedrecentchanges';
|
2014-08-04 00:35:56 +00:00
|
|
|
$feedLimit = $this->getConfig()->get( 'FeedLimit' );
|
|
|
|
|
if ( $query['limit'] > $feedLimit ) {
|
|
|
|
|
$query['limit'] = $feedLimit;
|
2014-01-03 15:23:45 +00:00
|
|
|
}
|
2014-03-22 22:51:18 +00:00
|
|
|
|
2014-02-02 16:30:44 +00:00
|
|
|
return $query;
|
2004-01-28 15:57:47 +00:00
|
|
|
}
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
2014-01-03 15:23:45 +00:00
|
|
|
* Build and output the actual changes list.
|
2008-06-26 19:12:52 +00:00
|
|
|
*
|
2018-04-04 12:52:10 +00:00
|
|
|
* @param IResultWrapper $rows Database rows
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param FormOptions $opts
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2014-01-03 15:23:45 +00:00
|
|
|
public function outputChangesList( $rows, $opts ) {
|
2013-05-24 14:09:56 +00:00
|
|
|
$limit = $opts['limit'];
|
|
|
|
|
|
2014-08-04 00:35:56 +00:00
|
|
|
$showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
|
2014-03-12 11:50:43 +00:00
|
|
|
&& $this->getUser()->getOption( 'shownumberswatching' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$watcherCache = [];
|
2007-12-01 09:48:40 +00:00
|
|
|
|
2008-11-28 23:06:25 +00:00
|
|
|
$counter = 1;
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
$list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
|
2014-03-03 21:26:54 +00:00
|
|
|
$list->initChangesListRows( $rows );
|
2008-11-28 23:06:25 +00:00
|
|
|
|
2016-04-13 15:52:48 +00:00
|
|
|
$userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
|
2014-03-26 14:07:44 +00:00
|
|
|
$rclistOutput = $list->beginRecentChangesList();
|
2017-06-27 18:19:31 +00:00
|
|
|
if ( $this->isStructuredFilterUiEnabled() ) {
|
|
|
|
|
$rclistOutput .= $this->makeLegend();
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $rows as $obj ) {
|
|
|
|
|
if ( $limit == 0 ) {
|
2011-05-09 22:57:44 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2008-11-28 23:06:25 +00:00
|
|
|
$rc = RecentChange::newFromRow( $obj );
|
2016-04-13 15:52:48 +00:00
|
|
|
|
|
|
|
|
# Skip CatWatch entries for hidden cats based on user preference
|
|
|
|
|
if (
|
|
|
|
|
$rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
|
|
|
|
|
!$userShowHiddenCats &&
|
|
|
|
|
$rc->getParam( 'hidden-cat' )
|
|
|
|
|
) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-28 23:06:25 +00:00
|
|
|
$rc->counter = $counter++;
|
2008-12-20 08:36:14 +00:00
|
|
|
# Check if the page has been updated since the last visit
|
2015-03-15 02:50:37 +00:00
|
|
|
if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
|
|
|
|
|
&& !empty( $obj->wl_notificationtimestamp )
|
|
|
|
|
) {
|
2011-05-09 22:57:44 +00:00
|
|
|
$rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
|
2008-12-20 08:36:14 +00:00
|
|
|
} else {
|
|
|
|
|
$rc->notificationtimestamp = false; // Default
|
2008-11-28 23:06:25 +00:00
|
|
|
}
|
2008-12-20 08:36:14 +00:00
|
|
|
# Check the number of users watching the page
|
2008-11-28 23:06:25 +00:00
|
|
|
$rc->numberofWatchingusers = 0; // Default
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
|
|
|
|
|
if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
|
2008-11-28 23:06:25 +00:00
|
|
|
$watcherCache[$obj->rc_namespace][$obj->rc_title] =
|
2016-04-15 16:29:05 +00:00
|
|
|
MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(
|
2016-04-14 08:15:18 +00:00
|
|
|
new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
|
2011-05-09 22:57:44 +00:00
|
|
|
);
|
2004-12-18 03:47:11 +00:00
|
|
|
}
|
2008-11-28 23:06:25 +00:00
|
|
|
$rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
|
2004-03-19 05:31:18 +00:00
|
|
|
}
|
2012-11-09 16:17:48 +00:00
|
|
|
|
|
|
|
|
$changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
|
|
|
|
|
if ( $changeLine !== false ) {
|
2013-05-24 14:09:56 +00:00
|
|
|
$rclistOutput .= $changeLine;
|
2012-11-09 16:17:48 +00:00
|
|
|
--$limit;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2013-05-24 14:09:56 +00:00
|
|
|
$rclistOutput .= $list->endRecentChangesList();
|
|
|
|
|
|
|
|
|
|
if ( $rows->numRows() === 0 ) {
|
2017-03-29 16:36:49 +00:00
|
|
|
$this->outputNoResults();
|
2014-07-24 08:25:01 +00:00
|
|
|
if ( !$this->including() ) {
|
|
|
|
|
$this->getOutput()->setStatusCode( 404 );
|
|
|
|
|
}
|
2013-05-24 14:09:56 +00:00
|
|
|
} else {
|
|
|
|
|
$this->getOutput()->addHTML( $rclistOutput );
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
2014-07-14 12:33:23 +00:00
|
|
|
* Set the text to be displayed above the changes
|
2008-06-26 19:12:52 +00:00
|
|
|
*
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param FormOptions $opts
|
2014-07-14 12:21:54 +00:00
|
|
|
* @param int $numRows Number of rows in the result to show after this header
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2014-07-14 12:21:54 +00:00
|
|
|
public function doHeader( $opts, $numRows ) {
|
2011-07-17 09:25:50 +00:00
|
|
|
$this->setTopText( $opts );
|
2008-06-17 08:24:00 +00:00
|
|
|
|
|
|
|
|
$defaults = $opts->getAllValues();
|
|
|
|
|
$nondefaults = $opts->getChangedValues();
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$panel = [];
|
2017-06-27 18:19:31 +00:00
|
|
|
if ( !$this->isStructuredFilterUiEnabled() ) {
|
|
|
|
|
$panel[] = $this->makeLegend();
|
|
|
|
|
}
|
2014-07-14 12:21:54 +00:00
|
|
|
$panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
|
2008-07-02 02:31:05 +00:00
|
|
|
$panel[] = '<hr />';
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
$extraOpts = $this->getExtraOptions( $opts );
|
2008-08-28 07:14:33 +00:00
|
|
|
$extraOptsCount = count( $extraOpts );
|
|
|
|
|
$count = 0;
|
2016-03-19 00:08:06 +00:00
|
|
|
$submit = ' ' . Xml::submitButton( $this->msg( 'recentchanges-submit' )->text() );
|
2008-06-17 08:24:00 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$out = Xml::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $extraOpts as $name => $optionRow ) {
|
2008-08-28 07:14:33 +00:00
|
|
|
# Add submit button to the last row only
|
|
|
|
|
++$count;
|
2012-04-09 18:33:28 +00:00
|
|
|
$addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
|
2008-08-28 07:14:33 +00:00
|
|
|
|
2017-08-03 17:11:53 +00:00
|
|
|
$out .= Xml::openElement( 'tr', [ 'class' => $name . 'Form' ] );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( is_array( $optionRow ) ) {
|
2013-05-09 14:51:30 +00:00
|
|
|
$out .= Xml::tags(
|
|
|
|
|
'td',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'mw-label mw-' . $name . '-label' ],
|
2013-05-09 14:51:30 +00:00
|
|
|
$optionRow[0]
|
|
|
|
|
);
|
|
|
|
|
$out .= Xml::tags(
|
|
|
|
|
'td',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'mw-input' ],
|
2013-05-09 14:51:30 +00:00
|
|
|
$optionRow[1] . $addSubmit
|
|
|
|
|
);
|
2008-06-17 08:24:00 +00:00
|
|
|
} else {
|
2013-05-09 14:51:30 +00:00
|
|
|
$out .= Xml::tags(
|
|
|
|
|
'td',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'mw-input', 'colspan' => 2 ],
|
2013-05-09 14:51:30 +00:00
|
|
|
$optionRow . $addSubmit
|
|
|
|
|
);
|
2008-06-17 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
$out .= Xml::closeElement( 'tr' );
|
|
|
|
|
}
|
|
|
|
|
$out .= Xml::closeElement( 'table' );
|
|
|
|
|
|
|
|
|
|
$unconsumed = $opts->getUnconsumedValues();
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $unconsumed as $key => $value ) {
|
2010-10-31 16:33:48 +00:00
|
|
|
$out .= Html::hidden( $key, $value );
|
2008-06-17 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-24 08:07:04 +00:00
|
|
|
$t = $this->getPageTitle();
|
2010-10-31 16:33:48 +00:00
|
|
|
$out .= Html::hidden( 'title', $t->getPrefixedText() );
|
2016-02-17 09:09:32 +00:00
|
|
|
$form = Xml::tags( 'form', [ 'action' => wfScript() ], $out );
|
2008-06-17 08:24:00 +00:00
|
|
|
$panel[] = $form;
|
|
|
|
|
$panelString = implode( "\n", $panel );
|
|
|
|
|
|
2017-03-06 23:28:21 +00:00
|
|
|
$rcoptions = Xml::fieldset(
|
|
|
|
|
$this->msg( 'recentchanges-legend' )->text(),
|
|
|
|
|
$panelString,
|
2017-08-03 17:11:53 +00:00
|
|
|
[ 'class' => 'rcoptions cloptions' ]
|
2017-03-06 23:28:21 +00:00
|
|
|
);
|
|
|
|
|
|
2017-03-01 01:22:54 +00:00
|
|
|
// Insert a placeholder for RCFilters
|
2017-08-03 17:11:53 +00:00
|
|
|
if ( $this->isStructuredFilterUiEnabled() ) {
|
2017-03-06 23:28:21 +00:00
|
|
|
$rcfilterContainer = Html::element(
|
|
|
|
|
'div',
|
|
|
|
|
[ 'class' => 'rcfilters-container' ]
|
|
|
|
|
);
|
|
|
|
|
|
2017-07-21 00:51:15 +00:00
|
|
|
$loadingContainer = Html::rawElement(
|
|
|
|
|
'div',
|
|
|
|
|
[ 'class' => 'rcfilters-spinner' ],
|
|
|
|
|
Html::element(
|
|
|
|
|
'div',
|
|
|
|
|
[ 'class' => 'rcfilters-spinner-bounce' ]
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2017-03-06 23:28:21 +00:00
|
|
|
// Wrap both with rcfilters-head
|
2017-03-01 01:22:54 +00:00
|
|
|
$this->getOutput()->addHTML(
|
2017-03-06 23:28:21 +00:00
|
|
|
Html::rawElement(
|
2017-03-01 01:22:54 +00:00
|
|
|
'div',
|
2017-03-06 23:28:21 +00:00
|
|
|
[ 'class' => 'rcfilters-head' ],
|
|
|
|
|
$rcfilterContainer . $rcoptions
|
2017-03-01 01:22:54 +00:00
|
|
|
)
|
|
|
|
|
);
|
2017-07-21 00:51:15 +00:00
|
|
|
|
|
|
|
|
// Add spinner
|
|
|
|
|
$this->getOutput()->addHTML( $loadingContainer );
|
2017-03-06 23:28:21 +00:00
|
|
|
} else {
|
|
|
|
|
$this->getOutput()->addHTML( $rcoptions );
|
2017-03-01 01:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-17 09:25:50 +00:00
|
|
|
$this->setBottomText( $opts );
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-22 02:17:34 +00:00
|
|
|
/**
|
|
|
|
|
* Send the text to be displayed above the options
|
|
|
|
|
*
|
|
|
|
|
* @param FormOptions $opts Unused
|
|
|
|
|
*/
|
|
|
|
|
function setTopText( FormOptions $opts ) {
|
|
|
|
|
global $wgContLang;
|
|
|
|
|
|
|
|
|
|
$message = $this->msg( 'recentchangestext' )->inContentLanguage();
|
|
|
|
|
if ( !$message->isDisabled() ) {
|
2017-08-28 16:12:14 +00:00
|
|
|
// Parse the message in this weird ugly way to preserve the ability to include interlanguage
|
|
|
|
|
// links in it (T172461). In the future when T66969 is resolved, perhaps we can just use
|
|
|
|
|
// $message->parse() instead. This code is copied from Message::parseText().
|
|
|
|
|
$parserOutput = MessageCache::singleton()->parse(
|
|
|
|
|
$message->plain(),
|
|
|
|
|
$this->getPageTitle(),
|
|
|
|
|
/*linestart*/true,
|
|
|
|
|
// Message class sets the interface flag to false when parsing in a language different than
|
|
|
|
|
// user language, and this is wiki content language
|
|
|
|
|
/*interface*/false,
|
|
|
|
|
$wgContLang
|
|
|
|
|
);
|
2017-11-22 20:07:51 +00:00
|
|
|
$content = $parserOutput->getText( [
|
|
|
|
|
'enableSectionEditLinks' => false,
|
|
|
|
|
] );
|
2017-08-28 16:12:14 +00:00
|
|
|
// Add only metadata here (including the language links), text is added below
|
|
|
|
|
$this->getOutput()->addParserOutputMetadata( $parserOutput );
|
2017-07-28 07:53:57 +00:00
|
|
|
|
|
|
|
|
$langAttributes = [
|
|
|
|
|
'lang' => $wgContLang->getHtmlCode(),
|
|
|
|
|
'dir' => $wgContLang->getDir(),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
|
|
|
|
|
|
2017-08-03 17:11:53 +00:00
|
|
|
if ( $this->isStructuredFilterUiEnabled() ) {
|
2017-09-21 23:15:47 +00:00
|
|
|
// Check whether the widget is already collapsed or expanded
|
|
|
|
|
$collapsedState = $this->getRequest()->getCookie( 'rcfilters-toplinks-collapsed-state' );
|
2017-09-25 21:50:04 +00:00
|
|
|
// Note that an empty/unset cookie means collapsed, so check for !== 'expanded'
|
2017-10-13 23:20:33 +00:00
|
|
|
$topLinksAttributes[ 'class' ] .= $collapsedState !== 'expanded' ?
|
|
|
|
|
' mw-recentchanges-toplinks-collapsed' : '';
|
|
|
|
|
|
|
|
|
|
$this->getOutput()->enableOOUI();
|
|
|
|
|
$contentTitle = new OOUI\ButtonWidget( [
|
|
|
|
|
'classes' => [ 'mw-recentchanges-toplinks-title' ],
|
|
|
|
|
'label' => new OOUI\HtmlSnippet( $this->msg( 'rcfilters-other-review-tools' )->parse() ),
|
|
|
|
|
'framed' => false,
|
|
|
|
|
'indicator' => $collapsedState !== 'expanded' ? 'down' : 'up',
|
|
|
|
|
'flags' => [ 'progressive' ],
|
|
|
|
|
] );
|
2017-09-21 23:15:47 +00:00
|
|
|
|
2017-07-28 07:53:57 +00:00
|
|
|
$contentWrapper = Html::rawElement( 'div',
|
2017-09-21 23:15:47 +00:00
|
|
|
array_merge(
|
2017-10-13 23:20:33 +00:00
|
|
|
[ 'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content' ],
|
2017-09-21 23:15:47 +00:00
|
|
|
$langAttributes
|
|
|
|
|
),
|
2017-07-28 07:53:57 +00:00
|
|
|
$content
|
|
|
|
|
);
|
|
|
|
|
$content = $contentTitle . $contentWrapper;
|
|
|
|
|
} else {
|
|
|
|
|
// Language direction should be on the top div only
|
|
|
|
|
// if the title is not there. If it is there, it's
|
|
|
|
|
// interface direction, and the language/dir attributes
|
|
|
|
|
// should be on the content itself
|
|
|
|
|
$topLinksAttributes = array_merge( $topLinksAttributes, $langAttributes );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->getOutput()->addHTML(
|
|
|
|
|
Html::rawElement( 'div', $topLinksAttributes, $content )
|
2013-12-22 02:17:34 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
|
|
|
|
* Get options to be displayed in a form
|
|
|
|
|
*
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param FormOptions $opts
|
|
|
|
|
* @return array
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2011-05-09 22:57:44 +00:00
|
|
|
function getExtraOptions( $opts ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$opts->consumeValues( [
|
2017-03-18 01:17:17 +00:00
|
|
|
'namespace', 'invert', 'associated', 'tagfilter'
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2013-05-20 12:00:52 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$extraOpts = [];
|
2008-06-26 19:12:52 +00:00
|
|
|
$extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
|
|
|
|
|
|
2016-10-19 19:06:14 +00:00
|
|
|
$tagFilter = ChangeTags::buildTagFilterSelector(
|
|
|
|
|
$opts['tagfilter'], false, $this->getContext() );
|
2011-05-09 22:57:44 +00:00
|
|
|
if ( count( $tagFilter ) ) {
|
2012-01-13 21:57:52 +00:00
|
|
|
$extraOpts['tagfilter'] = $tagFilter;
|
2011-05-09 22:57:44 +00:00
|
|
|
}
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2013-05-20 12:00:52 +00:00
|
|
|
// Don't fire the hook for subclasses. (Or should we?)
|
|
|
|
|
if ( $this->getName() === 'Recentchanges' ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
Hooks::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
|
2013-05-20 12:00:52 +00:00
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
return $extraOpts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2013-12-22 02:17:34 +00:00
|
|
|
* Add page-specific modules.
|
|
|
|
|
*/
|
|
|
|
|
protected function addModules() {
|
|
|
|
|
parent::addModules();
|
|
|
|
|
$out = $this->getOutput();
|
|
|
|
|
$out->addModules( 'mediawiki.special.recentchanges' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get last modified date, for client caching
|
|
|
|
|
* Don't use this if we are using the patrol feature, patrol changes don't
|
|
|
|
|
* update the timestamp
|
2008-06-26 19:12:52 +00:00
|
|
|
*
|
2013-12-22 02:17:34 +00:00
|
|
|
* @return string|bool
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2014-02-02 16:30:44 +00:00
|
|
|
public function checkLastModified() {
|
2013-12-24 11:40:42 +00:00
|
|
|
$dbr = $this->getDB();
|
2018-02-27 18:37:26 +00:00
|
|
|
$lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ );
|
2014-03-22 22:51:18 +00:00
|
|
|
|
2013-12-22 02:17:34 +00:00
|
|
|
return $lastmod;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
|
|
|
|
* Creates the choose namespace selection
|
|
|
|
|
*
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param FormOptions $opts
|
|
|
|
|
* @return string
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2008-06-17 08:24:00 +00:00
|
|
|
protected function namespaceFilterForm( FormOptions $opts ) {
|
2012-01-29 19:05:25 +00:00
|
|
|
$nsSelect = Html::namespaceSelector(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'selected' => $opts['namespace'], 'all' => '' ],
|
|
|
|
|
[ 'name' => 'namespace', 'id' => 'namespace' ]
|
2012-01-29 19:05:25 +00:00
|
|
|
);
|
2012-04-28 18:20:11 +00:00
|
|
|
$nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
|
2011-06-23 20:00:05 +00:00
|
|
|
$invert = Xml::checkLabel(
|
2012-04-28 18:20:11 +00:00
|
|
|
$this->msg( 'invert' )->text(), 'invert', 'nsinvert',
|
2011-06-23 20:00:05 +00:00
|
|
|
$opts['invert'],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'title' => $this->msg( 'tooltip-invert' )->text() ]
|
2011-06-23 20:00:05 +00:00
|
|
|
);
|
2011-05-09 22:57:44 +00:00
|
|
|
$associated = Xml::checkLabel(
|
2012-04-28 18:20:11 +00:00
|
|
|
$this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
|
2011-06-23 20:00:05 +00:00
|
|
|
$opts['associated'],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
|
2011-05-09 22:57:44 +00:00
|
|
|
);
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ $nsLabel, "$nsSelect $invert $associated" ];
|
2008-06-17 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
|
|
|
|
* Filter $rows by categories set in $opts
|
|
|
|
|
*
|
2017-03-18 01:17:17 +00:00
|
|
|
* @deprecated since 1.31
|
|
|
|
|
*
|
2018-04-04 12:52:10 +00:00
|
|
|
* @param IResultWrapper &$rows Database rows
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param FormOptions $opts
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
|
|
|
|
function filterByCategories( &$rows, FormOptions $opts ) {
|
2017-03-18 01:17:17 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2013-01-26 18:15:35 +00:00
|
|
|
$categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
|
2008-06-26 19:12:52 +00:00
|
|
|
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( !count( $categories ) ) {
|
2008-06-26 19:12:52 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
# Filter categories
|
2016-02-17 09:09:32 +00:00
|
|
|
$cats = [];
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $categories as $cat ) {
|
2008-06-26 19:12:52 +00:00
|
|
|
$cat = trim( $cat );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $cat == '' ) {
|
2011-05-09 22:57:44 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2008-06-26 19:12:52 +00:00
|
|
|
$cats[] = $cat;
|
2006-01-09 14:20:26 +00:00
|
|
|
}
|
2008-06-26 19:12:52 +00:00
|
|
|
|
|
|
|
|
# Filter articles
|
2016-02-17 09:09:32 +00:00
|
|
|
$articles = [];
|
|
|
|
|
$a2r = [];
|
|
|
|
|
$rowsarr = [];
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $rows as $k => $r ) {
|
2008-06-26 19:12:52 +00:00
|
|
|
$nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
|
|
|
|
|
$id = $nt->getArticleID();
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $id == 0 ) {
|
2011-05-09 22:57:44 +00:00
|
|
|
continue; # Page might have been deleted...
|
|
|
|
|
}
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( !in_array( $id, $articles ) ) {
|
2008-06-26 19:12:52 +00:00
|
|
|
$articles[] = $id;
|
|
|
|
|
}
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( !isset( $a2r[$id] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$a2r[$id] = [];
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|
|
|
|
|
$a2r[$id][] = $k;
|
2010-03-04 15:42:17 +00:00
|
|
|
$rowsarr[$k] = $r;
|
2006-01-09 14:20:26 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
# Shortcut?
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( !count( $articles ) || !count( $cats ) ) {
|
2011-05-09 22:57:44 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-06-26 19:12:52 +00:00
|
|
|
|
|
|
|
|
# Look up
|
2014-08-29 01:58:25 +00:00
|
|
|
$catFind = new CategoryFinder;
|
|
|
|
|
$catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
|
|
|
|
|
$match = $catFind->run();
|
2008-06-26 19:12:52 +00:00
|
|
|
|
|
|
|
|
# Filter
|
2016-02-17 09:09:32 +00:00
|
|
|
$newrows = [];
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $match as $id ) {
|
|
|
|
|
foreach ( $a2r[$id] as $rev ) {
|
2008-06-26 19:12:52 +00:00
|
|
|
$k = $rev;
|
2010-03-04 15:42:17 +00:00
|
|
|
$newrows[$k] = $rowsarr[$k];
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|
2004-12-12 04:13:19 +00:00
|
|
|
}
|
2017-03-20 14:26:47 +00:00
|
|
|
$rows = new FakeResultWrapper( array_values( $newrows ) );
|
2004-12-12 04:13:19 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
|
|
|
|
* Makes change an option link which carries all the other options
|
2010-07-03 21:09:25 +00:00
|
|
|
*
|
2017-12-28 15:06:10 +00:00
|
|
|
* @param string $title
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param array $override Options to override
|
|
|
|
|
* @param array $options Current options
|
|
|
|
|
* @param bool $active Whether to show the link in bold
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return string
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
|
|
|
|
function makeOptionsLink( $title, $override, $options, $active = false ) {
|
2016-12-06 15:25:35 +00:00
|
|
|
$params = $this->convertParamsForLink( $override + $options );
|
2012-07-16 08:45:27 +00:00
|
|
|
|
2009-04-13 12:39:12 +00:00
|
|
|
if ( $active ) {
|
2016-12-09 21:20:07 +00:00
|
|
|
$title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
|
2009-04-13 12:39:12 +00:00
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2017-02-28 01:56:40 +00:00
|
|
|
return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
|
|
|
|
|
'data-params' => json_encode( $override ),
|
|
|
|
|
'data-keys' => implode( ',', array_keys( $override ) ),
|
|
|
|
|
], $params );
|
2006-04-05 18:31:58 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
/**
|
|
|
|
|
* Creates the options panel.
|
2010-07-03 21:09:25 +00:00
|
|
|
*
|
2013-04-01 22:12:05 +00:00
|
|
|
* @param array $defaults
|
|
|
|
|
* @param array $nondefaults
|
2014-07-14 12:21:54 +00:00
|
|
|
* @param int $numRows Number of rows in the result to show after this header
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return string
|
2008-06-26 19:12:52 +00:00
|
|
|
*/
|
2014-07-14 12:21:54 +00:00
|
|
|
function optionsPanel( $defaults, $nondefaults, $numRows ) {
|
2008-06-26 19:12:52 +00:00
|
|
|
$options = $nondefaults + $defaults;
|
|
|
|
|
|
2008-10-29 15:47:58 +00:00
|
|
|
$note = '';
|
2012-04-28 18:20:11 +00:00
|
|
|
$msg = $this->msg( 'rclegend' );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( !$msg->isDisabled() ) {
|
2012-04-28 18:20:11 +00:00
|
|
|
$note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
|
2009-01-25 00:19:01 +00:00
|
|
|
}
|
2012-04-28 18:20:11 +00:00
|
|
|
|
|
|
|
|
$lang = $this->getLanguage();
|
|
|
|
|
$user = $this->getUser();
|
2015-08-24 17:40:06 +00:00
|
|
|
$config = $this->getConfig();
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $options['from'] ) {
|
2017-04-05 23:05:51 +00:00
|
|
|
$resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
|
|
|
|
|
[ 'from' => '' ], $nondefaults );
|
|
|
|
|
|
2017-07-21 15:41:36 +00:00
|
|
|
$noteFromMsg = $this->msg( 'rcnotefrom' )
|
2014-07-14 12:21:54 +00:00
|
|
|
->numParams( $options['limit'] )
|
|
|
|
|
->params(
|
|
|
|
|
$lang->userTimeAndDate( $options['from'], $user ),
|
|
|
|
|
$lang->userDate( $options['from'], $user ),
|
|
|
|
|
$lang->userTime( $options['from'], $user )
|
|
|
|
|
)
|
2017-07-21 15:41:36 +00:00
|
|
|
->numParams( $numRows );
|
|
|
|
|
$note .= Html::rawElement(
|
|
|
|
|
'span',
|
|
|
|
|
[ 'class' => 'rcnotefrom' ],
|
|
|
|
|
$noteFromMsg->parse()
|
|
|
|
|
) .
|
|
|
|
|
' ' .
|
2017-04-05 23:05:51 +00:00
|
|
|
Html::rawElement(
|
|
|
|
|
'span',
|
|
|
|
|
[ 'class' => 'rcoptions-listfromreset' ],
|
|
|
|
|
$this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
|
|
|
|
|
) .
|
|
|
|
|
'<br />';
|
2008-10-29 15:47:58 +00:00
|
|
|
}
|
2008-10-29 15:35:18 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
# Sort data for display and make sure it's unique after we've added user data.
|
2015-08-24 17:40:06 +00:00
|
|
|
$linkLimits = $config->get( 'RCLinkLimits' );
|
2013-05-23 17:31:56 +00:00
|
|
|
$linkLimits[] = $options['limit'];
|
|
|
|
|
sort( $linkLimits );
|
|
|
|
|
$linkLimits = array_unique( $linkLimits );
|
|
|
|
|
|
2015-08-24 17:40:06 +00:00
|
|
|
$linkDays = $config->get( 'RCLinkDays' );
|
2013-05-23 17:31:56 +00:00
|
|
|
$linkDays[] = $options['days'];
|
|
|
|
|
sort( $linkDays );
|
|
|
|
|
$linkDays = array_unique( $linkDays );
|
2008-06-26 19:12:52 +00:00
|
|
|
|
|
|
|
|
// limit links
|
2016-02-17 09:09:32 +00:00
|
|
|
$cl = [];
|
2013-05-23 17:31:56 +00:00
|
|
|
foreach ( $linkLimits as $value ) {
|
2012-04-28 18:20:11 +00:00
|
|
|
$cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|
2012-04-28 18:20:11 +00:00
|
|
|
$cl = $lang->pipeList( $cl );
|
2005-05-03 18:30:46 +00:00
|
|
|
|
2008-06-26 19:12:52 +00:00
|
|
|
// day links, reset 'from' to none
|
2016-02-17 09:09:32 +00:00
|
|
|
$dl = [];
|
2013-05-23 17:31:56 +00:00
|
|
|
foreach ( $linkDays as $value ) {
|
2012-04-28 18:20:11 +00:00
|
|
|
$dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|
2012-04-28 18:20:11 +00:00
|
|
|
$dl = $lang->pipeList( $dl );
|
2008-06-26 19:12:52 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$showhide = [ 'show', 'hide' ];
|
2014-01-24 13:25:19 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$links = [];
|
2014-02-28 18:29:11 +00:00
|
|
|
|
2017-10-18 10:28:43 +00:00
|
|
|
foreach ( $this->getLegacyShowHideFilters() as $key => $filter ) {
|
|
|
|
|
$msg = $filter->getShowHide();
|
|
|
|
|
$linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
|
|
|
|
|
// Extensions can define additional filters, but don't need to define the corresponding
|
|
|
|
|
// messages. If they don't exist, just fall back to 'show' and 'hide'.
|
|
|
|
|
if ( !$linkMessage->exists() ) {
|
|
|
|
|
$linkMessage = $this->msg( $showhide[1 - $options[$key]] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$link = $this->makeOptionsLink( $linkMessage->text(),
|
|
|
|
|
[ $key => 1 - $options[$key] ], $nondefaults );
|
|
|
|
|
|
|
|
|
|
$attribs = [
|
|
|
|
|
'class' => "$msg rcshowhideoption clshowhideoption",
|
|
|
|
|
'data-filter-name' => $filter->getName(),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
|
|
|
|
|
$attribs['data-feature-in-structured-ui'] = true;
|
Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.
This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).
This includes the query logic (see below) and logic for adding
CSS attribution classes.
This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery. An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.
This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this. I added all
the DB parameters from the hook, but this could be debated.
I have an checked and fixed the WMF-deployed extensions affected by
this.
Other than that, there should be full back-compat (including legacy
filters not using the new system).
* add hidepatrolled/hideunpatrolled to new UI.
* Move userExpLevel from RC to ChangesListSpecialPage. Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.
Change this to make 'all' exclude unregistered users.
* Don't have front-end convert none-selected to 'all' on string_options.
* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)
Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
|
|
|
}
|
2017-10-18 10:28:43 +00:00
|
|
|
|
|
|
|
|
$links[] = Html::rawElement(
|
|
|
|
|
'span',
|
|
|
|
|
$attribs,
|
2017-12-03 03:34:12 +00:00
|
|
|
$this->msg( $msg )->rawParams( $link )->parse()
|
2017-10-18 10:28:43 +00:00
|
|
|
);
|
2011-05-23 04:28:58 +00:00
|
|
|
}
|
2008-06-26 19:12:52 +00:00
|
|
|
|
|
|
|
|
// show from this onward link
|
2011-06-24 10:00:35 +00:00
|
|
|
$timestamp = wfTimestampNow();
|
2012-04-28 18:20:11 +00:00
|
|
|
$now = $lang->userTimeAndDate( $timestamp, $user );
|
2014-01-14 13:33:17 +00:00
|
|
|
$timenow = $lang->userTime( $timestamp, $user );
|
|
|
|
|
$datenow = $lang->userDate( $timestamp, $user );
|
2014-09-14 17:35:39 +00:00
|
|
|
$pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
|
|
|
|
|
|
2017-04-18 19:40:11 +00:00
|
|
|
$rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
|
2014-09-14 17:35:39 +00:00
|
|
|
->parse() . '</span>';
|
|
|
|
|
|
|
|
|
|
$rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
|
2014-01-14 13:33:17 +00:00
|
|
|
$this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'from' => $timestamp ],
|
2014-01-14 13:33:17 +00:00
|
|
|
$nondefaults
|
2014-09-14 17:35:39 +00:00
|
|
|
) . '</span>';
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2017-04-18 19:40:11 +00:00
|
|
|
return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
|
2005-05-03 18:30:46 +00:00
|
|
|
}
|
2011-06-28 06:40:49 +00:00
|
|
|
|
2013-12-22 02:17:34 +00:00
|
|
|
public function isIncludable() {
|
|
|
|
|
return true;
|
2013-03-07 20:15:54 +00:00
|
|
|
}
|
2014-06-20 16:18:29 +00:00
|
|
|
|
2016-06-15 04:19:43 +00:00
|
|
|
protected function getCacheTTL() {
|
2016-06-16 05:34:23 +00:00
|
|
|
return 60 * 5;
|
2014-06-20 16:18:29 +00:00
|
|
|
}
|
2017-08-21 19:28:23 +00:00
|
|
|
|
2017-11-02 23:15:36 +00:00
|
|
|
public function getDefaultLimit() {
|
|
|
|
|
$systemPrefValue = $this->getUser()->getIntOption( 'rclimit' );
|
|
|
|
|
// Prefer the RCFilters-specific preference if RCFilters is enabled
|
|
|
|
|
if ( $this->isStructuredFilterUiEnabled() ) {
|
|
|
|
|
return $this->getUser()->getIntOption( static::$limitPreferenceName, $systemPrefValue );
|
|
|
|
|
}
|
2017-08-21 19:28:23 +00:00
|
|
|
|
2017-11-02 23:15:36 +00:00
|
|
|
// Otherwise, use the system rclimit preference value
|
|
|
|
|
return $systemPrefValue;
|
2017-08-21 19:28:23 +00:00
|
|
|
}
|
2008-06-26 19:12:52 +00:00
|
|
|
}
|