Merge "Cleanup some docs (includes/[s-z])"
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
1 <?php
2 /**
3 * @defgroup Watchlist Users watchlist handling
4 */
5
6 /**
7 * Implements Special:EditWatchlist
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 * @ingroup SpecialPage
26 * @ingroup Watchlist
27 */
28
29 /**
30 * Provides the UI through which users can perform editing
31 * operations on their watchlist
32 *
33 * @ingroup SpecialPage
34 * @ingroup Watchlist
35 * @author Rob Church <robchur@gmail.com>
36 */
37 class SpecialEditWatchlist extends UnlistedSpecialPage {
38 /**
39 * Editing modes. EDIT_CLEAR is no longer used; the "Clear" link scared people
40 * too much. Now it's passed on to the raw editor, from which it's very easy to clear.
41 */
42 const EDIT_CLEAR = 1;
43 const EDIT_RAW = 2;
44 const EDIT_NORMAL = 3;
45
46 protected $successMessage;
47
48 protected $toc;
49
50 private $badItems = array();
51
52 public function __construct() {
53 parent::__construct( 'EditWatchlist', 'editmywatchlist' );
54 }
55
56 /**
57 * Main execution point
58 *
59 * @param int $mode
60 */
61 public function execute( $mode ) {
62 $this->setHeaders();
63
64 # Anons don't get a watchlist
65 $this->requireLogin( 'watchlistanontext' );
66
67 $out = $this->getOutput();
68
69 $this->checkPermissions();
70 $this->checkReadOnly();
71
72 $this->outputHeader();
73
74 $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
75 ->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
76
77 # B/C: $mode used to be waaay down the parameter list, and the first parameter
78 # was $wgUser
79 if ( $mode instanceof User ) {
80 $args = func_get_args();
81 if ( count( $args ) >= 4 ) {
82 $mode = $args[3];
83 }
84 }
85 $mode = self::getMode( $this->getRequest(), $mode );
86
87 switch ( $mode ) {
88 case self::EDIT_RAW:
89 $out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
90 $form = $this->getRawForm();
91 if ( $form->show() ) {
92 $out->addHTML( $this->successMessage );
93 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
94 }
95 break;
96 case self::EDIT_CLEAR:
97 $out->setPageTitle( $this->msg( 'watchlistedit-clear-title' ) );
98 $form = $this->getClearForm();
99 if ( $form->show() ) {
100 $out->addHTML( $this->successMessage );
101 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
102 }
103 break;
104
105 case self::EDIT_NORMAL:
106 default:
107 $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
108 $form = $this->getNormalForm();
109 if ( $form->show() ) {
110 $out->addHTML( $this->successMessage );
111 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
112 } elseif ( $this->toc !== false ) {
113 $out->prependHTML( $this->toc );
114 $out->addModules( 'mediawiki.toc' );
115 }
116 break;
117 }
118 }
119
120 /**
121 * Return an array of subpages beginning with $search that this special page will accept.
122 *
123 * @param string $search Prefix to search for
124 * @param int $limit Maximum number of results to return
125 * @return string[] Matching subpages
126 */
127 public function prefixSearchSubpages( $search, $limit = 10 ) {
128 return self::prefixSearchArray(
129 $search,
130 $limit,
131 // SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added
132 // here and there - no 'edit' here, because that the default for this page
133 array(
134 'clear',
135 'raw',
136 )
137 );
138 }
139
140 /**
141 * Extract a list of titles from a blob of text, returning
142 * (prefixed) strings; unwatchable titles are ignored
143 *
144 * @param string $list
145 * @return array
146 */
147 private function extractTitles( $list ) {
148 $list = explode( "\n", trim( $list ) );
149 if ( !is_array( $list ) ) {
150 return array();
151 }
152
153 $titles = array();
154
155 foreach ( $list as $text ) {
156 $text = trim( $text );
157 if ( strlen( $text ) > 0 ) {
158 $title = Title::newFromText( $text );
159 if ( $title instanceof Title && $title->isWatchable() ) {
160 $titles[] = $title;
161 }
162 }
163 }
164
165 GenderCache::singleton()->doTitlesArray( $titles );
166
167 $list = array();
168 /** @var Title $title */
169 foreach ( $titles as $title ) {
170 $list[] = $title->getPrefixedText();
171 }
172
173 return array_unique( $list );
174 }
175
176 public function submitRaw( $data ) {
177 $wanted = $this->extractTitles( $data['Titles'] );
178 $current = $this->getWatchlist();
179
180 if ( count( $wanted ) > 0 ) {
181 $toWatch = array_diff( $wanted, $current );
182 $toUnwatch = array_diff( $current, $wanted );
183 $this->watchTitles( $toWatch );
184 $this->unwatchTitles( $toUnwatch );
185 $this->getUser()->invalidateCache();
186
187 if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
188 $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
189 } else {
190 return false;
191 }
192
193 if ( count( $toWatch ) > 0 ) {
194 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' )
195 ->numParams( count( $toWatch ) )->parse();
196 $this->showTitles( $toWatch, $this->successMessage );
197 }
198
199 if ( count( $toUnwatch ) > 0 ) {
200 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
201 ->numParams( count( $toUnwatch ) )->parse();
202 $this->showTitles( $toUnwatch, $this->successMessage );
203 }
204 } else {
205 $this->clearWatchlist();
206 $this->getUser()->invalidateCache();
207
208 if ( count( $current ) > 0 ) {
209 $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
210 } else {
211 return false;
212 }
213
214 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
215 ->numParams( count( $current ) )->parse();
216 $this->showTitles( $current, $this->successMessage );
217 }
218
219 return true;
220 }
221
222 public function submitClear( $data ) {
223 $current = $this->getWatchlist();
224 $this->clearWatchlist();
225 $this->getUser()->invalidateCache();
226 $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse();
227 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' )
228 ->numParams( count( $current ) )->parse();
229 $this->showTitles( $current, $this->successMessage );
230
231 return true;
232 }
233
234 /**
235 * Print out a list of linked titles
236 *
237 * $titles can be an array of strings or Title objects; the former
238 * is preferred, since Titles are very memory-heavy
239 *
240 * @param array $titles Array of strings, or Title objects
241 * @param string $output
242 */
243 private function showTitles( $titles, &$output ) {
244 $talk = $this->msg( 'talkpagelinktext' )->escaped();
245 // Do a batch existence check
246 $batch = new LinkBatch();
247 if ( count( $titles ) >= 100 ) {
248 $output = wfMessage( 'watchlistedit-too-many' )->parse();
249 return;
250 }
251 foreach ( $titles as $title ) {
252 if ( !$title instanceof Title ) {
253 $title = Title::newFromText( $title );
254 }
255
256 if ( $title instanceof Title ) {
257 $batch->addObj( $title );
258 $batch->addObj( $title->getTalkPage() );
259 }
260 }
261
262 $batch->execute();
263
264 // Print out the list
265 $output .= "<ul>\n";
266
267 foreach ( $titles as $title ) {
268 if ( !$title instanceof Title ) {
269 $title = Title::newFromText( $title );
270 }
271
272 if ( $title instanceof Title ) {
273 $output .= "<li>"
274 . Linker::link( $title )
275 . ' (' . Linker::link( $title->getTalkPage(), $talk )
276 . ")</li>\n";
277 }
278 }
279
280 $output .= "</ul>\n";
281 }
282
283 /**
284 * Prepare a list of titles on a user's watchlist (excluding talk pages)
285 * and return an array of (prefixed) strings
286 *
287 * @return array
288 */
289 private function getWatchlist() {
290 $list = array();
291 $dbr = wfGetDB( DB_MASTER );
292
293 $res = $dbr->select(
294 'watchlist',
295 array(
296 'wl_namespace', 'wl_title'
297 ), array(
298 'wl_user' => $this->getUser()->getId(),
299 ),
300 __METHOD__
301 );
302
303 if ( $res->numRows() > 0 ) {
304 $titles = array();
305 foreach ( $res as $row ) {
306 $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
307
308 if ( $this->checkTitle( $title, $row->wl_namespace, $row->wl_title )
309 && !$title->isTalkPage()
310 ) {
311 $titles[] = $title;
312 }
313 }
314 $res->free();
315
316 GenderCache::singleton()->doTitlesArray( $titles );
317
318 foreach ( $titles as $title ) {
319 $list[] = $title->getPrefixedText();
320 }
321 }
322
323 $this->cleanupWatchlist();
324
325 return $list;
326 }
327
328 /**
329 * Get a list of titles on a user's watchlist, excluding talk pages,
330 * and return as a two-dimensional array with namespace and title.
331 *
332 * @return array
333 */
334 private function getWatchlistInfo() {
335 $titles = array();
336 $dbr = wfGetDB( DB_MASTER );
337
338 $res = $dbr->select(
339 array( 'watchlist' ),
340 array( 'wl_namespace', 'wl_title' ),
341 array( 'wl_user' => $this->getUser()->getId() ),
342 __METHOD__,
343 array( 'ORDER BY' => array( 'wl_namespace', 'wl_title' ) )
344 );
345
346 $lb = new LinkBatch();
347
348 foreach ( $res as $row ) {
349 $lb->add( $row->wl_namespace, $row->wl_title );
350 if ( !MWNamespace::isTalk( $row->wl_namespace ) ) {
351 $titles[$row->wl_namespace][$row->wl_title] = 1;
352 }
353 }
354
355 $lb->execute();
356
357 return $titles;
358 }
359
360 /**
361 * Validates watchlist entry
362 *
363 * @param Title $title
364 * @param int $namespace
365 * @param string $dbKey
366 * @return bool Whether this item is valid
367 */
368 private function checkTitle( $title, $namespace, $dbKey ) {
369 if ( $title
370 && ( $title->isExternal()
371 || $title->getNamespace() < 0
372 )
373 ) {
374 $title = false; // unrecoverable
375 }
376
377 if ( !$title
378 || $title->getNamespace() != $namespace
379 || $title->getDBkey() != $dbKey
380 ) {
381 $this->badItems[] = array( $title, $namespace, $dbKey );
382 }
383
384 return (bool)$title;
385 }
386
387 /**
388 * Attempts to clean up broken items
389 */
390 private function cleanupWatchlist() {
391 if ( !count( $this->badItems ) ) {
392 return; //nothing to do
393 }
394
395 $dbw = wfGetDB( DB_MASTER );
396 $user = $this->getUser();
397
398 foreach ( $this->badItems as $row ) {
399 list( $title, $namespace, $dbKey ) = $row;
400 $action = $title ? 'cleaning up' : 'deleting';
401 wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, $action.\n" );
402
403 $dbw->delete( 'watchlist',
404 array(
405 'wl_user' => $user->getId(),
406 'wl_namespace' => $namespace,
407 'wl_title' => $dbKey,
408 ),
409 __METHOD__
410 );
411
412 // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
413 if ( $title ) {
414 $user->addWatch( $title );
415 }
416 }
417 }
418
419 /**
420 * Remove all titles from a user's watchlist
421 */
422 private function clearWatchlist() {
423 $dbw = wfGetDB( DB_MASTER );
424 $dbw->delete(
425 'watchlist',
426 array( 'wl_user' => $this->getUser()->getId() ),
427 __METHOD__
428 );
429 }
430
431 /**
432 * Add a list of titles to a user's watchlist
433 *
434 * $titles can be an array of strings or Title objects; the former
435 * is preferred, since Titles are very memory-heavy
436 *
437 * @param array $titles Array of strings, or Title objects
438 */
439 private function watchTitles( $titles ) {
440 $dbw = wfGetDB( DB_MASTER );
441 $rows = array();
442
443 foreach ( $titles as $title ) {
444 if ( !$title instanceof Title ) {
445 $title = Title::newFromText( $title );
446 }
447
448 if ( $title instanceof Title ) {
449 $rows[] = array(
450 'wl_user' => $this->getUser()->getId(),
451 'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ),
452 'wl_title' => $title->getDBkey(),
453 'wl_notificationtimestamp' => null,
454 );
455 $rows[] = array(
456 'wl_user' => $this->getUser()->getId(),
457 'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ),
458 'wl_title' => $title->getDBkey(),
459 'wl_notificationtimestamp' => null,
460 );
461 }
462 }
463
464 $dbw->insert( 'watchlist', $rows, __METHOD__, 'IGNORE' );
465 }
466
467 /**
468 * Remove a list of titles from a user's watchlist
469 *
470 * $titles can be an array of strings or Title objects; the former
471 * is preferred, since Titles are very memory-heavy
472 *
473 * @param array $titles Array of strings, or Title objects
474 */
475 private function unwatchTitles( $titles ) {
476 $dbw = wfGetDB( DB_MASTER );
477
478 foreach ( $titles as $title ) {
479 if ( !$title instanceof Title ) {
480 $title = Title::newFromText( $title );
481 }
482
483 if ( $title instanceof Title ) {
484 $dbw->delete(
485 'watchlist',
486 array(
487 'wl_user' => $this->getUser()->getId(),
488 'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ),
489 'wl_title' => $title->getDBkey(),
490 ),
491 __METHOD__
492 );
493
494 $dbw->delete(
495 'watchlist',
496 array(
497 'wl_user' => $this->getUser()->getId(),
498 'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ),
499 'wl_title' => $title->getDBkey(),
500 ),
501 __METHOD__
502 );
503
504 $page = WikiPage::factory( $title );
505 wfRunHooks( 'UnwatchArticleComplete', array( $this->getUser(), &$page ) );
506 }
507 }
508 }
509
510 public function submitNormal( $data ) {
511 $removed = array();
512
513 foreach ( $data as $titles ) {
514 $this->unwatchTitles( $titles );
515 $removed = array_merge( $removed, $titles );
516 }
517
518 if ( count( $removed ) > 0 ) {
519 $this->successMessage = $this->msg( 'watchlistedit-normal-done'
520 )->numParams( count( $removed ) )->parse();
521 $this->showTitles( $removed, $this->successMessage );
522
523 return true;
524 } else {
525 return false;
526 }
527 }
528
529 /**
530 * Get the standard watchlist editing form
531 *
532 * @return HTMLForm
533 */
534 protected function getNormalForm() {
535 global $wgContLang;
536
537 $fields = array();
538 $count = 0;
539
540 foreach ( $this->getWatchlistInfo() as $namespace => $pages ) {
541 if ( $namespace >= 0 ) {
542 $fields['TitlesNs' . $namespace] = array(
543 'class' => 'EditWatchlistCheckboxSeriesField',
544 'options' => array(),
545 'section' => "ns$namespace",
546 );
547 }
548
549 foreach ( array_keys( $pages ) as $dbkey ) {
550 $title = Title::makeTitleSafe( $namespace, $dbkey );
551
552 if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
553 $text = $this->buildRemoveLine( $title );
554 $fields['TitlesNs' . $namespace]['options'][$text] = $title->getPrefixedText();
555 $count++;
556 }
557 }
558 }
559 $this->cleanupWatchlist();
560
561 if ( count( $fields ) > 1 && $count > 30 ) {
562 $this->toc = Linker::tocIndent();
563 $tocLength = 0;
564
565 foreach ( $fields as $data ) {
566 # strip out the 'ns' prefix from the section name:
567 $ns = substr( $data['section'], 2 );
568
569 $nsText = ( $ns == NS_MAIN )
570 ? $this->msg( 'blanknamespace' )->escaped()
571 : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
572 $this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
573 $this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
574 }
575
576 $this->toc = Linker::tocList( $this->toc );
577 } else {
578 $this->toc = false;
579 }
580
581 $context = new DerivativeContext( $this->getContext() );
582 $context->setTitle( $this->getPageTitle() ); // Remove subpage
583 $form = new EditWatchlistNormalHTMLForm( $fields, $context );
584 $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
585 # Used message keys:
586 # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
587 $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
588 $form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
589 $form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
590 $form->setSubmitCallback( array( $this, 'submitNormal' ) );
591
592 return $form;
593 }
594
595 /**
596 * Build the label for a checkbox, with a link to the title, and various additional bits
597 *
598 * @param Title $title
599 * @return string
600 */
601 private function buildRemoveLine( $title ) {
602 $link = Linker::link( $title );
603
604 if ( $title->isRedirect() ) {
605 // Linker already makes class mw-redirect, so this is redundant
606 $link = '<span class="watchlistredir">' . $link . '</span>';
607 }
608
609 $tools[] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
610
611 if ( $title->exists() ) {
612 $tools[] = Linker::linkKnown(
613 $title,
614 $this->msg( 'history_short' )->escaped(),
615 array(),
616 array( 'action' => 'history' )
617 );
618 }
619
620 if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
621 $tools[] = Linker::linkKnown(
622 SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
623 $this->msg( 'contributions' )->escaped()
624 );
625 }
626
627 wfRunHooks(
628 'WatchlistEditorBuildRemoveLine',
629 array( &$tools, $title, $title->isRedirect(), $this->getSkin() )
630 );
631
632 return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
633 }
634
635 /**
636 * Get a form for editing the watchlist in "raw" mode
637 *
638 * @return HTMLForm
639 */
640 protected function getRawForm() {
641 $titles = implode( $this->getWatchlist(), "\n" );
642 $fields = array(
643 'Titles' => array(
644 'type' => 'textarea',
645 'label-message' => 'watchlistedit-raw-titles',
646 'default' => $titles,
647 ),
648 );
649 $context = new DerivativeContext( $this->getContext() );
650 $context->setTitle( $this->getPageTitle( 'raw' ) ); // Reset subpage
651 $form = new HTMLForm( $fields, $context );
652 $form->setSubmitTextMsg( 'watchlistedit-raw-submit' );
653 # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
654 $form->setSubmitTooltip( 'watchlistedit-raw-submit' );
655 $form->setWrapperLegendMsg( 'watchlistedit-raw-legend' );
656 $form->addHeaderText( $this->msg( 'watchlistedit-raw-explain' )->parse() );
657 $form->setSubmitCallback( array( $this, 'submitRaw' ) );
658
659 return $form;
660 }
661
662 /**
663 * Get a form for clearing the watchlist
664 *
665 * @return HTMLForm
666 */
667 protected function getClearForm() {
668 $context = new DerivativeContext( $this->getContext() );
669 $context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage
670 $form = new HTMLForm( array(), $context );
671 $form->setSubmitTextMsg( 'watchlistedit-clear-submit' );
672 # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
673 $form->setSubmitTooltip( 'watchlistedit-clear-submit' );
674 $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
675 $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
676 $form->setSubmitCallback( array( $this, 'submitClear' ) );
677
678 return $form;
679 }
680
681 /**
682 * Determine whether we are editing the watchlist, and if so, what
683 * kind of editing operation
684 *
685 * @param WebRequest $request
686 * @param string $par
687 * @return int
688 */
689 public static function getMode( $request, $par ) {
690 $mode = strtolower( $request->getVal( 'action', $par ) );
691
692 switch ( $mode ) {
693 case 'clear':
694 case self::EDIT_CLEAR:
695 return self::EDIT_CLEAR;
696 case 'raw':
697 case self::EDIT_RAW:
698 return self::EDIT_RAW;
699 case 'edit':
700 case self::EDIT_NORMAL:
701 return self::EDIT_NORMAL;
702 default:
703 return false;
704 }
705 }
706
707 /**
708 * Build a set of links for convenient navigation
709 * between watchlist viewing and editing modes
710 *
711 * @param null $unused
712 * @return string
713 */
714 public static function buildTools( $unused ) {
715 global $wgLang;
716
717 $tools = array();
718 $modes = array(
719 'view' => array( 'Watchlist', false ),
720 'edit' => array( 'EditWatchlist', false ),
721 'raw' => array( 'EditWatchlist', 'raw' ),
722 'clear' => array( 'EditWatchlist', 'clear' ),
723 );
724
725 foreach ( $modes as $mode => $arr ) {
726 // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
727 $tools[] = Linker::linkKnown(
728 SpecialPage::getTitleFor( $arr[0], $arr[1] ),
729 wfMessage( "watchlisttools-{$mode}" )->escaped()
730 );
731 }
732
733 return Html::rawElement(
734 'span',
735 array( 'class' => 'mw-watchlist-toollinks' ),
736 wfMessage( 'parentheses', $wgLang->pipeList( $tools ) )->text()
737 );
738 }
739 }
740
741 /**
742 * Extend HTMLForm purely so we can have a more sane way of getting the section headers
743 */
744 class EditWatchlistNormalHTMLForm extends HTMLForm {
745 public function getLegend( $namespace ) {
746 $namespace = substr( $namespace, 2 );
747
748 return $namespace == NS_MAIN
749 ? $this->msg( 'blanknamespace' )->escaped()
750 : htmlspecialchars( $this->getContext()->getLanguage()->getFormattedNsText( $namespace ) );
751 }
752
753 public function getBody() {
754 return $this->displaySection( $this->mFieldTree, '', 'editwatchlist-' );
755 }
756 }
757
758 class EditWatchlistCheckboxSeriesField extends HTMLMultiSelectField {
759 /**
760 * HTMLMultiSelectField throws validation errors if we get input data
761 * that doesn't match the data set in the form setup. This causes
762 * problems if something gets removed from the watchlist while the
763 * form is open (bug 32126), but we know that invalid items will
764 * be harmless so we can override it here.
765 *
766 * @param string $value The value the field was submitted with
767 * @param array $alldata The data collected from the form
768 * @return bool|string Bool true on success, or String error to display.
769 */
770 function validate( $value, $alldata ) {
771 // Need to call into grandparent to be a good citizen. :)
772 return HTMLFormField::validate( $value, $alldata );
773 }
774 }