From: jenkins-bot Date: Mon, 27 Jul 2015 02:12:47 +0000 (+0000) Subject: Merge "HTMLTitleTextField: Support 'relative' config option" X-Git-Tag: 1.31.0-rc.0~10640 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=bec1064f3146466119934cfcbafde1f53eca8956;p=lhc%2Fweb%2Fwiklou.git Merge "HTMLTitleTextField: Support 'relative' config option" --- bec1064f3146466119934cfcbafde1f53eca8956 diff --cc includes/htmlform/HTMLTitleTextField.php index 2124bb1cf9,6e5242c792..a225c67c39 --- a/includes/htmlform/HTMLTitleTextField.php +++ b/includes/htmlform/HTMLTitleTextField.php @@@ -29,13 -30,15 +31,20 @@@ class HTMLTitleTextField extends HTMLTe } public function validate( $value, $alldata ) { + if ( $this->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 + return parent::validate( $value, $alldata ); + } try { - $title = Title::newFromTextThrow( $value ); + if ( !$this->mParams['relative'] ) { + $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 ); + } } catch ( MalformedTitleException $e ) { $msg = $this->msg( $e->getErrorMessage() ); $params = $e->getErrorMessageParameters();