templatelinks does).
* (bug 58167) The web installer no longer throws an exception when PHP is
compiled without support for MySQL yet with support for another DBMS.
+* (bug 56199) Raw option of parser functions must now match complete word,
+ to take effect.
=== Web API changes in 1.23 ===
* (bug 54884) action=parse&prop=categories now indicates hidden and missing
var $mId, $mSynonyms, $mCaseSensitive;
var $mRegex = '';
var $mRegexStart = '';
+ var $mRegexStartToEnd = '';
var $mBaseRegex = '';
var $mVariableRegex = '';
var $mVariableStartToEndRegex = '';
$case = $this->mCaseSensitive ? '' : 'iu';
$this->mRegex = "/{$this->mBaseRegex}/{$case}";
$this->mRegexStart = "/^(?:{$this->mBaseRegex})/{$case}";
+ $this->mRegexStartToEnd = "/^(?:{$this->mBaseRegex})$/{$case}";
$this->mVariableRegex = str_replace( "\\$1", "(.*?)", $this->mRegex );
$this->mVariableStartToEndRegex = str_replace( "\\$1", "(.*?)",
"/^(?:{$this->mBaseRegex})$/{$case}" );
return $this->mRegexStart;
}
+ /**
+ * Gets a regex matching the word from start to end of a string
+ *
+ * @return string
+ * @since 1.23
+ */
+ function getRegexStartToEnd() {
+ if ( $this->mRegexStartToEnd == '' ) {
+ $this->initRegex();
+ }
+ return $this->mRegexStartToEnd;
+ }
+
/**
* regex without the slashes and what not
*
return (bool)preg_match( $this->getRegexStart(), $text );
}
+ /**
+ * Returns true if the text matched the word
+ *
+ * @param $text string
+ *
+ * @return bool
+ * @since 1.23
+ */
+ function matchStartToEnd( $text ) {
+ return (bool)preg_match( $this->getRegexStartToEnd(), $text );
+ }
+
/**
* Returns NULL if there's no match, the value of $1 otherwise
* The return code is the matched string, if there's no variable
* @return boolean true on successful match
*/
private static function matchAgainstMagicword( $magicword, $value ) {
- if ( strval( $value ) === '' ) {
+ $value = trim( strval( $value ) );
+ if ( $value === '' ) {
return false;
}
$mwObject = MagicWord::get( $magicword );
- return $mwObject->match( $value );
+ return $mwObject->matchStartToEnd( $value );
}
static function formatRaw( $num, $raw ) {
</p>
!! end
+!! test
+Wrong option for formatNum (bug 56199)
+!! input
+{{formatnum:1,234.56|Random}}
+{{formatnum:1,234.56|EVERYTHING}}
+{{formatnum:1234.56|any argument that has the string 'NOSEP'}}
+!! result
+<p>1,234.56
+1,234.56
+1,234.56
+</p>
+!! end
+
!! test
Strip marker in grammar
!! options