Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/250882
Change subject: Title: Add warning if newFromText is given non-string/non-null
value
......................................................................
Title: Add warning if newFromText is given non-string/non-null value
Bug: T76305
Change-Id: I47517021471ac6fd6daca6deee039c8047224a33
---
M includes/Title.php
1 file changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/82/250882/1
diff --git a/includes/Title.php b/includes/Title.php
index 9ada4f3..82df19f 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -252,7 +252,7 @@
* 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 $text The link text; spaces, prefixes, and an
+ * @param string|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
@@ -264,13 +264,13 @@
public static function newFromText( $text, $defaultNamespace = NS_MAIN
) {
if ( is_object( $text ) ) {
throw new InvalidArgumentException( '$text must be a
string.' );
- } elseif ( !is_string( $text ) ) {
+ }
+ if ( $text !== null && !is_string( $text ) ) {
wfDebugLog( 'T76305', wfGetAllCallers( 5 ) );
- wfWarn(
- __METHOD__ . ': $text must be a string. ' .
- 'This will throw an
InvalidArgumentException in future.',
- 2
- );
+ return null;
+ }
+ if ( $text === null ) {
+ return null;
}
try {
@@ -296,7 +296,7 @@
*/
public static function newFromTextThrow( $text, $defaultNamespace =
NS_MAIN ) {
if ( is_object( $text ) ) {
- throw new MWException( 'Title::newFromTextThrow given
an object' );
+ throw new MWException( '$text must be a string, given
an object' );
}
$cache = self::getTitleCache();
--
To view, visit https://gerrit.wikimedia.org/r/250882
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I47517021471ac6fd6daca6deee039c8047224a33
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits