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