r99914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99913‎ | r99914 | r99915 >
Date:21:06, 15 October 2011
Author:maxsem
Status:resolved (Comments)
Tags:
Comment:
(bug 31674) Can't edit watchlist if it contains special pages
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.18 (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/api/ApiWatch.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialEditWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.18
@@ -469,6 +469,7 @@
470470 really small, and somewhat inconsistent with each other.
471471 * (bug 30466) Entries in iwlinks table are now cleared when moving a page over
472472 redirect
 473+* (bug 31674) Can't edit watchlist if it contains special pages
473474
474475 === API changes in 1.18 ===
475476 * BREAKING CHANGE: action=watch now requires POST and token.
@@ -697,17 +698,17 @@
698699 MediaWiki.org, and is covered under the GNU Free Documentation License (except
699700 for pages that explicitly state that their contents are in the public domain):
700701
701 - http://www.mediawiki.org/wiki/Documentation
 702+ http://www.mediawiki.org/wiki/Documentation
702703
703704 == Mailing list ==
704705
705706 A mailing list is available for MediaWiki user support and discussion:
706707
707 - http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
 708+ http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
708709
709710 A low-traffic announcements-only list is also available:
710711
711 - http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce
 712+ http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce
712713
713714 It's highly recommended that you sign up for one of these lists if you're
714715 going to run a public MediaWiki, so you can be notified of security fixes.
Index: trunk/phase3/includes/User.php
@@ -2606,6 +2606,14 @@
26072607 }
26082608
26092609 /**
 2610+ * Cleans up watchlist by removing invalid entries from it
 2611+ */
 2612+ public function cleanupWatchlist() {
 2613+ $dbw = wfGetDB( DB_MASTER );
 2614+ $dbw->delete( 'watchlist', array( 'wl_namespace < 0', 'wl_user' => $this->getId() ), __METHOD__ );
 2615+ }
 2616+
 2617+ /**
26102618 * Clear the user's notification timestamp for the given title.
26112619 * If e-notif e-mails are on, they will receive notification mails on
26122620 * the next change of the page if it's watched etc.
Index: trunk/phase3/includes/api/ApiWatch.php
@@ -49,7 +49,7 @@
5050 $params = $this->extractRequestParams();
5151 $title = Title::newFromText( $params['title'] );
5252
53 - if ( !$title ) {
 53+ if ( !$title || $titile->getNamespace() < 0 ) {
5454 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
5555 }
5656
Index: trunk/phase3/includes/specials/SpecialEditWatchlist.php
@@ -376,8 +376,13 @@
377377
378378 $fields = array();
379379
 380+ $haveInvalidNamespaces = false;
380381 foreach( $this->getWatchlistInfo() as $namespace => $pages ){
381 -
 382+ if ( $namespace < 0 ) {
 383+ $haveInvalidNamespaces = true;
 384+ continue;
 385+ }
 386+
382387 $namespace == NS_MAIN
383388 ? wfMsgHtml( 'blanknamespace' )
384389 : htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) );
@@ -394,6 +399,10 @@
395400 $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText();
396401 }
397402 }
 403+ if ( $haveInvalidNamespaces ) {
 404+ wfDebug( "User {$this->getContext()->getUser()->getId()} has invalid watchlist entries, clening up...\n" );
 405+ $this->getContext()->getUser()->cleanupWatchlist();
 406+ }
398407
399408 $form = new EditWatchlistNormalHTMLForm( $fields, $this->getContext() );
400409 $form->setTitle( $this->getTitle() );

Sign-offs

UserFlagDate
Reedyinspected01:18, 26 October 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r99918Fix typo in r99914maxsem22:08, 15 October 2011
r99952Fixed bug in r99914, also reverted accidental tabs->spaces conversionmaxsem15:08, 16 October 2011
r100840REL1_18: MFT r98426, r99371, r99632, r99897, r99910, r99914, r999952reedy18:47, 26 October 2011
r1011261.18wmf1: MFT r98669, r99164, r99321, r99332, r99632, r99897, r99914, r99952,...catrope12:09, 28 October 2011

Comments

#Comment by Bryan (talk | contribs)   21:43, 15 October 2011

"clening up"

#Comment by MaxSem (talk | contribs)   22:09, 15 October 2011

Done, thanks.

#Comment by Nikerabbit (talk | contribs)   10:31, 16 October 2011
+		if ( !$title || $titile->getNamespace() < 0 ) {
#Comment by MaxSem (talk | contribs)   15:10, 16 October 2011

Thanks, fixed in r99952.

#Comment by Duplicatebug (talk | contribs)   14:50, 16 October 2011

Why not fixing the api, which adds the title to the watchlist?

#Comment by MaxSem (talk | contribs)   15:10, 16 October 2011

What do you mean? This revision fixes the API bug, too - see changes to ApiWatch.php ;)

#Comment by Duplicatebug (talk | contribs)   16:58, 16 October 2011

Ah, sorry, I have not seen that, but looks better after r99952.

Status & tagging log