MediaWiki master
RedirectSpecialArticle.php
Go to the documentation of this file.
1<?php
8
10
81
87 public function __construct( $name ) {
88 parent::__construct( $name );
89 $redirectParams = [
90 'action',
91 'redirect', 'rdfrom',
92 # Options for preloaded edits
93 'preload', 'preloadparams', 'editintro', 'preloadtitle', 'summary', 'nosummary',
94 # Options for overriding user settings
95 'preview', 'minor', 'watchthis',
96 # Options for history/diffs
97 'section', 'oldid', 'diff', 'dir',
98 'limit', 'offset', 'feed',
99 # Misc options
100 'redlink',
101 # Options for action=raw; missing ctype can break JS or CSS in some browsers
102 'ctype', 'maxage', 'smaxage',
103 ];
104
105 $this->getHookRunner()->onRedirectSpecialArticleRedirectParams( $redirectParams );
106 $this->mAllowedRedirectParams = $redirectParams;
107 }
108
112 public function getRedirectQuery( $subpage ) {
113 $query = parent::getRedirectQuery( $subpage );
114 $title = $this->getRedirect( $subpage );
115 // Avoid double redirect for action=edit&redlink=1 for existing pages
116 // (compare to the check in EditPage::edit)
117 if (
118 $query && isset( $query['action'] ) && isset( $query['redlink'] ) &&
119 ( $query['action'] === 'edit' || $query['action'] === 'submit' ) &&
120 (bool)$query['redlink'] &&
121 $title instanceof Title &&
122 $title->exists()
123 ) {
124 return false;
125 }
126 return $query;
127 }
128
129}
130
132class_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:69
exists( $flags=0)
Check if page exists.
Definition Title.php:3106