r51110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51109‎ | r51110 | r51111 >
Date:12:32, 28 May 2009
Author:werdna
Status:deferred
Tags:
Comment:
Fix bug 18947 LiquidThreads thread renaming silently fails if user is not allowed to move pages.
It now fails gracefully, but really I'd like to be able to disable that subject bar altogether instead of letting users change it only to be told off.
Modified paths:
  • /trunk/extensions/LiquidThreads/Lqt.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtView.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -665,6 +665,11 @@
666666 $subject: subject of the mail
667667 $text: text of the mail
668668
 669+'EmailUserPermissionsErrors': to retrieve permissions errors for emailing a user.
 670+$user: The user who is trying to email another user.
 671+$editToken: The user's edit token.
 672+&$hookErr: Out-param for the error. Passed as the parameters to OutputPage::showErrorPage.
 673+
669674 'FetchChangesList': When fetching the ChangesList derivative for a particular user
670675 &$user: User the list is being fetched for
671676 &$skin: Skin object to be used with the list
Index: trunk/extensions/LiquidThreads/classes/LqtView.php
@@ -259,8 +259,12 @@
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+ // Stuff that might break the save
 265+ $valid_subject = true;
 266+ $failed_rename = false;
263267
264 - $valid_summary = true;
 268+ $subject = $this->request->getVal( 'lqt_subject_field', '' );
265269
266270 if ( $edit_type == 'summarize' && $edit_applies_to->summary() ) {
267271 $article = $edit_applies_to->summary();
@@ -268,11 +272,9 @@
269273 $t = $this->newSummaryTitle( $edit_applies_to );
270274 $article = new Article( $t );
271275 } elseif ( $thread == null ) {
272 - $subject = $this->request->getVal( 'lqt_subject_field', '' );
273 -
274276 if ( is_null( Title::makeTitleSafe( NS_LQT_THREAD, $subject ) ) ) {
275277 // Dodgy title
276 - $valid_summary = false;
 278+ $valid_subject = false;
277279 $t = $this->scratchTitle();
278280 } else {
279281 if ( $edit_type == 'new' ) {
@@ -288,13 +290,27 @@
289291
290292 $e = new EditPage( $article );
291293
292 - if (!$valid_summary && $subject) {
 294+
 295+ // Find errors.
 296+ if (!$valid_subject && $subject) {
293297 $e->editFormPageTop .=
294298 Xml::tags( 'div', array( 'class' => 'error' ),
295299 wfMsgExt( 'lqt_invalid_subject', 'parse' ) );
296300 }
297301
298 - if (!$valid_summary) {
 302+ if ( $subject != $thread->subjectWithoutIncrement() &&
 303+ !$this->user->isAllowed( 'move' ) ) {
 304+ $e->editFormPageTop .=
 305+ Xml::tags( 'div', array( 'class' => 'error' ),
 306+ wfMsgExt( 'lqt_subject_change_forbidden', 'parse' ) );
 307+ $failed_rename = true;
 308+
 309+ // Reset the subject
 310+ global $wgRequest;
 311+ $wgRequest->setVal( 'lqt_subject_field', $thread->subjectWithoutIncrement() );
 312+ }
 313+
 314+ if ( !$valid_subject || $failed_rename ) {
299315 // Dirty hack to prevent saving from going ahead
300316 global $wgRequest;
301317 $wgRequest->setVal( 'wpPreview', true );
Index: trunk/extensions/LiquidThreads/Lqt.i18n.php
@@ -29,6 +29,7 @@
3030 * Contain invalid characters, such as []{}<>,
3131 * Be too long, or
3232 * Conflict with interwiki prefixes or namespace names.',
 33+ 'lqt_subject_change_forbidden' => 'You are not allowed to change the subject for this thread because you cannot move pages.',
3334 'lqt_in_response_to' => 'In reply to $1 by $2, above:',
3435 'lqt_edited_notice' => 'Edited',
3536 'lqt_reply' => 'Reply',

Follow-up revisions

RevisionCommit summaryAuthorDate
r51111Fix bug 18947 "LiquidThreads thread renaming silently fails if user is not al...werdna12:39, 28 May 2009

Status & tagging log