From: This, that and the other Date: Thu, 28 Jan 2016 23:52:37 +0000 (+1100) Subject: Title::newFromText: Cast integers to strings X-Git-Tag: 1.31.0-rc.0~8165^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=eda82d60c68beb89189f2828edea9c5de696082d;p=lhc%2Fweb%2Fwiklou.git Title::newFromText: Cast integers to strings This is the cause of the T76305 debug log entries relating to SpecialExport and Echo. Bug: T76305 Bug: T116034 Change-Id: I64d629d31be79c4b4702a4298bce68fd544df6e8 --- diff --git a/includes/Title.php b/includes/Title.php index e549037fac..882b7dda78 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -246,7 +246,7 @@ class Title { * Create a new Title from text, such as what one would find in a link. De- * codes any HTML entities in the text. * - * @param string|null $text The link text; spaces, prefixes, and an + * @param string|int|null $text The link text; spaces, prefixes, and an * initial ':' indicating the main namespace are accepted. * @param int $defaultNamespace The namespace to use if none is specified * by a prefix. If you want to force a specific namespace even if @@ -259,7 +259,8 @@ class Title { if ( is_object( $text ) ) { throw new InvalidArgumentException( '$text must be a string.' ); } - if ( $text !== null && !is_string( $text ) ) { + // DWIM: Integers can be passed in here when page titles are used as array keys. + if ( $text !== null && !is_string( $text ) && !is_int( $text ) ) { wfDebugLog( 'T76305', wfGetAllCallers( 5 ) ); return null; } @@ -268,7 +269,7 @@ class Title { } try { - return Title::newFromTextThrow( $text, $defaultNamespace ); + return Title::newFromTextThrow( strval( $text ), $defaultNamespace ); } catch ( MalformedTitleException $ex ) { return null; }