MediaWiki  1.34.0
RedirectSpecialArticle.php
Go to the documentation of this file.
1 <?php
88  function __construct( $name ) {
89  parent::__construct( $name );
90  $redirectParams = [
91  'action',
92  'redirect', 'rdfrom',
93  # Options for preloaded edits
94  'preload', 'preloadparams', 'editintro', 'preloadtitle', 'summary', 'nosummary',
95  # Options for overriding user settings
96  'preview', 'minor', 'watchthis',
97  # Options for history/diffs
98  'section', 'oldid', 'diff', 'dir',
99  'limit', 'offset', 'feed',
100  # Misc options
101  'redlink',
102  # Options for action=raw; missing ctype can break JS or CSS in some browsers
103  'ctype', 'maxage', 'smaxage',
104  ];
105 
106  Hooks::run( "RedirectSpecialArticleRedirectParams", [ &$redirectParams ] );
107  $this->mAllowedRedirectParams = $redirectParams;
108  }
109 
113  public function getRedirectQuery( $subpage ) {
114  $query = parent::getRedirectQuery( $subpage );
115  $title = $this->getRedirect( $subpage );
116  // Avoid double redirect for action=edit&redlink=1 for existing pages
117  // (compare to the check in EditPage::edit)
118  if (
119  $query && isset( $query['action'] ) && isset( $query['redlink'] ) &&
120  ( $query['action'] === 'edit' || $query['action'] === 'submit' ) &&
121  (bool)$query['redlink'] &&
122  $title instanceof Title &&
123  $title->exists()
124  ) {
125  return false;
126  }
127  return $query;
128  }
129 
130 }
RedirectSpecialArticle\__construct
__construct( $name)
Definition: RedirectSpecialArticle.php:88
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:29
$title
$title
Definition: testCompression.php:34
RedirectSpecialArticle
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
Definition: RedirectSpecialArticle.php:87
Title
Represents a title within MediaWiki.
Definition: Title.php:42
RedirectSpecialArticle\getRedirectQuery
getRedirectQuery( $subpage)
Return part of the request string for a special redirect page This allows passing,...
Definition: RedirectSpecialArticle.php:113
RedirectSpecialPage\getRedirect
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200