diff --git a/includes/Rest/ConditionalHeaderUtil.php b/includes/Rest/ConditionalHeaderUtil.php index 355e48dedd8..0a39f06678c 100644 --- a/includes/Rest/ConditionalHeaderUtil.php +++ b/includes/Rest/ConditionalHeaderUtil.php @@ -143,11 +143,14 @@ class ConditionalHeaderUtil { /** * The strong comparison function * - * @param array $tag1 Parsed tag info array - * @param array $tag2 Parsed tag info array + * @param array|null $tag1 Parsed tag info array + * @param array|null $tag2 Parsed tag info array * @return bool */ private function strongCompare( $tag1, $tag2 ) { + if ( $tag1 === null || $tag2 === null ) { + return false; + } return !$tag1['weak'] && !$tag2['weak'] && $tag1['contents'] === $tag2['contents']; } } diff --git a/includes/media/WebPHandler.php b/includes/media/WebPHandler.php index 0613fc27788..1a42da87c18 100644 --- a/includes/media/WebPHandler.php +++ b/includes/media/WebPHandler.php @@ -188,9 +188,9 @@ class WebPHandler extends BitmapHandler { // Bytes 0-3 are 'VP8L' // Bytes 4-7 are chunk stream size // Byte 8 is 0x2F called the signature - if ( $header{8} != "\x2F" ) { + if ( $header[8] != "\x2F" ) { wfDebugLog( 'WebP', __METHOD__ . ': Invalid signature: ' . - bin2hex( $header{8} ) . "\n" ); + bin2hex( $header[8] ) . "\n" ); return []; } // Bytes 9-12 contain the image size diff --git a/tests/phpunit/unit/includes/FactoryArgTestTrait.php b/tests/phpunit/unit/includes/FactoryArgTestTrait.php index f7035b4d23e..d9f56e1aa21 100644 --- a/tests/phpunit/unit/includes/FactoryArgTestTrait.php +++ b/tests/phpunit/unit/includes/FactoryArgTestTrait.php @@ -91,7 +91,13 @@ trait FactoryArgTestTrait { $pos = $param->getPosition(); - $type = (string)$param->getType(); + $type = $param->getType(); + if ( !$type ) { + // Optimistically assume a string is okay + return "some unlikely string $pos"; + } + + $type = $type->getName(); if ( $type === 'array' ) { return [ "some unlikely string $pos" ]; @@ -101,11 +107,6 @@ trait FactoryArgTestTrait { return $this->createMock( $type ); } - if ( $type === '' ) { - // Optimistically assume a string is okay - return "some unlikely string $pos"; - } - $this->fail( "Unrecognized parameter type $type" ); }