r23896 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23895‎ | r23896 | r23897 >
Date:11:08, 9 July 2007
Author:robchurch
Status:old
Tags:
Comment:
Let's be a little bit clever here; faster code path for the case where users just blank the text box and submit to clear...skip all that pointless diffing and so forth
Modified paths:
  • /trunk/phase3/includes/WatchlistEditor.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WatchlistEditor.php
@@ -44,23 +44,30 @@
4545 case self::EDIT_RAW:
4646 $output->setPageTitle( wfMsg( 'watchlistedit-raw-title' ) );
4747 if( $request->wasPosted() && $this->checkToken( $request, $wgUser ) ) {
 48+ $wanted = $this->extractTitles( $request->getText( 'titles' ) );
4849 $current = $this->getWatchlist( $user );
49 - $wanted = $this->extractTitles( $request->getText( 'titles' ) );
50 - $toWatch = array_diff( $wanted, $current );
51 - $toUnwatch = array_diff( $current, $wanted );
52 - $this->watchTitles( $toWatch, $user );
53 - $this->unwatchTitles( $toUnwatch, $user );
54 - $user->invalidateCache();
55 - if( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 )
56 - $output->addHtml( wfMsgExt( 'watchlistedit-raw-done', 'parse' ) );
57 - if( ( $count = count( $toWatch ) ) > 0 ) {
58 - $output->addHtml( wfMsgExt( 'watchlistedit-raw-added', 'parse', $count ) );
59 - $this->showTitles( $toWatch, $output, $wgUser->getSkin() );
 50+ if( count( $wanted ) > 0 ) {
 51+ $toWatch = array_diff( $wanted, $current );
 52+ $toUnwatch = array_diff( $current, $wanted );
 53+ $this->watchTitles( $toWatch, $user );
 54+ $this->unwatchTitles( $toUnwatch, $user );
 55+ $user->invalidateCache();
 56+ if( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 )
 57+ $output->addHtml( wfMsgExt( 'watchlistedit-raw-done', 'parse' ) );
 58+ if( ( $count = count( $toWatch ) ) > 0 ) {
 59+ $output->addHtml( wfMsgExt( 'watchlistedit-raw-added', 'parse', $count ) );
 60+ $this->showTitles( $toWatch, $output, $wgUser->getSkin() );
 61+ }
 62+ if( ( $count = count( $toUnwatch ) ) > 0 ) {
 63+ $output->addHtml( wfMsgExt( 'watchlistedit-raw-removed', 'parse', $count ) );
 64+ $this->showTitles( $toUnwatch, $output, $wgUser->getSkin() );
 65+ }
 66+ } else {
 67+ $this->clearWatchlist( $user );
 68+ $user->invalidateCache();
 69+ $output->addHtml( wfMsgExt( 'watchlistedit-raw-removed', 'parse', count( $current ) ) );
 70+ $this->showTitles( $current, $output, $wgUser->getSkin() );
6071 }
61 - if( ( $count = count( $toUnwatch ) ) > 0 ) {
62 - $output->addHtml( wfMsgExt( 'watchlistedit-raw-removed', 'parse', $count ) );
63 - $this->showTitles( $toUnwatch, $output, $wgUser->getSkin() );
64 - }
6572 }
6673 $this->showRawForm( $output, $user );
6774 break;

Follow-up revisions

RevisionCommit summaryAuthorDate
r23912Merged revisions 23662-23909 via svnmerge from...david18:11, 9 July 2007

Status & tagging log