From 27f652644ce64b86d5a8701e8010b3c61ae062ac Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 27 Jun 2016 19:31:56 -0400 Subject: [PATCH] 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 --- includes/api/ApiMain.php | 8 ++++++++ 1 file changed, 8 insertions(+) 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 ) ) + ); + } } /** -- 2.20.1