Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -196,6 +196,33 @@ |
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
| 200 | + * Return part of the request string for a special redirect page |
| 201 | + * This allows passing, e.g. action=history to Special:Mypage, etc. |
| 202 | + * |
| 203 | + * @param $name Name of the redirect page |
| 204 | + * @return string |
| 205 | + */ |
| 206 | + function getRedirectParams( $name ) { |
| 207 | + global $wgRequest; |
| 208 | + |
| 209 | + $args = array(); |
| 210 | + switch( $name ) { |
| 211 | + case 'Mypage': |
| 212 | + case 'Mytalk': |
| 213 | + case 'Randompage': |
| 214 | + $args = array( 'action' ); |
| 215 | + } |
| 216 | + |
| 217 | + $params = array(); |
| 218 | + foreach( $args as $arg ) { |
| 219 | + if( $val = $wgRequest->getVal( $arg, false ) ) |
| 220 | + $params[] = $arg . '=' . $val; |
| 221 | + } |
| 222 | + |
| 223 | + return count( $params ) ? implode( '&', $params ) : false; |
| 224 | + } |
| 225 | + |
| 226 | + /** |
200 | 227 | * Return categorised listable special pages |
201 | 228 | * Returns a 2d array where the first index is the restriction name |
202 | 229 | * @static |
— | — | @@ -248,10 +275,15 @@ |
249 | 276 | } else { |
250 | 277 | $redir = SpecialPage::getRedirect( $name ); |
251 | 278 | if ( isset( $redir ) ) { |
252 | | - if ( isset( $par ) ) |
253 | | - $wgOut->redirect( $redir->getFullURL() . '/' . $par ); |
254 | | - else |
255 | | - $wgOut->redirect( $redir->getFullURL() ); |
| 279 | + $params = SpecialPage::getRedirectParams( $name ); |
| 280 | + if( $params ) { |
| 281 | + $url = $redir->getFullUrl( $params ); |
| 282 | + } elseif( $par ) { |
| 283 | + $url = $redir->getFullUrl() . '/' . $par; |
| 284 | + } else { |
| 285 | + $url = $redir->getFullUrl(); |
| 286 | + } |
| 287 | + $wgOut->redirect( $url ); |
256 | 288 | $retVal = $redir; |
257 | 289 | } else { |
258 | 290 | $wgOut->setArticleRelated( false ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -152,6 +152,7 @@ |
153 | 153 | * (bug 5757) Fix premature cutoff in LanguageConverter with extra end markers |
154 | 154 | * (bug 5516) Show appropriate "return to" link on blocked page |
155 | 155 | * (bug 5377) Do not auto-login when creating an account as another user |
| 156 | +* (bug 5284) Special redirect pages should remember parameters |
156 | 157 | |
157 | 158 | == Compatibility == |
158 | 159 | |