X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLTitleTextField.php;h=3df5b7ec9ba19bf51cfa1e5257c9adb7dcf51402;hb=fa0f6f34972c0e0f4aac24a03b3efdfc45f256f6;hp=93d09e7f14d1f57f83bbcd078d0799a7fd364c8c;hpb=97af92da48f0d434cf4b541e7a3f2d96619a95b2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLTitleTextField.php b/includes/htmlform/fields/HTMLTitleTextField.php index 93d09e7f14..3df5b7ec9b 100644 --- a/includes/htmlform/fields/HTMLTitleTextField.php +++ b/includes/htmlform/fields/HTMLTitleTextField.php @@ -1,6 +1,5 @@ mParent->getMethod() === 'get' && $value === '' ) { - // If the form is a GET form and has no value, assume it hasn't been - // submitted yet, and skip validation - // TODO This doesn't look right, we should be able to tell the difference - // between "not submitted" (null) and "submitted but empty" (empty string). - return parent::validate( $value, $alldata ); - } - // Default value (from getDefault()) is null, which breaks Title::newFromTextThrow() below if ( $value === null ) { $value = ''; @@ -57,24 +45,17 @@ class HTMLTitleTextField extends HTMLTextField { $title = Title::newFromTextThrow( $value ); } else { // Can't use Title::makeTitleSafe(), because it doesn't throw useful exceptions - $namespaceName = MediaWikiServices::getInstance()->getContentLanguage()-> - getNsText( $this->mParams['namespace'] ); - $title = Title::newFromTextThrow( $namespaceName . ':' . $value ); + $title = Title::newFromTextThrow( Title::makeName( $this->mParams['namespace'], $value ) ); } } catch ( MalformedTitleException $e ) { - $msg = $this->msg( $e->getErrorMessage() ); - $params = $e->getErrorMessageParameters(); - if ( $params ) { - $msg->params( $params ); - } - return $msg; + return $this->msg( $e->getErrorMessage(), $e->getErrorMessageParameters() ); } $text = $title->getPrefixedText(); if ( $this->mParams['namespace'] !== false && !$title->inNamespace( $this->mParams['namespace'] ) ) { - return $this->msg( 'htmlform-title-badnamespace', $this->mParams['namespace'], $text ); + return $this->msg( 'htmlform-title-badnamespace', $text, $this->mParams['namespace'] ); } if ( $this->mParams['creatable'] && !$title->canExist() ) {