HttpError: Cast Message to string

In theory PHP should use coerce objects with a __toString method
to string when passing them to a method which has a string-typed
argument, but with the native Exception class this doesn't seem
to be working, so cast explicitly.

Bug: T388171
Change-Id: I310b97164877445837babed2a4c47795f1c2c277
(cherry picked from commit a14ef848f758612ac9d4e8c881ecdbbccf3e1158)
This commit is contained in:
Gergő Tisza 2025-03-07 20:21:20 +01:00 committed by Reedy
parent c614979c07
commit b4dc368f72

View file

@ -47,7 +47,7 @@ class HttpError extends MWException {
* @param-taint $header tainted
*/
public function __construct( $httpCode, $content, $header = null ) {
parent::__construct( $content );
parent::__construct( (string)$content );
$this->httpCode = (int)$httpCode;
$this->header = $header;
$this->content = $content;