X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FTitle.php;h=1fdeca87c095d3f0091671e42cb04b3118f76631;hb=0686221b2d87e551b61f6c74ae1fcbad6a3aaea5;hp=9ada4f314d0a0e3620df76928227ce0cabe8c870;hpb=adc9d5b9ab7f7f92ece9c85d0a54e5fe2bbc738d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 9ada4f314d..1fdeca87c0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -252,7 +252,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 $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 @@ class Title { 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 @@ class Title { */ 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(); @@ -1944,7 +1944,7 @@ class Title { * - secure : does cheap and expensive checks, using the master as needed * @param array $ignoreErrors Array of Strings Set this to a list of message keys * whose corresponding errors may be ignored. - * @return array Array of arguments to wfMessage to explain permissions problems. + * @return array Array of arrays of the arguments to wfMessage to explain permissions problems. */ public function getUserPermissionsErrors( $action, $user, $rigor = 'secure', $ignoreErrors = array() @@ -1953,9 +1953,12 @@ class Title { // Remove the errors being ignored. foreach ( $errors as $index => $error ) { - $error_key = is_array( $error ) ? $error[0] : $error; + $errKey = is_array( $error ) ? $error[0] : $error; - if ( in_array( $error_key, $ignoreErrors ) ) { + if ( in_array( $errKey, $ignoreErrors ) ) { + unset( $errors[$index] ); + } + if ( $errKey instanceof MessageSpecifier && in_array( $errKey->getKey(), $ignoreErrors ) ) { unset( $errors[$index] ); } } @@ -2054,6 +2057,9 @@ class Title { } elseif ( $result !== '' && is_string( $result ) ) { // A string representing a message-id $errors[] = array( $result ); + } elseif ( $result instanceof MessageSpecifier ) { + // A message specifier representing an error + $errors[] = array( $result ); } elseif ( $result === false ) { // a generic "We don't want them to do that" $errors[] = array( 'badaccess-group0' );