Page MenuHomePhabricator

PHP warning with error_reporting(E_ALL) on empty padding input to {{padleft}} / {{padright}}
Closed, ResolvedPublic

Description

Author: nickpj

Description:

Minor PHP warning with string padding, wiki text is:

{{padright:||||||||}}

HTML output on a wiki with error_reporting(E_ALL) includes:

<b>Warning</b>: str_pad() [<a href='function.str-pad'>function.str-pad</a>]:
Padding string cannot be empty. in
<b>/var/www/hosts/mediawiki/phase3/includes/CoreParserFunctions.php</b> on line

<b>155</b><br />

Maybe just return $string when the padding value is empty? e.g. something

roughly like:

function padright( $parser, $string = '', $length = 0, $char = 0 ) {
if ((string)$char) {
return str_pad( $string, $length, (string)$char, STR_PAD_RIGHT );
} else {
return $string;
}

}

... or perhaps in this situation just set it to a generally acceptable default:

if (!(string)$char) $char = "0";

return str_pad( $string, $length, (string)$char, STR_PAD_RIGHT );


Version: 1.8.x
Severity: minor

Details

Reference
bz7081

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:26 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz7081.

robchur wrote:

Fixed in SVN trunk, r16152.