2011-03-02 20:40:40 +00:00
|
|
|
<?php
|
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
|
|
|
|
2020-06-24 06:04:05 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2017-04-19 19:37:35 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
|
2011-03-02 20:40:40 +00:00
|
|
|
/**
|
|
|
|
|
* Test class for SpecialRecentchanges class
|
|
|
|
|
*
|
2011-09-15 20:43:40 +00:00
|
|
|
* @group Database
|
2013-10-24 20:30:43 +00:00
|
|
|
*
|
|
|
|
|
* @covers SpecialRecentChanges
|
2011-03-02 20:40:40 +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
|
|
|
class SpecialRecentchangesTest extends AbstractChangesListSpecialPageTestCase {
|
2021-01-30 15:07:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return SpecialRecentChanges
|
|
|
|
|
*/
|
2016-12-06 15:25:35 +00:00
|
|
|
protected function getPage() {
|
2020-10-21 18:41:25 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
2016-12-06 15:25:35 +00:00
|
|
|
return TestingAccessWrapper::newFromObject(
|
2020-10-21 18:41:25 +00:00
|
|
|
new SpecialRecentChanges(
|
|
|
|
|
$services->getWatchedItemStore(),
|
|
|
|
|
$services->getMessageCache(),
|
|
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
$services->getUserOptionsLookup()
|
|
|
|
|
)
|
2011-03-02 20:40:40 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-06 15:25:35 +00:00
|
|
|
// Below providers should only be for features specific to
|
|
|
|
|
// RecentChanges. Otherwise, it should go in ChangesListSpecialPageTest
|
|
|
|
|
|
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
|
|
|
public function provideParseParameters() {
|
|
|
|
|
return [
|
|
|
|
|
[ 'limit=123', [ 'limit' => '123' ] ],
|
2016-11-14 17:47:41 +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
|
|
|
[ '234', [ 'limit' => '234' ] ],
|
2011-03-02 20:40:40 +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
|
|
|
[ 'days=3', [ 'days' => '3' ] ],
|
2011-03-02 20:40:40 +00:00
|
|
|
|
2017-08-11 14:22:42 +00:00
|
|
|
[ 'days=0.25', [ 'days' => '0.25' ] ],
|
2017-07-24 23:38:59 +00:00
|
|
|
|
2017-05-08 05:06:12 +00:00
|
|
|
[ 'namespace=5', [ 'namespace' => '5' ] ],
|
|
|
|
|
|
|
|
|
|
[ 'namespace=5|3', [ 'namespace' => '5|3' ] ],
|
2011-03-02 20:40:40 +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
|
|
|
[ 'tagfilter=foo', [ 'tagfilter' => 'foo' ] ],
|
2017-05-08 05:06:12 +00:00
|
|
|
|
|
|
|
|
[ 'tagfilter=foo;bar', [ 'tagfilter' => 'foo;bar' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2011-03-02 20:40:40 +00:00
|
|
|
}
|
2016-12-06 15:25:35 +00:00
|
|
|
|
|
|
|
|
public function validateOptionsProvider() {
|
|
|
|
|
return [
|
|
|
|
|
[
|
|
|
|
|
// hidebots=1 is default for Special:RecentChanges
|
|
|
|
|
[ 'hideanons' => 1, 'hideliu' => 1 ],
|
|
|
|
|
true,
|
|
|
|
|
[ 'hideliu' => 1 ],
|
2018-09-27 17:09:33 +00:00
|
|
|
false,
|
2016-12-06 15:25:35 +00:00
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
2020-06-24 06:04:05 +00:00
|
|
|
|
|
|
|
|
public function testAddWatchlistJoins() {
|
|
|
|
|
// Edit a test page so that it shows up in RC.
|
|
|
|
|
$testTitle = Title::newFromText( 'Test page' );
|
|
|
|
|
$testPage = WikiPage::factory( $testTitle );
|
|
|
|
|
$testPage->doEditContent( ContentHandler::makeContent( 'Test content', $testTitle ), '' );
|
|
|
|
|
|
|
|
|
|
// Set up RC.
|
|
|
|
|
$context = new RequestContext;
|
|
|
|
|
$context->setTitle( Title::newFromText( __METHOD__ ) );
|
|
|
|
|
$context->setUser( $this->getTestUser()->getUser() );
|
|
|
|
|
$context->setRequest( new FauxRequest );
|
|
|
|
|
|
|
|
|
|
// Confirm that the test page is in RC.
|
2020-10-21 18:41:25 +00:00
|
|
|
$rc1 = $this->getPage();
|
2020-06-24 06:04:05 +00:00
|
|
|
$rc1->setContext( $context );
|
|
|
|
|
$rc1->execute( null );
|
|
|
|
|
$this->assertStringContainsString( 'Test page', $rc1->getOutput()->getHTML() );
|
|
|
|
|
$this->assertStringContainsString( 'mw-changeslist-line-not-watched', $rc1->getOutput()->getHTML() );
|
|
|
|
|
|
|
|
|
|
// Watch the page, and check that it's now watched in RC.
|
|
|
|
|
$watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
|
|
|
|
|
$watchedItemStore->addWatch( $context->getUser(), $testTitle );
|
2020-10-21 18:41:25 +00:00
|
|
|
$rc2 = $this->getPage();
|
2020-06-24 06:04:05 +00:00
|
|
|
$rc2->setContext( $context );
|
|
|
|
|
$rc2->execute( null );
|
|
|
|
|
$this->assertStringContainsString( 'Test page', $rc2->getOutput()->getHTML() );
|
|
|
|
|
$this->assertStringContainsString( 'mw-changeslist-line-watched', $rc2->getOutput()->getHTML() );
|
|
|
|
|
|
|
|
|
|
// Force a past expiry date on the watchlist item.
|
2021-04-29 02:37:11 +00:00
|
|
|
$db = wfGetDB( DB_PRIMARY );
|
2020-06-24 06:04:05 +00:00
|
|
|
$queryConds = [ 'wl_namespace' => $testTitle->getNamespace(), 'wl_title' => $testTitle->getDBkey() ];
|
2020-07-28 15:17:31 +00:00
|
|
|
$watchedItemId = $db->selectField( 'watchlist', 'wl_id', $queryConds, __METHOD__ );
|
|
|
|
|
$db->update(
|
|
|
|
|
'watchlist_expiry',
|
|
|
|
|
[ 'we_expiry' => $db->timestamp( '20200101000000' ) ],
|
|
|
|
|
[ 'we_item' => $watchedItemId ],
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
2020-06-24 06:04:05 +00:00
|
|
|
|
|
|
|
|
// Check that the page is still in RC, but that it's no longer watched.
|
2020-10-21 18:41:25 +00:00
|
|
|
$rc3 = $this->getPage();
|
2020-06-24 06:04:05 +00:00
|
|
|
$rc3->setContext( $context );
|
|
|
|
|
$rc3->execute( null );
|
|
|
|
|
$this->assertStringContainsString( 'Test page', $rc3->getOutput()->getHTML() );
|
|
|
|
|
$this->assertStringContainsString( 'mw-changeslist-line-not-watched', $rc3->getOutput()->getHTML() );
|
|
|
|
|
}
|
2011-03-02 20:40:40 +00:00
|
|
|
}
|