MediaWiki master
RedirectSpecialArticle.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\SpecialPage;
25
27
94
100 public function __construct( $name ) {
101 parent::__construct( $name );
102 $redirectParams = [
103 'action',
104 'redirect', 'rdfrom',
105 # Options for preloaded edits
106 'preload', 'preloadparams', 'editintro', 'preloadtitle', 'summary', 'nosummary',
107 # Options for overriding user settings
108 'preview', 'minor', 'watchthis',
109 # Options for history/diffs
110 'section', 'oldid', 'diff', 'dir',
111 'limit', 'offset', 'feed',
112 # Misc options
113 'redlink',
114 # Options for action=raw; missing ctype can break JS or CSS in some browsers
115 'ctype', 'maxage', 'smaxage',
116 ];
117
118 $this->getHookRunner()->onRedirectSpecialArticleRedirectParams( $redirectParams );
119 $this->mAllowedRedirectParams = $redirectParams;
120 }
121
125 public function getRedirectQuery( $subpage ) {
126 $query = parent::getRedirectQuery( $subpage );
127 $title = $this->getRedirect( $subpage );
128 // Avoid double redirect for action=edit&redlink=1 for existing pages
129 // (compare to the check in EditPage::edit)
130 if (
131 $query && isset( $query['action'] ) && isset( $query['redlink'] ) &&
132 ( $query['action'] === 'edit' || $query['action'] === 'submit' ) &&
133 (bool)$query['redlink'] &&
134 $title instanceof Title &&
135 $title->exists()
136 ) {
137 return false;
138 }
139 return $query;
140 }
141
142}
143
148class_alias( RedirectSpecialArticle::class, 'RedirectSpecialArticle' );
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.
Represents a title within MediaWiki.
Definition Title.php:78
exists( $flags=0)
Check if page exists.
Definition Title.php:3181