Go to the documentation of this file.
3 use Wikimedia\TestingAccessWrapper;
22 'ChangesListSpecialPage',
26 ->setMethods( [
'getPageTitle' ] )
27 ->getMockForAbstractClass();
29 $mock->method(
'getPageTitle' )->willReturn(
33 $mock = TestingAccessWrapper::newFromObject(
41 $requestOptions =
null,
50 $this->changesListSpecialPage->setContext(
$context );
51 $this->changesListSpecialPage->filterGroups = [];
52 $formOptions = $this->changesListSpecialPage->setup(
null );
54 # Filter out rc_timestamp conditions which depends on the test runtime
55 # This condition is not needed as of march 2, 2011 -- hashar
56 # @todo FIXME: Find a way to generate the correct rc_timestamp
60 $queryConditions = [];
65 [ $this->changesListSpecialPage,
'buildQuery' ],
76 $queryConditions = array_filter(
78 'ChangesListSpecialPageTest::filterOutRcTimestampCondition'
81 return $queryConditions;
87 $requestOptions =
null,
94 self::normalizeCondition( $expected ),
95 self::normalizeCondition( $queryConditions ),
102 $normalized = array_map(
103 function ( $k, $v )
use (
$dbr ) {
104 if ( is_array( $v ) ) {
110 array_keys( $conds ),
119 return ( is_array( $var ) ||
false === strpos( $var,
'rc_timestamp ' ) );
125 "rc_namespace = '0'",
130 "rc conditions with one namespace"
137 "rc_namespace != '0'",
143 "rc conditions with namespace inverted"
150 "rc_namespace IN ('1','2','3')",
153 'namespace' =>
'1;2;3',
155 "rc conditions with multiple namespaces"
162 "rc_namespace IN ('0','1','4','5','6','7')",
165 'namespace' =>
'1;4;7',
168 "rc conditions with multiple namespaces and associated"
175 "rc_namespace NOT IN ('2','3','8','9')",
178 'namespace' =>
'2;3;9',
182 "rc conditions with multiple namespaces, associated and inverted"
189 "rc_namespace NOT IN ('1','2','3')",
192 'namespace' =>
'1;2;3',
195 "rc conditions with multiple namespaces inverted"
209 "NOT((rc_user = '{$user->getId()}'))",
214 "rc conditions: hidemyself=1 (logged in)",
222 "NOT((rc_user_text = '10.11.12.13'))",
227 "rc conditions: hidemyself=1 (anon)",
242 "(rc_user_text = '{$user->getName()}')",
247 "rc conditions: hidebyothers=1 (logged in)",
255 "(rc_user_text = '10.11.12.13')",
260 "rc conditions: hidebyothers=1 (anon)",
271 'hidepageedits' => 1,
273 "rc conditions: hidepageedits=1"
285 "rc conditions: hidenewpages=1"
297 "rc conditions: hidelog=1"
310 "rc conditions: hidebots=0 hidehumans=1"
321 'hidepatrolled' => 1,
323 "rc conditions: hidepatrolled=1 (user not allowed)",
335 'hideunpatrolled' => 1,
337 "rc conditions: hideunpatrolled=1 (user not allowed)",
348 'hidepatrolled' => 1,
350 "rc conditions: hidepatrolled=1",
359 'rc_patrolled' => [ 1, 2 ],
362 'hideunpatrolled' => 1,
364 "rc conditions: hideunpatrolled=1",
376 'reviewStatus' =>
'manual'
378 "rc conditions: reviewStatus=manual",
383 'rc_patrolled' => [ 0, 2 ],
386 'reviewStatus' =>
'unpatrolled;auto'
388 "rc conditions: reviewStatus=unpatrolled;auto",
401 "rc conditions: hideminor=1"
413 "rc conditions: hidemajor=1"
424 'hidecategorization' => 1
426 "rc conditions: hidecategorization=1"
436 'userExpLevel' =>
'registered;unregistered;newcomer;learner;experienced',
438 "rc conditions: userExpLevel=registered;unregistered;newcomer;learner;experienced"
448 'userExpLevel' =>
'registered;unregistered',
450 "rc conditions: userExpLevel=registered;unregistered"
460 'userExpLevel' =>
'registered;unregistered;learner',
462 "rc conditions: userExpLevel=registered;unregistered;learner"
478 'userExpLevel' =>
'newcomer;learner;experienced',
480 "rc conditions: userExpLevel=newcomer;learner;experienced"
496 'userExpLevel' =>
'registered',
498 "rc conditions: userExpLevel=registered"
514 'userExpLevel' =>
'unregistered',
516 "rc conditions: userExpLevel=unregistered"
532 'userExpLevel' =>
'registered;learner',
534 "rc conditions: userExpLevel=registered;learner"
544 $conds = $this->
buildQuery( [
'userExpLevel' =>
'unregistered;experienced' ] );
547 '/\(rc_user = 0\) OR '
548 .
'\(\(user_editcount >= 500\) AND \(user_registration <= \'[^\']+\'\)\)/',
550 "rc conditions: userExpLevel=unregistered;experienced"
557 'wgLearnerEdits' => 10,
558 'wgLearnerMemberSince' => 4,
559 'wgExperiencedUserEdits' => 500,
560 'wgExperiencedUserMemberSince' => 30,
564 'Newcomer1' => [
'edits' => 2,
'days' => 2 ],
565 'Newcomer2' => [
'edits' => 12,
'days' => 3 ],
566 'Newcomer3' => [
'edits' => 8,
'days' => 5 ],
567 'Learner1' => [
'edits' => 15,
'days' => 10 ],
568 'Learner2' => [
'edits' => 450,
'days' => 20 ],
569 'Learner3' => [
'edits' => 460,
'days' => 33 ],
570 'Learner4' => [
'edits' => 525,
'days' => 28 ],
571 'Experienced1' => [
'edits' => 538,
'days' => 33 ],
576 [
'Newcomer1',
'Newcomer2',
'Newcomer3' ],
583 'Newcomer1',
'Newcomer2',
'Newcomer3',
584 'Learner1',
'Learner2',
'Learner3',
'Learner4',
586 $this->
fetchUsers( [
'newcomer',
'learner' ], $now )
592 'Newcomer1',
'Newcomer2',
'Newcomer3',
595 $this->
fetchUsers( [
'newcomer',
'experienced' ], $now )
600 [
'Learner1',
'Learner2',
'Learner3',
'Learner4' ],
613 'Learner1',
'Learner2',
'Learner3',
'Learner4',
616 $this->
fetchUsers( [
'learner',
'experienced' ], $now ),
617 'Learner and more experienced'
623 foreach ( $specs
as $name => $spec ) {
627 'editcount' => $spec[
'edits'],
628 'registration' => $dbw->timestamp( $this->daysAgo( $spec[
'days'], $now ) ),
644 call_user_func_array(
645 [ $this->changesListSpecialPage,
'filterOnUserExperienceLevel' ],
647 get_class( $this->changesListSpecialPage ),
648 $this->changesListSpecialPage->getContext(),
649 $this->changesListSpecialPage->getDB(),
665 array_filter( $conds ) + [
'user_email' =>
'ut' ]
670 $usernames[] = $row->user_name;
677 $secondsPerDay = 86400;
678 return $now - $days * $secondsPerDay;
682 $this->changesListSpecialPage->filterGroups = [];
686 'name' =>
'gub-group',
687 'title' =>
'gub-group-title',
692 'label' =>
'foo-label',
693 'description' =>
'foo-description',
695 'showHide' =>
'showhidefoo',
700 'label' =>
'bar-label',
701 'description' =>
'bar-description',
709 'name' =>
'des-group',
710 'title' =>
'des-group-title',
712 'isFullCoverage' =>
true,
716 'label' =>
'grault-label',
717 'description' =>
'grault-description',
721 'label' =>
'garply-label',
722 'description' =>
'garply-description',
725 'queryCallable' =>
function () {
731 'name' =>
'unstructured',
735 'name' =>
'hidethud',
736 'showHide' =>
'showhidethud',
742 'showHide' =>
'showhidemos',
750 $this->changesListSpecialPage->registerFiltersFromDefinitions( $definition );
759 'name' =>
'gub-group',
760 'title' =>
'gub-group-title',
766 'label' =>
'bar-label',
767 'description' =>
'bar-description',
773 'defaultHighlightColor' =>
null
777 'label' =>
'foo-label',
778 'description' =>
'foo-description',
784 'defaultHighlightColor' =>
null
787 'fullCoverage' =>
true,
792 'name' =>
'des-group',
793 'title' =>
'des-group-title',
796 'fullCoverage' =>
true,
800 'label' =>
'grault-label',
801 'description' =>
'grault-description',
806 'defaultHighlightColor' =>
null
810 'label' =>
'garply-label',
811 'description' =>
'garply-description',
816 'defaultHighlightColor' =>
null
832 'grault-description',
834 'garply-description',
837 $this->changesListSpecialPage->getStructuredFilterJsData(),
false,
true
845 [
'hidebots', [
'hidebots' =>
true ] ],
847 [
'bots', [
'hidebots' =>
false ] ],
849 [
'hideminor', [
'hideminor' =>
true ] ],
851 [
'minor', [
'hideminor' =>
false ] ],
853 [
'hidemajor', [
'hidemajor' =>
true ] ],
855 [
'hideliu', [
'hideliu' =>
true ] ],
857 [
'hidepatrolled', [
'hidepatrolled' =>
true ] ],
859 [
'hideunpatrolled', [
'hideunpatrolled' =>
true ] ],
861 [
'hideanons', [
'hideanons' =>
true ] ],
863 [
'hidemyself', [
'hidemyself' =>
true ] ],
865 [
'hidebyothers', [
'hidebyothers' =>
true ] ],
867 [
'hidehumans', [
'hidehumans' =>
true ] ],
869 [
'hidepageedits', [
'hidepageedits' =>
true ] ],
871 [
'pagedits', [
'hidepageedits' =>
false ] ],
873 [
'hidenewpages', [
'hidenewpages' =>
true ] ],
875 [
'hidecategorization', [
'hidecategorization' =>
true ] ],
877 [
'hidelog', [
'hidelog' =>
true ] ],
880 'userExpLevel=learner;experienced',
882 'userExpLevel' =>
'learner;experienced'
888 'bots,hideliu,hidemyself',
892 'hidemyself' =>
true,
897 'minor,hideanons,categorization',
899 'hideminor' =>
false,
901 'hidecategorization' =>
false,
906 'hidehumans,bots,hidecategorization',
908 'hidehumans' =>
true,
910 'hidecategorization' =>
true,
915 'hidemyself,userExpLevel=newcomer;learner,hideminor',
917 'hidemyself' =>
true,
919 'userExpLevel' =>
'newcomer;learner',
929 "expectedConflicts" =>
false,
934 "userExpLevel" =>
"newcomer",
936 "expectedConflicts" =>
false,
941 "userExpLevel" =>
"learner",
943 "expectedConflicts" =>
false,
948 "hidenewpages" =>
true,
949 "hidepageedits" =>
true,
950 "hidecategorization" =>
false,
952 "hideWikidata" =>
true,
954 "expectedConflicts" =>
true,
959 "hidenewpages" =>
false,
960 "hidepageedits" =>
true,
961 "hidecategorization" =>
false,
963 "hideWikidata" =>
true,
965 "expectedConflicts" =>
true,
970 "hidenewpages" =>
false,
971 "hidepageedits" =>
false,
972 "hidecategorization" =>
true,
974 "hideWikidata" =>
true,
976 "expectedConflicts" =>
false,
981 "hidenewpages" =>
true,
982 "hidepageedits" =>
true,
983 "hidecategorization" =>
false,
985 "hideWikidata" =>
true,
987 "expectedConflicts" =>
false,
998 $this->changesListSpecialPage->setContext(
$context );
1000 $this->assertEquals(
1002 $this->changesListSpecialPage->areFiltersInConflict()
1009 [
'hideanons' => 1,
'hideliu' => 1,
'hidebots' => 1 ],
1011 [
'userExpLevel' =>
'unregistered',
'hidebots' => 1, ],
1015 [
'hideanons' => 1,
'hideliu' => 1,
'hidebots' => 0 ],
1017 [
'hidebots' => 0,
'hidehumans' => 1 ],
1021 [
'hideanons' => 1 ],
1023 [
'userExpLevel' =>
'registered' ],
1029 [
'userExpLevel' =>
'unregistered' ],
1033 [
'hideanons' => 1,
'hidebots' => 1 ],
1035 [
'userExpLevel' =>
'registered',
'hidebots' => 1 ],
1039 [
'hideliu' => 1,
'hidebots' => 0 ],
1041 [
'userExpLevel' =>
'unregistered',
'hidebots' => 0 ],
1045 [
'hidemyself' => 1,
'hidebyothers' => 1 ],
1051 [
'hidebots' => 1,
'hidehumans' => 1 ],
1057 [
'hidepatrolled' => 1,
'hideunpatrolled' => 1 ],
1063 [
'hideminor' => 1,
'hidemajor' => 1 ],
1070 [
'hidepageedits' => 1,
'hidenewpages' => 1,
'hidecategorization' => 1,
'hidelog' => 1, ],
testRcNsFilterMultipleAssociatedInvert()
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
WebRequest clone which takes values from a provided array.
processing should stop and the error should be shown to the user * false
testFilterUserExpLevelAllExperienceLevels()
testFilterUserExpLevelRegisteredUnregisteredLearner()
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
testRcHideunpatrolledFilter()
assertConditions( $expected, $requestOptions=null, $message='', $user=null)
helper to test SpecialRecentchanges::buildQuery()
testFilterUserExpLevelRegistrered()
testFilterUserExpLevelUnregistrered()
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED since 1.16! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
testRcNsFilterMultipleAssociated()
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
testRcNsFilterInversion()
testFilterUserExpLevelRegistreredOrLearner()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static createNew( $name, $params=[])
Add a user to the database, return the user object.
Test class for ChangesListSpecialPage class.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
testFilterUserExpLevelUnregistreredOrExperienced()
testGetFilterConflicts( $parameters, $expectedConflicts)
provideGetFilterConflicts
testRcHidebyothersFilter()
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
testFilterUserExpLevelAll()
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Group all the pieces relevant to the context of a request into one instance.
testRcHideunpatrolledDisabledFilter()
provideGetFilterConflicts()
fetchUsers( $filters, $now)
Allows to change the fields on the form that will be generated $name
createUsers( $specs, $now)
static normalizeCondition( $conds)
testRcHidepatrolledFilter()
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
buildQuery( $requestOptions=null, $user=null)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const SCHEMA_COMPAT_WRITE_BOTH
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
testRcNsFilterMultipleInvert()
const TYPE
Type marker, used by JavaScript.
validateOptionsProvider()
static filterOutRcTimestampCondition( $var)
return false if condition begins with 'rc_timestamp '
const TYPE
Type marker, used by JavaScript.
testFilterUserExpLevelRegisteredUnregistered()
const SCHEMA_COMPAT_READ_OLD
testRcReviewStatusFilter()
Abstract base class for shared logic when testing ChangesListSpecialPage and subclasses.
testGetStructuredFilterJsData()
testRcHidepatrolledDisabledFilter()