MessageCache invalidation improvements
[mediawiki.git] / includes / specials / SpecialEditWatchlist.php
blob0defcd1bafb41605f6be8f8888f728271e2c19ed
1 <?php
2 /**
3 * @defgroup Watchlist Users watchlist handling
4 */
6 /**
7 * Implements Special:EditWatchlist
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.
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.
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
24 * @file
25 * @ingroup SpecialPage
26 * @ingroup Watchlist
29 use MediaWiki\Linker\LinkRenderer;
30 use MediaWiki\Linker\LinkTarget;
31 use MediaWiki\MediaWikiServices;
33 /**
34 * Provides the UI through which users can perform editing
35 * operations on their watchlist
37 * @ingroup SpecialPage
38 * @ingroup Watchlist
39 * @author Rob Church <robchur@gmail.com>
41 class SpecialEditWatchlist extends UnlistedSpecialPage {
42 /**
43 * Editing modes. EDIT_CLEAR is no longer used; the "Clear" link scared people
44 * too much. Now it's passed on to the raw editor, from which it's very easy to clear.
46 const EDIT_CLEAR = 1;
47 const EDIT_RAW = 2;
48 const EDIT_NORMAL = 3;
50 protected $successMessage;
52 protected $toc;
54 private $badItems = [];
56 /**
57 * @var TitleParser
59 private $titleParser;
61 public function __construct() {
62 parent::__construct( 'EditWatchlist', 'editmywatchlist' );
65 /**
66 * Initialize any services we'll need (unless it has already been provided via a setter).
67 * This allows for dependency injection even though we don't control object creation.
69 private function initServices() {
70 if ( !$this->titleParser ) {
71 $this->titleParser = MediaWikiServices::getInstance()->getTitleParser();
75 public function doesWrites() {
76 return true;
79 /**
80 * Main execution point
82 * @param int $mode
84 public function execute( $mode ) {
85 $this->initServices();
86 $this->setHeaders();
88 # Anons don't get a watchlist
89 $this->requireLogin( 'watchlistanontext' );
91 $out = $this->getOutput();
93 $this->checkPermissions();
94 $this->checkReadOnly();
96 $this->outputHeader();
97 $this->outputSubtitle();
98 $out->addModuleStyles( 'mediawiki.special' );
100 # B/C: $mode used to be waaay down the parameter list, and the first parameter
101 # was $wgUser
102 if ( $mode instanceof User ) {
103 $args = func_get_args();
104 if ( count( $args ) >= 4 ) {
105 $mode = $args[3];
108 $mode = self::getMode( $this->getRequest(), $mode );
110 switch ( $mode ) {
111 case self::EDIT_RAW:
112 $out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
113 $form = $this->getRawForm();
114 if ( $form->show() ) {
115 $out->addHTML( $this->successMessage );
116 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
118 break;
119 case self::EDIT_CLEAR:
120 $out->setPageTitle( $this->msg( 'watchlistedit-clear-title' ) );
121 $form = $this->getClearForm();
122 if ( $form->show() ) {
123 $out->addHTML( $this->successMessage );
124 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
126 break;
128 case self::EDIT_NORMAL:
129 default:
130 $this->executeViewEditWatchlist();
131 break;
136 * Renders a subheader on the watchlist page.
138 protected function outputSubtitle() {
139 $out = $this->getOutput();
140 $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
141 ->rawParams(
142 self::buildTools(
143 $this->getLanguage(),
144 $this->getLinkRenderer()
151 * Executes an edit mode for the watchlist view, from which you can manage your watchlist
154 protected function executeViewEditWatchlist() {
155 $out = $this->getOutput();
156 $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
157 $form = $this->getNormalForm();
158 if ( $form->show() ) {
159 $out->addHTML( $this->successMessage );
160 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
161 } elseif ( $this->toc !== false ) {
162 $out->prependHTML( $this->toc );
163 $out->addModules( 'mediawiki.toc' );
168 * Return an array of subpages that this special page will accept.
170 * @see also SpecialWatchlist::getSubpagesForPrefixSearch
171 * @return string[] subpages
173 public function getSubpagesForPrefixSearch() {
174 // SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added
175 // here and there - no 'edit' here, because that the default for this page
176 return [
177 'clear',
178 'raw',
183 * Extract a list of titles from a blob of text, returning
184 * (prefixed) strings; unwatchable titles are ignored
186 * @param string $list
187 * @return array
189 private function extractTitles( $list ) {
190 $list = explode( "\n", trim( $list ) );
191 if ( !is_array( $list ) ) {
192 return [];
195 $titles = [];
197 foreach ( $list as $text ) {
198 $text = trim( $text );
199 if ( strlen( $text ) > 0 ) {
200 $title = Title::newFromText( $text );
201 if ( $title instanceof Title && $title->isWatchable() ) {
202 $titles[] = $title;
207 MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray( $titles );
209 $list = [];
210 /** @var Title $title */
211 foreach ( $titles as $title ) {
212 $list[] = $title->getPrefixedText();
215 return array_unique( $list );
218 public function submitRaw( $data ) {
219 $wanted = $this->extractTitles( $data['Titles'] );
220 $current = $this->getWatchlist();
222 if ( count( $wanted ) > 0 ) {
223 $toWatch = array_diff( $wanted, $current );
224 $toUnwatch = array_diff( $current, $wanted );
225 $this->watchTitles( $toWatch );
226 $this->unwatchTitles( $toUnwatch );
227 $this->getUser()->invalidateCache();
229 if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
230 $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
231 } else {
232 return false;
235 if ( count( $toWatch ) > 0 ) {
236 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' )
237 ->numParams( count( $toWatch ) )->parse();
238 $this->showTitles( $toWatch, $this->successMessage );
241 if ( count( $toUnwatch ) > 0 ) {
242 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
243 ->numParams( count( $toUnwatch ) )->parse();
244 $this->showTitles( $toUnwatch, $this->successMessage );
246 } else {
247 $this->clearWatchlist();
248 $this->getUser()->invalidateCache();
250 if ( count( $current ) > 0 ) {
251 $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
252 } else {
253 return false;
256 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
257 ->numParams( count( $current ) )->parse();
258 $this->showTitles( $current, $this->successMessage );
261 return true;
264 public function submitClear( $data ) {
265 $current = $this->getWatchlist();
266 $this->clearWatchlist();
267 $this->getUser()->invalidateCache();
268 $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse();
269 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' )
270 ->numParams( count( $current ) )->parse();
271 $this->showTitles( $current, $this->successMessage );
273 return true;
277 * Print out a list of linked titles
279 * $titles can be an array of strings or Title objects; the former
280 * is preferred, since Titles are very memory-heavy
282 * @param array $titles Array of strings, or Title objects
283 * @param string $output
285 private function showTitles( $titles, &$output ) {
286 $talk = $this->msg( 'talkpagelinktext' )->text();
287 // Do a batch existence check
288 $batch = new LinkBatch();
289 if ( count( $titles ) >= 100 ) {
290 $output = $this->msg( 'watchlistedit-too-many' )->parse();
291 return;
293 foreach ( $titles as $title ) {
294 if ( !$title instanceof Title ) {
295 $title = Title::newFromText( $title );
298 if ( $title instanceof Title ) {
299 $batch->addObj( $title );
300 $batch->addObj( $title->getTalkPage() );
304 $batch->execute();
306 // Print out the list
307 $output .= "<ul>\n";
309 $linkRenderer = $this->getLinkRenderer();
310 foreach ( $titles as $title ) {
311 if ( !$title instanceof Title ) {
312 $title = Title::newFromText( $title );
315 if ( $title instanceof Title ) {
316 $output .= '<li>' .
317 $linkRenderer->makeLink( $title ) . ' ' .
318 $this->msg( 'parentheses' )->rawParams(
319 $linkRenderer->makeLink( $title->getTalkPage(), $talk )
320 )->escaped() .
321 "</li>\n";
325 $output .= "</ul>\n";
329 * Prepare a list of titles on a user's watchlist (excluding talk pages)
330 * and return an array of (prefixed) strings
332 * @return array
334 private function getWatchlist() {
335 $list = [];
337 $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()->getWatchedItemsForUser(
338 $this->getUser(),
339 [ 'forWrite' => $this->getRequest()->wasPosted() ]
342 if ( $watchedItems ) {
343 /** @var Title[] $titles */
344 $titles = [];
345 foreach ( $watchedItems as $watchedItem ) {
346 $namespace = $watchedItem->getLinkTarget()->getNamespace();
347 $dbKey = $watchedItem->getLinkTarget()->getDBkey();
348 $title = Title::makeTitleSafe( $namespace, $dbKey );
350 if ( $this->checkTitle( $title, $namespace, $dbKey )
351 && !$title->isTalkPage()
353 $titles[] = $title;
357 MediaWikiServices::getInstance()->getGenderCache()->doTitlesArray( $titles );
359 foreach ( $titles as $title ) {
360 $list[] = $title->getPrefixedText();
364 $this->cleanupWatchlist();
366 return $list;
370 * Get a list of titles on a user's watchlist, excluding talk pages,
371 * and return as a two-dimensional array with namespace and title.
373 * @return array
375 protected function getWatchlistInfo() {
376 $titles = [];
378 $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
379 ->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
381 $lb = new LinkBatch();
383 foreach ( $watchedItems as $watchedItem ) {
384 $namespace = $watchedItem->getLinkTarget()->getNamespace();
385 $dbKey = $watchedItem->getLinkTarget()->getDBkey();
386 $lb->add( $namespace, $dbKey );
387 if ( !MWNamespace::isTalk( $namespace ) ) {
388 $titles[$namespace][$dbKey] = 1;
392 $lb->execute();
394 return $titles;
398 * Validates watchlist entry
400 * @param Title $title
401 * @param int $namespace
402 * @param string $dbKey
403 * @return bool Whether this item is valid
405 private function checkTitle( $title, $namespace, $dbKey ) {
406 if ( $title
407 && ( $title->isExternal()
408 || $title->getNamespace() < 0
411 $title = false; // unrecoverable
414 if ( !$title
415 || $title->getNamespace() != $namespace
416 || $title->getDBkey() != $dbKey
418 $this->badItems[] = [ $title, $namespace, $dbKey ];
421 return (bool)$title;
425 * Attempts to clean up broken items
427 private function cleanupWatchlist() {
428 if ( !count( $this->badItems ) ) {
429 return; // nothing to do
432 $user = $this->getUser();
433 $badItems = $this->badItems;
434 DeferredUpdates::addCallableUpdate( function () use ( $user, $badItems ) {
435 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
436 foreach ( $badItems as $row ) {
437 list( $title, $namespace, $dbKey ) = $row;
438 $action = $title ? 'cleaning up' : 'deleting';
439 wfDebug( "User {$user->getName()} has broken watchlist item " .
440 "ns($namespace):$dbKey, $action.\n" );
442 $store->removeWatch( $user, new TitleValue( (int)$namespace, $dbKey ) );
443 // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
444 if ( $title ) {
445 $user->addWatch( $title );
448 } );
452 * Remove all titles from a user's watchlist
454 private function clearWatchlist() {
455 $dbw = wfGetDB( DB_MASTER );
456 $dbw->delete(
457 'watchlist',
458 [ 'wl_user' => $this->getUser()->getId() ],
459 __METHOD__
464 * Add a list of targets to a user's watchlist
466 * @param string[]|LinkTarget[] $targets
468 private function watchTitles( $targets ) {
469 $expandedTargets = [];
470 foreach ( $targets as $target ) {
471 if ( !$target instanceof LinkTarget ) {
472 try {
473 $target = $this->titleParser->parseTitle( $target, NS_MAIN );
475 catch ( MalformedTitleException $e ) {
476 continue;
480 $ns = $target->getNamespace();
481 $dbKey = $target->getDBkey();
482 $expandedTargets[] = new TitleValue( MWNamespace::getSubject( $ns ), $dbKey );
483 $expandedTargets[] = new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
486 MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
487 $this->getUser(),
488 $expandedTargets
493 * Remove a list of titles from a user's watchlist
495 * $titles can be an array of strings or Title objects; the former
496 * is preferred, since Titles are very memory-heavy
498 * @param array $titles Array of strings, or Title objects
500 private function unwatchTitles( $titles ) {
501 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
503 foreach ( $titles as $title ) {
504 if ( !$title instanceof Title ) {
505 $title = Title::newFromText( $title );
508 if ( $title instanceof Title ) {
509 $store->removeWatch( $this->getUser(), $title->getSubjectPage() );
510 $store->removeWatch( $this->getUser(), $title->getTalkPage() );
512 $page = WikiPage::factory( $title );
513 Hooks::run( 'UnwatchArticleComplete', [ $this->getUser(), &$page ] );
518 public function submitNormal( $data ) {
519 $removed = [];
521 foreach ( $data as $titles ) {
522 $this->unwatchTitles( $titles );
523 $removed = array_merge( $removed, $titles );
526 if ( count( $removed ) > 0 ) {
527 $this->successMessage = $this->msg( 'watchlistedit-normal-done'
528 )->numParams( count( $removed ) )->parse();
529 $this->showTitles( $removed, $this->successMessage );
531 return true;
532 } else {
533 return false;
538 * Get the standard watchlist editing form
540 * @return HTMLForm
542 protected function getNormalForm() {
543 global $wgContLang;
545 $fields = [];
546 $count = 0;
548 // Allow subscribers to manipulate the list of watched pages (or use it
549 // to preload lots of details at once)
550 $watchlistInfo = $this->getWatchlistInfo();
551 Hooks::run(
552 'WatchlistEditorBeforeFormRender',
553 [ &$watchlistInfo ]
556 foreach ( $watchlistInfo as $namespace => $pages ) {
557 $options = [];
559 foreach ( array_keys( $pages ) as $dbkey ) {
560 $title = Title::makeTitleSafe( $namespace, $dbkey );
562 if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
563 $text = $this->buildRemoveLine( $title );
564 $options[$text] = $title->getPrefixedText();
565 $count++;
569 // checkTitle can filter some options out, avoid empty sections
570 if ( count( $options ) > 0 ) {
571 $fields['TitlesNs' . $namespace] = [
572 'class' => 'EditWatchlistCheckboxSeriesField',
573 'options' => $options,
574 'section' => "ns$namespace",
578 $this->cleanupWatchlist();
580 if ( count( $fields ) > 1 && $count > 30 ) {
581 $this->toc = Linker::tocIndent();
582 $tocLength = 0;
584 foreach ( $fields as $data ) {
585 # strip out the 'ns' prefix from the section name:
586 $ns = substr( $data['section'], 2 );
588 $nsText = ( $ns == NS_MAIN )
589 ? $this->msg( 'blanknamespace' )->escaped()
590 : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
591 $this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
592 $this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
595 $this->toc = Linker::tocList( $this->toc );
596 } else {
597 $this->toc = false;
600 $context = new DerivativeContext( $this->getContext() );
601 $context->setTitle( $this->getPageTitle() ); // Remove subpage
602 $form = new EditWatchlistNormalHTMLForm( $fields, $context );
603 $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
604 $form->setSubmitDestructive();
605 # Used message keys:
606 # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
607 $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
608 $form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
609 $form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
610 $form->setSubmitCallback( [ $this, 'submitNormal' ] );
612 return $form;
616 * Build the label for a checkbox, with a link to the title, and various additional bits
618 * @param Title $title
619 * @return string
621 private function buildRemoveLine( $title ) {
622 $linkRenderer = $this->getLinkRenderer();
623 $link = $linkRenderer->makeLink( $title );
625 $tools['talk'] = $linkRenderer->makeLink(
626 $title->getTalkPage(),
627 $this->msg( 'talkpagelinktext' )->text()
630 if ( $title->exists() ) {
631 $tools['history'] = $linkRenderer->makeKnownLink(
632 $title,
633 $this->msg( 'history_short' )->text(),
635 [ 'action' => 'history' ]
639 if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
640 $tools['contributions'] = $linkRenderer->makeKnownLink(
641 SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
642 $this->msg( 'contributions' )->text()
646 Hooks::run(
647 'WatchlistEditorBuildRemoveLine',
648 [ &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link ]
651 if ( $title->isRedirect() ) {
652 // Linker already makes class mw-redirect, so this is redundant
653 $link = '<span class="watchlistredir">' . $link . '</span>';
656 return $link . ' ' .
657 $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $tools ) )->escaped();
661 * Get a form for editing the watchlist in "raw" mode
663 * @return HTMLForm
665 protected function getRawForm() {
666 $titles = implode( $this->getWatchlist(), "\n" );
667 $fields = [
668 'Titles' => [
669 'type' => 'textarea',
670 'label-message' => 'watchlistedit-raw-titles',
671 'default' => $titles,
674 $context = new DerivativeContext( $this->getContext() );
675 $context->setTitle( $this->getPageTitle( 'raw' ) ); // Reset subpage
676 $form = new HTMLForm( $fields, $context );
677 $form->setSubmitTextMsg( 'watchlistedit-raw-submit' );
678 # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
679 $form->setSubmitTooltip( 'watchlistedit-raw-submit' );
680 $form->setWrapperLegendMsg( 'watchlistedit-raw-legend' );
681 $form->addHeaderText( $this->msg( 'watchlistedit-raw-explain' )->parse() );
682 $form->setSubmitCallback( [ $this, 'submitRaw' ] );
684 return $form;
688 * Get a form for clearing the watchlist
690 * @return HTMLForm
692 protected function getClearForm() {
693 $context = new DerivativeContext( $this->getContext() );
694 $context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage
695 $form = new HTMLForm( [], $context );
696 $form->setSubmitTextMsg( 'watchlistedit-clear-submit' );
697 # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
698 $form->setSubmitTooltip( 'watchlistedit-clear-submit' );
699 $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
700 $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
701 $form->setSubmitCallback( [ $this, 'submitClear' ] );
702 $form->setSubmitDestructive();
704 return $form;
708 * Determine whether we are editing the watchlist, and if so, what
709 * kind of editing operation
711 * @param WebRequest $request
712 * @param string $par
713 * @return int
715 public static function getMode( $request, $par ) {
716 $mode = strtolower( $request->getVal( 'action', $par ) );
718 switch ( $mode ) {
719 case 'clear':
720 case self::EDIT_CLEAR:
721 return self::EDIT_CLEAR;
722 case 'raw':
723 case self::EDIT_RAW:
724 return self::EDIT_RAW;
725 case 'edit':
726 case self::EDIT_NORMAL:
727 return self::EDIT_NORMAL;
728 default:
729 return false;
734 * Build a set of links for convenient navigation
735 * between watchlist viewing and editing modes
737 * @param Language $lang
738 * @param LinkRenderer|null $linkRenderer
739 * @return string
741 public static function buildTools( $lang, LinkRenderer $linkRenderer = null ) {
742 if ( !$lang instanceof Language ) {
743 // back-compat where the first parameter was $unused
744 global $wgLang;
745 $lang = $wgLang;
747 if ( !$linkRenderer ) {
748 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
751 $tools = [];
752 $modes = [
753 'view' => [ 'Watchlist', false ],
754 'edit' => [ 'EditWatchlist', false ],
755 'raw' => [ 'EditWatchlist', 'raw' ],
756 'clear' => [ 'EditWatchlist', 'clear' ],
759 foreach ( $modes as $mode => $arr ) {
760 // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
761 $tools[] = $linkRenderer->makeKnownLink(
762 SpecialPage::getTitleFor( $arr[0], $arr[1] ),
763 wfMessage( "watchlisttools-{$mode}" )->text()
767 return Html::rawElement(
768 'span',
769 [ 'class' => 'mw-watchlist-toollinks' ],
770 wfMessage( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped()
776 * Extend HTMLForm purely so we can have a more sane way of getting the section headers
778 class EditWatchlistNormalHTMLForm extends HTMLForm {
779 public function getLegend( $namespace ) {
780 $namespace = substr( $namespace, 2 );
782 return $namespace == NS_MAIN
783 ? $this->msg( 'blanknamespace' )->escaped()
784 : htmlspecialchars( $this->getContext()->getLanguage()->getFormattedNsText( $namespace ) );
787 public function getBody() {
788 return $this->displaySection( $this->mFieldTree, '', 'editwatchlist-' );
792 class EditWatchlistCheckboxSeriesField extends HTMLMultiSelectField {
794 * HTMLMultiSelectField throws validation errors if we get input data
795 * that doesn't match the data set in the form setup. This causes
796 * problems if something gets removed from the watchlist while the
797 * form is open (bug 32126), but we know that invalid items will
798 * be harmless so we can override it here.
800 * @param string $value The value the field was submitted with
801 * @param array $alldata The data collected from the form
802 * @return bool|string Bool true on success, or String error to display.
804 function validate( $value, $alldata ) {
805 // Need to call into grandparent to be a good citizen. :)
806 return HTMLFormField::validate( $value, $alldata );