From d2ae2bd802ce0cf4637ea82e303f668fe719f559 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 11 Jul 2007 05:40:05 +0000 Subject: [PATCH] PHP typing strikes again! Padding parser functions now work with strings like '0' that evaluate to false. --- RELEASE-NOTES | 1 + includes/CoreParserFunctions.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 01d051dc27..55dd1a1388 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -275,6 +275,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN the intended skin directly in the URL. * (bug 9903) Don't mark redirects in categories as stubs * (bug 6965) Cannot include "Template:R" with {{R}} (magic word conflict) +* Padding parser functions now work with strings like '0' that evaluate to false == API changes since 1.10 == diff --git a/includes/CoreParserFunctions.php b/includes/CoreParserFunctions.php index 261452aa29..a5f45016d1 100644 --- a/includes/CoreParserFunctions.php +++ b/includes/CoreParserFunctions.php @@ -161,7 +161,7 @@ class CoreParserFunctions { static function pad( $string = '', $length = 0, $char = 0, $direction = STR_PAD_RIGHT ) { $length = min( max( $length, 0 ), 500 ); $char = substr( $char, 0, 1 ); - return ( $string && (int)$length > 0 && strlen( trim( (string)$char ) ) > 0 ) + return ( $string !== '' && (int)$length > 0 && strlen( trim( (string)$char ) ) > 0 ) ? str_pad( $string, $length, (string)$char, $direction ) : $string; } -- 2.20.1