Check namespace exists in HTMLNamespacesMultiselectField validation
authorThalia <thalia.e.chan@googlemail.com>
Tue, 16 Jul 2019 17:07:10 +0000 (18:07 +0100)
committerThalia <thalia.e.chan@googlemail.com>
Tue, 16 Jul 2019 17:07:10 +0000 (18:07 +0100)
Bug: T219882
Change-Id: I710d0abed6bd40dcea5bdd1c59c8d936565961eb

includes/htmlform/fields/HTMLNamespacesMultiselectField.php

index 5eab605..cbcd3ba 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use MediaWiki\Widget\NamespacesMultiselectWidget;
+use MediaWiki\MediaWikiServices;
 
 /**
  * Implements a tag multiselect input field for namespaces.
@@ -43,7 +44,10 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace {
                }
 
                foreach ( $namespaces as $namespace ) {
-                       if ( $namespace < 0 ) {
+                       if (
+                               $namespace < 0 ||
+                               !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace )
+                       ) {
                                return $this->msg( 'htmlform-select-badoption' );
                        }