MediaWiki  master
RedirectSpecialPage.php
Go to the documentation of this file.
1 <?php
29 abstract class RedirectSpecialPage extends UnlistedSpecialPage {
30  // Query parameters that can be passed through redirects
31  protected $mAllowedRedirectParams = [];
32 
33  // Query parameters added by redirects
34  protected $mAddedRedirectParams = [];
35 
39  public function execute( $subpage ) {
40  $redirect = $this->getRedirect( $subpage );
41  $query = $this->getRedirectQuery( $subpage );
42 
43  if ( $redirect instanceof Title ) {
44  // Redirect to a page title with possible query parameters
45  $url = $redirect->getFullUrlForRedirect( $query );
46  $this->getOutput()->redirect( $url );
47  } elseif ( $redirect === true ) {
48  // Redirect to index.php with query parameters
49  $url = wfAppendQuery( wfScript( 'index' ), $query );
50  $this->getOutput()->redirect( $url );
51  } else {
52  $this->showNoRedirectPage();
53  }
54  }
55 
63  abstract public function getRedirect( $subpage );
64 
72  public function getRedirectQuery( $subpage ) {
73  $params = [];
74  $request = $this->getRequest();
75 
76  foreach ( array_merge( $this->mAllowedRedirectParams,
77  [ 'uselang', 'useskin', 'debug', 'safemode' ] // parameters which can be passed to all pages
78  ) as $arg ) {
79  if ( $request->getVal( $arg, null ) !== null ) {
80  $params[$arg] = $request->getVal( $arg );
81  } elseif ( $request->getArray( $arg, null ) !== null ) {
82  $params[$arg] = $request->getArray( $arg );
83  }
84  }
85 
86  foreach ( $this->mAddedRedirectParams as $arg => $val ) {
87  $params[$arg] = $val;
88  }
89 
90  return count( $params )
91  ? $params
92  : false;
93  }
94 
103  public function personallyIdentifiableTarget() {
104  return false;
105  }
106 
107  protected function showNoRedirectPage() {
108  $class = static::class;
109  throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
110  }
111 }
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1529
Shortcut to construct a special page which is unlisted by default.
getOutput()
Get the OutputPage being used for this instance.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
getRedirectQuery( $subpage)
Return part of the request string for a special redirect page This allows passing, e.g.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Shortcut to construct a special page alias.
$params
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
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
Definition: distributors.txt:9
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
Definition: injection.txt:35
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
Definition: maintenance.txt:52
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.
personallyIdentifiableTarget()
Indicate if the target of this redirect can be used to identify a particular user of this wiki (e...
getRequest()
Get the WebRequest being used for this instance.
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 $request
Definition: hooks.txt:2621