Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -123,6 +123,7 @@ |
124 | 124 | * (bug 27775) Namespace has it's own XML tag in the XML dump file. |
125 | 125 | * (bug 30513) Redirect tag is now resolved in XML dump file. |
126 | 126 | * sha1 xml tag added to XML dump file. |
| 127 | +* (bug 33646) Badtitle error page now emits a 400 HTTP status. |
127 | 128 | |
128 | 129 | === Bug fixes in 1.19 === |
129 | 130 | * $wgUploadNavigationUrl should be used for file redlinks if. |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -167,7 +167,7 @@ |
168 | 168 | { |
169 | 169 | $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) ); |
170 | 170 | wfProfileOut( __METHOD__ ); |
171 | | - throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
| 171 | + throw new BadTitleError(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Check user's permissions to read this page. |
— | — | @@ -214,7 +214,7 @@ |
215 | 215 | } else { |
216 | 216 | $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) ); |
217 | 217 | wfProfileOut( __METHOD__ ); |
218 | | - throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
| 218 | + throw new BadTitleError(); |
219 | 219 | } |
220 | 220 | // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant |
221 | 221 | } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted() |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -266,12 +266,43 @@ |
267 | 267 | function report() { |
268 | 268 | global $wgOut; |
269 | 269 | |
| 270 | + |
270 | 271 | $wgOut->showErrorPage( $this->title, $this->msg, $this->params ); |
271 | 272 | $wgOut->output(); |
272 | 273 | } |
273 | 274 | } |
274 | 275 | |
275 | 276 | /** |
| 277 | + * Show an error page on a badtitle. |
| 278 | + * Similar to ErrorPage, but emit a 400 HTTP error code to let mobile |
| 279 | + * browser it is not really a valid content. |
| 280 | + */ |
| 281 | +class BadTitleError extends ErrorPageError { |
| 282 | + |
| 283 | + /** |
| 284 | + * @param $msg string A message key (default: 'badtitletext') |
| 285 | + * @param $params Array parameter to wfMsg() |
| 286 | + */ |
| 287 | + function __construct( $msg = 'badtitletext', $params = null ) { |
| 288 | + parent::__construct( 'badtitle', $msg, $params ); |
| 289 | + } |
| 290 | + |
| 291 | + /** |
| 292 | + * Just like ErrorPageError::report() but additionally set |
| 293 | + * a 400 HTTP status code (bug 33646). |
| 294 | + */ |
| 295 | + function report() { |
| 296 | + global $wgOut; |
| 297 | + |
| 298 | + // bug 33646: a badtitle error page need to return an error code |
| 299 | + // to let mobile browser now that it is not a normal page. |
| 300 | + $wgOut->setStatusCode( 400 ); |
| 301 | + parent::report(); |
| 302 | + } |
| 303 | + |
| 304 | +} |
| 305 | + |
| 306 | +/** |
276 | 307 | * Show an error when a user tries to do something they do not have the necessary |
277 | 308 | * permissions for. |
278 | 309 | * @ingroup Exception |