Merge "Replace extract() with explicit variable definitions in DjVuImage"
[lhc/web/wiklou.git] / includes / specialpage / SpecialPage.php
1 <?php
2 /**
3 * Parent class for all special pages.
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 SpecialPage
22 */
23
24 use MediaWiki\Auth\AuthManager;
25 use MediaWiki\Linker\LinkRenderer;
26 use MediaWiki\MediaWikiServices;
27
28 /**
29 * Parent class for all special pages.
30 *
31 * Includes some static functions for handling the special page list deprecated
32 * in favor of SpecialPageFactory.
33 *
34 * @ingroup SpecialPage
35 */
36 class SpecialPage {
37 // The canonical name of this special page
38 // Also used for the default <h1> heading, @see getDescription()
39 protected $mName;
40
41 // The local name of this special page
42 private $mLocalName;
43
44 // Minimum user level required to access this page, or "" for anyone.
45 // Also used to categorise the pages in Special:Specialpages
46 protected $mRestriction;
47
48 // Listed in Special:Specialpages?
49 private $mListed;
50
51 // Whether or not this special page is being included from an article
52 protected $mIncluding;
53
54 // Whether the special page can be included in an article
55 protected $mIncludable;
56
57 /**
58 * Current request context
59 * @var IContextSource
60 */
61 protected $mContext;
62
63 /**
64 * @var \MediaWiki\Linker\LinkRenderer|null
65 */
66 private $linkRenderer;
67
68 /**
69 * Get a localised Title object for a specified special page name
70 *
71 * @since 1.9
72 * @since 1.21 $fragment parameter added
73 *
74 * @param string $name
75 * @param string|bool $subpage Subpage string, or false to not use a subpage
76 * @param string $fragment The link fragment (after the "#")
77 * @return Title
78 * @throws MWException
79 */
80 public static function getTitleFor( $name, $subpage = false, $fragment = '' ) {
81 $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
82
83 return Title::makeTitle( NS_SPECIAL, $name, $fragment );
84 }
85
86 /**
87 * Get a localised Title object for a page name with a possibly unvalidated subpage
88 *
89 * @param string $name
90 * @param string|bool $subpage Subpage string, or false to not use a subpage
91 * @return Title|null Title object or null if the page doesn't exist
92 */
93 public static function getSafeTitleFor( $name, $subpage = false ) {
94 $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
95 if ( $name ) {
96 return Title::makeTitleSafe( NS_SPECIAL, $name );
97 } else {
98 return null;
99 }
100 }
101
102 /**
103 * Default constructor for special pages
104 * Derivative classes should call this from their constructor
105 * Note that if the user does not have the required level, an error message will
106 * be displayed by the default execute() method, without the global function ever
107 * being called.
108 *
109 * If you override execute(), you can recover the default behavior with userCanExecute()
110 * and displayRestrictionError()
111 *
112 * @param string $name Name of the special page, as seen in links and URLs
113 * @param string $restriction User right required, e.g. "block" or "delete"
114 * @param bool $listed Whether the page is listed in Special:Specialpages
115 * @param callable|bool $function Unused
116 * @param string $file Unused
117 * @param bool $includable Whether the page can be included in normal pages
118 */
119 public function __construct(
120 $name = '', $restriction = '', $listed = true,
121 $function = false, $file = '', $includable = false
122 ) {
123 $this->mName = $name;
124 $this->mRestriction = $restriction;
125 $this->mListed = $listed;
126 $this->mIncludable = $includable;
127 }
128
129 /**
130 * Get the name of this Special Page.
131 * @return string
132 */
133 function getName() {
134 return $this->mName;
135 }
136
137 /**
138 * Get the permission that a user must have to execute this page
139 * @return string
140 */
141 function getRestriction() {
142 return $this->mRestriction;
143 }
144
145 // @todo FIXME: Decide which syntax to use for this, and stick to it
146 /**
147 * Whether this special page is listed in Special:SpecialPages
148 * @since 1.3 (r3583)
149 * @return bool
150 */
151 function isListed() {
152 return $this->mListed;
153 }
154
155 /**
156 * Set whether this page is listed in Special:Specialpages, at run-time
157 * @since 1.3
158 * @param bool $listed
159 * @return bool
160 */
161 function setListed( $listed ) {
162 return wfSetVar( $this->mListed, $listed );
163 }
164
165 /**
166 * Get or set whether this special page is listed in Special:SpecialPages
167 * @since 1.6
168 * @param bool $x
169 * @return bool
170 */
171 function listed( $x = null ) {
172 return wfSetVar( $this->mListed, $x );
173 }
174
175 /**
176 * Whether it's allowed to transclude the special page via {{Special:Foo/params}}
177 * @return bool
178 */
179 public function isIncludable() {
180 return $this->mIncludable;
181 }
182
183 /**
184 * How long to cache page when it is being included.
185 *
186 * @note If cache time is not 0, then the current user becomes an anon
187 * if you want to do any per-user customizations, than this method
188 * must be overriden to return 0.
189 * @since 1.26
190 * @return int Time in seconds, 0 to disable caching altogether,
191 * false to use the parent page's cache settings
192 */
193 public function maxIncludeCacheTime() {
194 return $this->getConfig()->get( 'MiserMode' ) ? $this->getCacheTTL() : 0;
195 }
196
197 /**
198 * @return int Seconds that this page can be cached
199 */
200 protected function getCacheTTL() {
201 return 60 * 60;
202 }
203
204 /**
205 * Whether the special page is being evaluated via transclusion
206 * @param bool $x
207 * @return bool
208 */
209 function including( $x = null ) {
210 return wfSetVar( $this->mIncluding, $x );
211 }
212
213 /**
214 * Get the localised name of the special page
215 * @return string
216 */
217 function getLocalName() {
218 if ( !isset( $this->mLocalName ) ) {
219 $this->mLocalName = SpecialPageFactory::getLocalNameFor( $this->mName );
220 }
221
222 return $this->mLocalName;
223 }
224
225 /**
226 * Is this page expensive (for some definition of expensive)?
227 * Expensive pages are disabled or cached in miser mode. Originally used
228 * (and still overridden) by QueryPage and subclasses, moved here so that
229 * Special:SpecialPages can safely call it for all special pages.
230 *
231 * @return bool
232 */
233 public function isExpensive() {
234 return false;
235 }
236
237 /**
238 * Is this page cached?
239 * Expensive pages are cached or disabled in miser mode.
240 * Used by QueryPage and subclasses, moved here so that
241 * Special:SpecialPages can safely call it for all special pages.
242 *
243 * @return bool
244 * @since 1.21
245 */
246 public function isCached() {
247 return false;
248 }
249
250 /**
251 * Can be overridden by subclasses with more complicated permissions
252 * schemes.
253 *
254 * @return bool Should the page be displayed with the restricted-access
255 * pages?
256 */
257 public function isRestricted() {
258 // DWIM: If anons can do something, then it is not restricted
259 return $this->mRestriction != '' && !User::groupHasPermission( '*', $this->mRestriction );
260 }
261
262 /**
263 * Checks if the given user (identified by an object) can execute this
264 * special page (as defined by $mRestriction). Can be overridden by sub-
265 * classes with more complicated permissions schemes.
266 *
267 * @param User $user The user to check
268 * @return bool Does the user have permission to view the page?
269 */
270 public function userCanExecute( User $user ) {
271 return $user->isAllowed( $this->mRestriction );
272 }
273
274 /**
275 * Output an error message telling the user what access level they have to have
276 * @throws PermissionsError
277 */
278 function displayRestrictionError() {
279 throw new PermissionsError( $this->mRestriction );
280 }
281
282 /**
283 * Checks if userCanExecute, and if not throws a PermissionsError
284 *
285 * @since 1.19
286 * @return void
287 * @throws PermissionsError
288 */
289 public function checkPermissions() {
290 if ( !$this->userCanExecute( $this->getUser() ) ) {
291 $this->displayRestrictionError();
292 }
293 }
294
295 /**
296 * If the wiki is currently in readonly mode, throws a ReadOnlyError
297 *
298 * @since 1.19
299 * @return void
300 * @throws ReadOnlyError
301 */
302 public function checkReadOnly() {
303 if ( wfReadOnly() ) {
304 throw new ReadOnlyError;
305 }
306 }
307
308 /**
309 * If the user is not logged in, throws UserNotLoggedIn error
310 *
311 * The user will be redirected to Special:Userlogin with the given message as an error on
312 * the form.
313 *
314 * @since 1.23
315 * @param string $reasonMsg [optional] Message key to be displayed on login page
316 * @param string $titleMsg [optional] Passed on to UserNotLoggedIn constructor
317 * @throws UserNotLoggedIn
318 */
319 public function requireLogin(
320 $reasonMsg = 'exception-nologin-text', $titleMsg = 'exception-nologin'
321 ) {
322 if ( $this->getUser()->isAnon() ) {
323 throw new UserNotLoggedIn( $reasonMsg, $titleMsg );
324 }
325 }
326
327 /**
328 * Tells if the special page does something security-sensitive and needs extra defense against
329 * a stolen account (e.g. a reauthentication). What exactly that will mean is decided by the
330 * authentication framework.
331 * @return bool|string False or the argument for AuthManager::securitySensitiveOperationStatus().
332 * Typically a special page needing elevated security would return its name here.
333 */
334 protected function getLoginSecurityLevel() {
335 return false;
336 }
337
338 /**
339 * Verifies that the user meets the security level, possibly reauthenticating them in the process.
340 *
341 * This should be used when the page does something security-sensitive and needs extra defense
342 * against a stolen account (e.g. a reauthentication). The authentication framework will make
343 * an extra effort to make sure the user account is not compromised. What that exactly means
344 * will depend on the system and user settings; e.g. the user might be required to log in again
345 * unless their last login happened recently, or they might be given a second-factor challenge.
346 *
347 * Calling this method will result in one if these actions:
348 * - return true: all good.
349 * - return false and set a redirect: caller should abort; the redirect will take the user
350 * to the login page for reauthentication, and back.
351 * - throw an exception if there is no way for the user to meet the requirements without using
352 * a different access method (e.g. this functionality is only available from a specific IP).
353 *
354 * Note that this does not in any way check that the user is authorized to use this special page
355 * (use checkPermissions() for that).
356 *
357 * @param string $level A security level. Can be an arbitrary string, defaults to the page name.
358 * @return bool False means a redirect to the reauthentication page has been set and processing
359 * of the special page should be aborted.
360 * @throws ErrorPageError If the security level cannot be met, even with reauthentication.
361 */
362 protected function checkLoginSecurityLevel( $level = null ) {
363 $level = $level ?: $this->getName();
364 $securityStatus = AuthManager::singleton()->securitySensitiveOperationStatus( $level );
365 if ( $securityStatus === AuthManager::SEC_OK ) {
366 return true;
367 } elseif ( $securityStatus === AuthManager::SEC_REAUTH ) {
368 $request = $this->getRequest();
369 $title = SpecialPage::getTitleFor( 'Userlogin' );
370 $query = [
371 'returnto' => $this->getFullTitle()->getPrefixedDBkey(),
372 'returntoquery' => wfArrayToCgi( array_diff_key( $request->getQueryValues(),
373 [ 'title' => true ] ) ),
374 'force' => $level,
375 ];
376 $url = $title->getFullURL( $query, false, PROTO_HTTPS );
377
378 $this->getOutput()->redirect( $url );
379 return false;
380 }
381
382 $titleMessage = wfMessage( 'specialpage-securitylevel-not-allowed-title' );
383 $errorMessage = wfMessage( 'specialpage-securitylevel-not-allowed' );
384 throw new ErrorPageError( $titleMessage, $errorMessage );
385 }
386
387 /**
388 * Return an array of subpages beginning with $search that this special page will accept.
389 *
390 * For example, if a page supports subpages "foo", "bar" and "baz" (as in Special:PageName/foo,
391 * etc.):
392 *
393 * - `prefixSearchSubpages( "ba" )` should return `array( "bar", "baz" )`
394 * - `prefixSearchSubpages( "f" )` should return `array( "foo" )`
395 * - `prefixSearchSubpages( "z" )` should return `array()`
396 * - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )`
397 *
398 * @param string $search Prefix to search for
399 * @param int $limit Maximum number of results to return (usually 10)
400 * @param int $offset Number of results to skip (usually 0)
401 * @return string[] Matching subpages
402 */
403 public function prefixSearchSubpages( $search, $limit, $offset ) {
404 $subpages = $this->getSubpagesForPrefixSearch();
405 if ( !$subpages ) {
406 return [];
407 }
408
409 return self::prefixSearchArray( $search, $limit, $subpages, $offset );
410 }
411
412 /**
413 * Return an array of subpages that this special page will accept for prefix
414 * searches. If this method requires a query you might instead want to implement
415 * prefixSearchSubpages() directly so you can support $limit and $offset. This
416 * method is better for static-ish lists of things.
417 *
418 * @return string[] subpages to search from
419 */
420 protected function getSubpagesForPrefixSearch() {
421 return [];
422 }
423
424 /**
425 * Perform a regular substring search for prefixSearchSubpages
426 * @param string $search Prefix to search for
427 * @param int $limit Maximum number of results to return (usually 10)
428 * @param int $offset Number of results to skip (usually 0)
429 * @return string[] Matching subpages
430 */
431 protected function prefixSearchString( $search, $limit, $offset ) {
432 $title = Title::newFromText( $search );
433 if ( !$title || !$title->canExist() ) {
434 // No prefix suggestion in special and media namespace
435 return [];
436 }
437
438 $searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
439 $searchEngine->setLimitOffset( $limit, $offset );
440 $searchEngine->setNamespaces( [] );
441 $result = $searchEngine->defaultPrefixSearch( $search );
442 return array_map( function( Title $t ) {
443 return $t->getPrefixedText();
444 }, $result );
445 }
446
447 /**
448 * Helper function for implementations of prefixSearchSubpages() that
449 * filter the values in memory (as opposed to making a query).
450 *
451 * @since 1.24
452 * @param string $search
453 * @param int $limit
454 * @param array $subpages
455 * @param int $offset
456 * @return string[]
457 */
458 protected static function prefixSearchArray( $search, $limit, array $subpages, $offset ) {
459 $escaped = preg_quote( $search, '/' );
460 return array_slice( preg_grep( "/^$escaped/i",
461 array_slice( $subpages, $offset ) ), 0, $limit );
462 }
463
464 /**
465 * Sets headers - this should be called from the execute() method of all derived classes!
466 */
467 function setHeaders() {
468 $out = $this->getOutput();
469 $out->setArticleRelated( false );
470 $out->setRobotPolicy( $this->getRobotPolicy() );
471 $out->setPageTitle( $this->getDescription() );
472 if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
473 $out->addModuleStyles( [
474 'mediawiki.ui.input',
475 'mediawiki.ui.radio',
476 'mediawiki.ui.checkbox',
477 ] );
478 }
479 }
480
481 /**
482 * Entry point.
483 *
484 * @since 1.20
485 *
486 * @param string|null $subPage
487 */
488 final public function run( $subPage ) {
489 /**
490 * Gets called before @see SpecialPage::execute.
491 * Return false to prevent calling execute() (since 1.27+).
492 *
493 * @since 1.20
494 *
495 * @param SpecialPage $this
496 * @param string|null $subPage
497 */
498 if ( !Hooks::run( 'SpecialPageBeforeExecute', [ $this, $subPage ] ) ) {
499 return;
500 }
501
502 if ( $this->beforeExecute( $subPage ) === false ) {
503 return;
504 }
505 $this->execute( $subPage );
506 $this->afterExecute( $subPage );
507
508 /**
509 * Gets called after @see SpecialPage::execute.
510 *
511 * @since 1.20
512 *
513 * @param SpecialPage $this
514 * @param string|null $subPage
515 */
516 Hooks::run( 'SpecialPageAfterExecute', [ $this, $subPage ] );
517 }
518
519 /**
520 * Gets called before @see SpecialPage::execute.
521 * Return false to prevent calling execute() (since 1.27+).
522 *
523 * @since 1.20
524 *
525 * @param string|null $subPage
526 * @return bool|void
527 */
528 protected function beforeExecute( $subPage ) {
529 // No-op
530 }
531
532 /**
533 * Gets called after @see SpecialPage::execute.
534 *
535 * @since 1.20
536 *
537 * @param string|null $subPage
538 */
539 protected function afterExecute( $subPage ) {
540 // No-op
541 }
542
543 /**
544 * Default execute method
545 * Checks user permissions
546 *
547 * This must be overridden by subclasses; it will be made abstract in a future version
548 *
549 * @param string|null $subPage
550 */
551 public function execute( $subPage ) {
552 $this->setHeaders();
553 $this->checkPermissions();
554 $this->checkLoginSecurityLevel( $this->getLoginSecurityLevel() );
555 $this->outputHeader();
556 }
557
558 /**
559 * Outputs a summary message on top of special pages
560 * Per default the message key is the canonical name of the special page
561 * May be overridden, i.e. by extensions to stick with the naming conventions
562 * for message keys: 'extensionname-xxx'
563 *
564 * @param string $summaryMessageKey Message key of the summary
565 */
566 function outputHeader( $summaryMessageKey = '' ) {
567 global $wgContLang;
568
569 if ( $summaryMessageKey == '' ) {
570 $msg = $wgContLang->lc( $this->getName() ) . '-summary';
571 } else {
572 $msg = $summaryMessageKey;
573 }
574 if ( !$this->msg( $msg )->isDisabled() && !$this->including() ) {
575 $this->getOutput()->wrapWikiMsg(
576 "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
577 }
578 }
579
580 /**
581 * Returns the name that goes in the \<h1\> in the special page itself, and
582 * also the name that will be listed in Special:Specialpages
583 *
584 * Derived classes can override this, but usually it is easier to keep the
585 * default behavior.
586 *
587 * @return string
588 */
589 function getDescription() {
590 return $this->msg( strtolower( $this->mName ) )->text();
591 }
592
593 /**
594 * Get a self-referential title object
595 *
596 * @param string|bool $subpage
597 * @return Title
598 * @deprecated since 1.23, use SpecialPage::getPageTitle
599 */
600 function getTitle( $subpage = false ) {
601 return $this->getPageTitle( $subpage );
602 }
603
604 /**
605 * Get a self-referential title object
606 *
607 * @param string|bool $subpage
608 * @return Title
609 * @since 1.23
610 */
611 function getPageTitle( $subpage = false ) {
612 return self::getTitleFor( $this->mName, $subpage );
613 }
614
615 /**
616 * Sets the context this SpecialPage is executed in
617 *
618 * @param IContextSource $context
619 * @since 1.18
620 */
621 public function setContext( $context ) {
622 $this->mContext = $context;
623 }
624
625 /**
626 * Gets the context this SpecialPage is executed in
627 *
628 * @return IContextSource|RequestContext
629 * @since 1.18
630 */
631 public function getContext() {
632 if ( $this->mContext instanceof IContextSource ) {
633 return $this->mContext;
634 } else {
635 wfDebug( __METHOD__ . " called and \$mContext is null. " .
636 "Return RequestContext::getMain(); for sanity\n" );
637
638 return RequestContext::getMain();
639 }
640 }
641
642 /**
643 * Get the WebRequest being used for this instance
644 *
645 * @return WebRequest
646 * @since 1.18
647 */
648 public function getRequest() {
649 return $this->getContext()->getRequest();
650 }
651
652 /**
653 * Get the OutputPage being used for this instance
654 *
655 * @return OutputPage
656 * @since 1.18
657 */
658 public function getOutput() {
659 return $this->getContext()->getOutput();
660 }
661
662 /**
663 * Shortcut to get the User executing this instance
664 *
665 * @return User
666 * @since 1.18
667 */
668 public function getUser() {
669 return $this->getContext()->getUser();
670 }
671
672 /**
673 * Shortcut to get the skin being used for this instance
674 *
675 * @return Skin
676 * @since 1.18
677 */
678 public function getSkin() {
679 return $this->getContext()->getSkin();
680 }
681
682 /**
683 * Shortcut to get user's language
684 *
685 * @return Language
686 * @since 1.19
687 */
688 public function getLanguage() {
689 return $this->getContext()->getLanguage();
690 }
691
692 /**
693 * Shortcut to get main config object
694 * @return Config
695 * @since 1.24
696 */
697 public function getConfig() {
698 return $this->getContext()->getConfig();
699 }
700
701 /**
702 * Return the full title, including $par
703 *
704 * @return Title
705 * @since 1.18
706 */
707 public function getFullTitle() {
708 return $this->getContext()->getTitle();
709 }
710
711 /**
712 * Return the robot policy. Derived classes that override this can change
713 * the robot policy set by setHeaders() from the default 'noindex,nofollow'.
714 *
715 * @return string
716 * @since 1.23
717 */
718 protected function getRobotPolicy() {
719 return 'noindex,nofollow';
720 }
721
722 /**
723 * Wrapper around wfMessage that sets the current context.
724 *
725 * @since 1.16
726 * @return Message
727 * @see wfMessage
728 */
729 public function msg( /* $args */ ) {
730 $message = call_user_func_array(
731 [ $this->getContext(), 'msg' ],
732 func_get_args()
733 );
734 // RequestContext passes context to wfMessage, and the language is set from
735 // the context, but setting the language for Message class removes the
736 // interface message status, which breaks for example usernameless gender
737 // invocations. Restore the flag when not including special page in content.
738 if ( $this->including() ) {
739 $message->setInterfaceMessageFlag( false );
740 }
741
742 return $message;
743 }
744
745 /**
746 * Adds RSS/atom links
747 *
748 * @param array $params
749 */
750 protected function addFeedLinks( $params ) {
751 $feedTemplate = wfScript( 'api' );
752
753 foreach ( $this->getConfig()->get( 'FeedClasses' ) as $format => $class ) {
754 $theseParams = $params + [ 'feedformat' => $format ];
755 $url = wfAppendQuery( $feedTemplate, $theseParams );
756 $this->getOutput()->addFeedLink( $format, $url );
757 }
758 }
759
760 /**
761 * Adds help link with an icon via page indicators.
762 * Link target can be overridden by a local message containing a wikilink:
763 * the message key is: lowercase special page name + '-helppage'.
764 * @param string $to Target MediaWiki.org page title or encoded URL.
765 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
766 * @since 1.25
767 */
768 public function addHelpLink( $to, $overrideBaseUrl = false ) {
769 global $wgContLang;
770 $msg = $this->msg( $wgContLang->lc( $this->getName() ) . '-helppage' );
771
772 if ( !$msg->isDisabled() ) {
773 $helpUrl = Skin::makeUrl( $msg->plain() );
774 $this->getOutput()->addHelpLink( $helpUrl, true );
775 } else {
776 $this->getOutput()->addHelpLink( $to, $overrideBaseUrl );
777 }
778 }
779
780 /**
781 * Get the group that the special page belongs in on Special:SpecialPage
782 * Use this method, instead of getGroupName to allow customization
783 * of the group name from the wiki side
784 *
785 * @return string Group of this special page
786 * @since 1.21
787 */
788 public function getFinalGroupName() {
789 $name = $this->getName();
790
791 // Allow overbidding the group from the wiki side
792 $msg = $this->msg( 'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage();
793 if ( !$msg->isBlank() ) {
794 $group = $msg->text();
795 } else {
796 // Than use the group from this object
797 $group = $this->getGroupName();
798 }
799
800 return $group;
801 }
802
803 /**
804 * Indicates whether this special page may perform database writes
805 *
806 * @return bool
807 * @since 1.27
808 */
809 public function doesWrites() {
810 return false;
811 }
812
813 /**
814 * Under which header this special page is listed in Special:SpecialPages
815 * See messages 'specialpages-group-*' for valid names
816 * This method defaults to group 'other'
817 *
818 * @return string
819 * @since 1.21
820 */
821 protected function getGroupName() {
822 return 'other';
823 }
824
825 /**
826 * Call wfTransactionalTimeLimit() if this request was POSTed
827 * @since 1.26
828 */
829 protected function useTransactionalTimeLimit() {
830 if ( $this->getRequest()->wasPosted() ) {
831 wfTransactionalTimeLimit();
832 }
833 }
834
835 /**
836 * @since 1.28
837 * @return \MediaWiki\Linker\LinkRenderer
838 */
839 protected function getLinkRenderer() {
840 if ( $this->linkRenderer ) {
841 return $this->linkRenderer;
842 } else {
843 return MediaWikiServices::getInstance()->getLinkRenderer();
844 }
845 }
846
847 /**
848 * @since 1.28
849 * @param \MediaWiki\Linker\LinkRenderer $linkRenderer
850 */
851 public function setLinkRenderer( LinkRenderer $linkRenderer ) {
852 $this->linkRenderer = $linkRenderer;
853 }
854 }