From: Ben Davis Date: Mon, 18 Jul 2016 19:26:07 +0000 (-0500) Subject: Fix for "Invalid key type: integer" X-Git-Tag: 1.31.0-rc.0~6150 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=8d590fac31d5b37b892ea76852da029bb01cdbed;p=lhc%2Fweb%2Fwiklou.git Fix for "Invalid key type: integer" MWCryptHash::hmac requires a string, but mt_rand() returns an integer. This issue resulted in an uncaught exception in a fresh installation of mediawiki. Imported from https://github.com/wikimedia/mediawiki/pull/55 Change-Id: Idccf5f230bfc2de30357b03c78c51cdad4839515 --- diff --git a/includes/utils/MWCryptRand.php b/includes/utils/MWCryptRand.php index f3d72e834e..dd3ea1b87e 100644 --- a/includes/utils/MWCryptRand.php +++ b/includes/utils/MWCryptRand.php @@ -324,7 +324,7 @@ class MWCryptRand { ": Falling back to using a pseudo random state to generate randomness.\n" ); } while ( strlen( $buffer ) < $bytes ) { - $buffer .= MWCryptHash::hmac( $this->randomState(), mt_rand() ); + $buffer .= MWCryptHash::hmac( $this->randomState(), strval( mt_rand() ) ); // This code is never really cryptographically strong, if we use it // at all, then set strong to false. $this->strong = false;