X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLTitleTextField.php;h=dd9f793e1f6107d58b8db81fb5b5e1fb12fc2d95;hp=602ddee486d05608dee275c718ad16df1047d54c;hb=1dee28cb5f1efd6d9e14d6cc1d0c73c3f69269b4;hpb=8c96aec32cffaab96b2bd9dca206a99a13640545 diff --git a/includes/htmlform/fields/HTMLTitleTextField.php b/includes/htmlform/fields/HTMLTitleTextField.php index 602ddee486..dd9f793e1f 100644 --- a/includes/htmlform/fields/HTMLTitleTextField.php +++ b/includes/htmlform/fields/HTMLTitleTextField.php @@ -41,6 +41,11 @@ class HTMLTitleTextField extends HTMLTextField { return parent::validate( $value, $alldata ); } + // Default value (from getDefault()) is null, which breaks Title::newFromTextThrow() below + if ( $value === null ) { + $value = ''; + } + if ( !$this->mParams['required'] && $value === '' ) { // If this field is not required and the value is empty, that's okay, skip validation return parent::validate( $value, $alldata ); @@ -51,17 +56,10 @@ class HTMLTitleTextField extends HTMLTextField { $title = Title::newFromTextThrow( $value ); } else { // Can't use Title::makeTitleSafe(), because it doesn't throw useful exceptions - global $wgContLang; - $namespaceName = $wgContLang->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();