Skip to content

Commit 8f8a614

Browse files
b1ink0westonruter
andauthored
Convert invalid input to empty array
Co-authored-by: Weston Ruter <[email protected]>
1 parent 70ad323 commit 8f8a614

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

plugins/webp-uploads/hooks.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,11 +813,12 @@ function webp_uploads_enable_additional_mime_type_support_for_all_sizes( array $
813813
* @since n.e.x.t
814814
*
815815
* @param array<string, mixed>|mixed $file The uploaded file data.
816-
* @return array<string, mixed>|mixed The modified file data.
816+
* @return array<string, mixed> The modified file data.
817817
*/
818-
function webp_uploads_convert_palette_png_to_truecolor( $file ) {
818+
function webp_uploads_convert_palette_png_to_truecolor( $file ): array {
819+
// Because plugins do bad things.
819820
if ( ! is_array( $file ) ) {
820-
return $file;
821+
$file = array();
821822
}
822823
if ( ! isset( $file['tmp_name'], $file['name'] ) ) {
823824
return $file;

plugins/webp-uploads/tests/test-load.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,7 @@ public function data_to_test_webp_uploads_convert_palette_png_to_truecolor(): ar
12351235
* @covers ::webp_uploads_convert_palette_png_to_truecolor
12361236
*/
12371237
public function test_webp_uploads_convert_palette_png_to_truecolor_conditions(): void {
1238-
$invalid_file = 'test';
1239-
$this->assertSame( $invalid_file, webp_uploads_convert_palette_png_to_truecolor( $invalid_file ) );
1238+
$this->assertSame( array(), webp_uploads_convert_palette_png_to_truecolor( 'test' ) );
12401239
$this->assertSameSets( array(), webp_uploads_convert_palette_png_to_truecolor( array() ) );
12411240

12421241
$file = array(

0 commit comments

Comments
 (0)