#25649 closed defect (bug) (fixed)
Warning in wp-admin/includes/images.php
Reported by: | asakurayoh | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.8 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Warnings/Notices | Keywords: | |
Focuses: | Cc: |
Description
So, in wp-admin/includes/images.php, on line 154, this line is throwing a warning:
unset( $metadata['image']['data'] );
because, if the file attachment is not an image (like a video or audio file) those array are not set. So I propose to change it to:
if(isset($metadata['image']) && isset($metadata['image']['data'])){ unset( $metadata['image']['data'] ); }
Thanks
Change History (8)
#3
in reply to:
↑ 2
@
11 years ago
Replying to asakurayoh:
Well... it does, on EasyPHP, with errors activated, on PHP 5.2...
What's the exact warning?
(helen: I'm guessing it's for $metadata['image']
)
#4
@
11 years ago
The exact warning is this:
Warning: Cannot unset offset in a non-array variable in [my computer]\wp-admin\includes\image.php on line 154
So the problem is that it can't unset $metadata['image']['data']
because $metadata['image']
does'nt exists... the problem is with the multidimension array...
Thanks.
#5
@
11 years ago
- Milestone changed from Awaiting Review to 3.8
- Version changed from trunk to 3.6
The issue here is not a non-existent array key, it's that $metadata
isn't always an array.
I can reproduce the warning by calling wp_generate_attachment_metadata()
for an audio or video attachment that doesn't exist in the local filesystem.
Both wp_read_video_metadata()
and wp_read_audio_metadata()
return false in that case:
tags/3.7/src/wp-admin/includes/media.php#L2615
tags/3.7/src/wp-admin/includes/image.php#L121
And that causes the warning:
$metadata = false; unset( $metadata['image']['data'] );
I thought
unset()
didn't throw any warnings for a non-existent key. Are you actually seeing this in practice or is this an IDE warning?