r51109 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51108‎ | r51109 | r51110 >
Date:12:17, 28 May 2009
Author:werdna
Status:deferred
Tags:
Comment:
(bug 18953) Fix fatal error when new LiquidThreads thread subject is invalid as a page title
Modified paths:
  • /trunk/extensions/LiquidThreads/Lqt.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/LqtView.php
@@ -259,17 +259,27 @@
260260 can temporarily use a random scratch title. It's fine if the title changes
261261 throughout the edit cycle, since the article doesn't exist yet anyways.
262262 */
 263+
 264+ $valid_summary = true;
 265+
263266 if ( $edit_type == 'summarize' && $edit_applies_to->summary() ) {
264267 $article = $edit_applies_to->summary();
265 - } else if ( $edit_type == 'summarize' ) {
 268+ } elseif ( $edit_type == 'summarize' ) {
266269 $t = $this->newSummaryTitle( $edit_applies_to );
267270 $article = new Article( $t );
268 - } else if ( $thread == null ) {
 271+ } elseif ( $thread == null ) {
269272 $subject = $this->request->getVal( 'lqt_subject_field', '' );
270 - if ( $edit_type == 'new' ) {
271 - $t = $this->newScratchTitle( $subject );
272 - } else if ( $edit_type == 'reply' ) {
273 - $t = $this->newReplyTitle( $subject, $edit_applies_to );
 273+
 274+ if ( is_null( Title::makeTitleSafe( NS_LQT_THREAD, $subject ) ) ) {
 275+ // Dodgy title
 276+ $valid_summary = false;
 277+ $t = $this->scratchTitle();
 278+ } else {
 279+ if ( $edit_type == 'new' ) {
 280+ $t = $this->newScratchTitle( $subject );
 281+ } elseif ( $edit_type == 'reply' ) {
 282+ $t = $this->newReplyTitle( $subject, $edit_applies_to );
 283+ }
274284 }
275285 $article = new Article( $t );
276286 } else {
@@ -277,6 +287,18 @@
278288 }
279289
280290 $e = new EditPage( $article );
 291+
 292+ if (!$valid_summary && $subject) {
 293+ $e->editFormPageTop .=
 294+ Xml::tags( 'div', array( 'class' => 'error' ),
 295+ wfMsgExt( 'lqt_invalid_subject', 'parse' ) );
 296+ }
 297+
 298+ if (!$valid_summary) {
 299+ // Dirty hack to prevent saving from going ahead
 300+ global $wgRequest;
 301+ $wgRequest->setVal( 'wpPreview', true );
 302+ }
281303
282304 $e->suppressIntro = true;
283305 $e->editFormTextBeforeContent .=
Index: trunk/extensions/LiquidThreads/Lqt.i18n.php
@@ -25,6 +25,10 @@
2626 'lqt_contents_title' => 'Contents:',
2727 'lqt_add_header' => 'Add header',
2828 'lqt_new_thread' => 'Start a new discussion',
 29+ 'lqt_invalid_subject' => 'The subject you entered is invalid. It may:
 30+* Contain invalid characters, such as []{}<>,
 31+* Be too long, or
 32+* Conflict with interwiki prefixes or namespace names.',
2933 'lqt_in_response_to' => 'In reply to $1 by $2, above:',
3034 'lqt_edited_notice' => 'Edited',
3135 'lqt_reply' => 'Reply',

Status & tagging log