MediaWiki  master
RedirectSpecialArticle.php
Go to the documentation of this file.
1 <?php
25 
92 
98  public function __construct( $name ) {
99  parent::__construct( $name );
100  $redirectParams = [
101  'action',
102  'redirect', 'rdfrom',
103  # Options for preloaded edits
104  'preload', 'preloadparams', 'editintro', 'preloadtitle', 'summary', 'nosummary',
105  # Options for overriding user settings
106  'preview', 'minor', 'watchthis',
107  # Options for history/diffs
108  'section', 'oldid', 'diff', 'dir',
109  'limit', 'offset', 'feed',
110  # Misc options
111  'redlink',
112  # Options for action=raw; missing ctype can break JS or CSS in some browsers
113  'ctype', 'maxage', 'smaxage',
114  ];
115 
116  $this->getHookRunner()->onRedirectSpecialArticleRedirectParams( $redirectParams );
117  $this->mAllowedRedirectParams = $redirectParams;
118  }
119 
123  public function getRedirectQuery( $subpage ) {
124  $query = parent::getRedirectQuery( $subpage );
125  $title = $this->getRedirect( $subpage );
126  // Avoid double redirect for action=edit&redlink=1 for existing pages
127  // (compare to the check in EditPage::edit)
128  if (
129  $query && isset( $query['action'] ) && isset( $query['redlink'] ) &&
130  ( $query['action'] === 'edit' || $query['action'] === 'submit' ) &&
131  (bool)$query['redlink'] &&
132  $title instanceof Title &&
133  $title->exists()
134  ) {
135  return false;
136  }
137  return $query;
138  }
139 
140 }
Represents a title within MediaWiki.
Definition: Title.php:82
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
getRedirectQuery( $subpage)
Return part of the request string for a special redirect page This allows passing,...
Shortcut to construct a special page alias.
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.