Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
70.77% |
494 / 698 |
|
36.36% |
32 / 88 |
CRAP | |
0.00% |
0 / 1 |
CoreParserFunctions | |
70.88% |
494 / 697 |
|
36.36% |
32 / 88 |
2321.95 | |
0.00% |
0 / 1 |
register | |
90.74% |
49 / 54 |
|
0.00% |
0 / 1 |
4.01 | |||
intFunction | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
formatDate | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 | |||
ns | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
4.07 | |||
nse | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
urlencode | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
6 | |||
lcfirst | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
ucfirst | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
lc | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
uc | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
localurl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
localurle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
fullurl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
fullurle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
canonicalurl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
canonicalurle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
urlFunction | |
66.67% |
6 / 9 |
|
0.00% |
0 / 1 |
4.59 | |||
formatnum | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 | |||
getLegacyFormatNum | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
5 | |||
grammar | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
gender | |
77.78% |
14 / 18 |
|
0.00% |
0 / 1 |
8.70 | |||
plural | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
formal | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
bidi | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
displaytitle | |
81.25% |
39 / 48 |
|
0.00% |
0 / 1 |
15.29 | |||
matchAgainstMagicword | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
formatRaw | |
33.33% |
2 / 6 |
|
0.00% |
0 / 1 |
12.41 | |||
numberofpages | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
numberofusers | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
numberofactiveusers | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
numberofarticles | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
numberoffiles | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
numberofadmins | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
numberofedits | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
pagesinnamespace | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
numberingroup | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
makeTitle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
namespace | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
namespacee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
namespacenumber | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
talkspace | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
3.14 | |||
talkspacee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
3.14 | |||
subjectspace | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
subjectspacee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
pagename | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
pagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
fullpagename | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
fullpagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
subpagename | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
subpagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
rootpagename | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
rootpagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
basepagename | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
basepagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
talkpagename | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
talkpagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
3.14 | |||
subjectpagename | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
subjectpagenamee | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
pagesincategory | |
44.74% |
17 / 38 |
|
0.00% |
0 / 1 |
15.27 | |||
pagesize | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
5.05 | |||
protectionlevel | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
protectionexpiry | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
language | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
4 | |||
dir | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
6 | |||
bcp47 | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
pad | |
92.86% |
13 / 14 |
|
0.00% |
0 / 1 |
5.01 | |||
padleft | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
padright | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
anchorencode | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
special | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
speciale | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
defaultsort | |
55.00% |
11 / 20 |
|
0.00% |
0 / 1 |
13.83 | |||
filepath | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
56 | |||
tagObj | |
62.50% |
20 / 32 |
|
0.00% |
0 / 1 |
15.27 | |||
getCachedRevisionObject | |
83.33% |
25 / 30 |
|
0.00% |
0 / 1 |
16.04 | |||
pageid | |
43.48% |
10 / 23 |
|
0.00% |
0 / 1 |
23.63 | |||
revisionid | |
61.54% |
16 / 26 |
|
0.00% |
0 / 1 |
30.57 | |||
getRevisionTimestampSubstring | |
77.78% |
14 / 18 |
|
0.00% |
0 / 1 |
6.40 | |||
revisionday | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
revisionday2 | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
revisionmonth | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
revisionmonth1 | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
revisionyear | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
revisiontimestamp | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
revisionuser | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
6 | |||
cascadingsources | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
20 | |||
interwikilink | |
93.33% |
14 / 15 |
|
0.00% |
0 / 1 |
4.00 | |||
interlanguagelink | |
94.12% |
16 / 17 |
|
0.00% |
0 / 1 |
5.01 |
1 | <?php |
2 | /** |
3 | * Parser functions provided by MediaWiki core |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License along |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | * http://www.gnu.org/copyleft/gpl.html |
19 | * |
20 | * @file |
21 | * @ingroup Parser |
22 | */ |
23 | |
24 | namespace MediaWiki\Parser; |
25 | |
26 | use InvalidArgumentException; |
27 | use MediaWiki\Category\Category; |
28 | use MediaWiki\Config\ServiceOptions; |
29 | use MediaWiki\Language\Language; |
30 | use MediaWiki\Language\LanguageCode; |
31 | use MediaWiki\Languages\LanguageNameUtils; |
32 | use MediaWiki\Linker\Linker; |
33 | use MediaWiki\MainConfigNames; |
34 | use MediaWiki\MediaWikiServices; |
35 | use MediaWiki\Message\Message; |
36 | use MediaWiki\Revision\RevisionAccessException; |
37 | use MediaWiki\Revision\RevisionRecord; |
38 | use MediaWiki\SiteStats\SiteStats; |
39 | use MediaWiki\SpecialPage\SpecialPage; |
40 | use MediaWiki\Title\Title; |
41 | use MediaWiki\Title\TitleValue; |
42 | use MediaWiki\User\User; |
43 | use Wikimedia\Bcp47Code\Bcp47CodeValue; |
44 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
45 | use Wikimedia\RemexHtml\Tokenizer\PlainAttributes; |
46 | |
47 | /** |
48 | * Various core parser functions, registered in every Parser |
49 | * @ingroup Parser |
50 | */ |
51 | class CoreParserFunctions { |
52 | /** @var int Assume that no output will later be saved this many seconds after parsing */ |
53 | private const MAX_TTS = 900; |
54 | |
55 | /** |
56 | * @internal |
57 | */ |
58 | public const REGISTER_OPTIONS = [ |
59 | // See documentation for the corresponding config options |
60 | MainConfigNames::AllowDisplayTitle, |
61 | MainConfigNames::AllowSlowParserFunctions, |
62 | ]; |
63 | |
64 | /** |
65 | * @param Parser $parser |
66 | * @param ServiceOptions $options |
67 | * |
68 | * @return void |
69 | * @internal |
70 | */ |
71 | public static function register( Parser $parser, ServiceOptions $options ) { |
72 | $options->assertRequiredOptions( self::REGISTER_OPTIONS ); |
73 | $allowDisplayTitle = $options->get( MainConfigNames::AllowDisplayTitle ); |