From: Brad Jorsch Date: Mon, 27 Jun 2016 23:31:56 +0000 (-0400) Subject: UsageException: Validate that $codestr is a non-empty string X-Git-Tag: 1.31.0-rc.0~6513 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=27f652644ce64b86d5a8701e8010b3c61ae062ac;p=lhc%2Fweb%2Fwiklou.git UsageException: Validate that $codestr is a non-empty string Current theory on T138585 is that something is passing in false, so let's throw an InvalidArgumentException that should log a backtrace for us. Bug: T138585 Change-Id: Iba0dad424c56340b8bc73322bb1a7ae6d4de314a --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index ce9587f399..c8601a0992 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1901,6 +1901,14 @@ class UsageException extends MWException { parent::__construct( $message, $code ); $this->mCodestr = $codestr; $this->mExtraData = $extradata; + + // This should never happen, so throw an exception about it that will + // hopefully get logged with a backtrace (T138585) + if ( !is_string( $codestr ) || $codestr === '' ) { + throw new InvalidArgumentException( 'Invalid $codestr, was ' . + ( $codestr === '' ? 'empty string' : gettype( $codestr ) ) + ); + } } /**