Opened 10 years ago
Closed 10 years ago
#36838 closed defect (bug) (fixed)
Invalid argument supplied for foreach() in /wp-includes/theme-compat/embed-content.php on line 32
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.5.3 | Priority: | normal |
| Severity: | normal | Version: | 4.5 |
| Component: | Embeds | Keywords: | has-patch commit fixed-major |
| Focuses: | template | Cc: |
Description
This is a follow-up to #35237.
Looks like this bug is happening again. If it was fixed, it's not now. This embed URL causes it on my blog: http://blog.markheadrick.com/2011/12/13/blog-updated-to-wordpress-3-3-and-other-website-changes/embed/
It's this line of code:
foreach ( $meta['sizes'] as $size => $data ) {
The $meta array is:
Array
(
[width] => 140
[height] => 105
[hwstring_small] => height='96' width='128'
[file] => 2010/12/markrh_s2.jpg
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
)
)
As you can see there is no [sizes] section. Looks like the check mentioned in my previous bug is no longer in the code, if it was added. This is an older post with a single image associated with it at the single size.
Attachments (1)
Change History (10)
#2
@
10 years ago
I re-added that image as the featured image for that post again for debugging purposes.
#3
@
10 years ago
- Focuses template added
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.5.3
- Owner set to swissspidy
- Status changed from new to assigned
- Version changed from 4.5.2 to 4.5
Hey @MarkRH,
Thanks for creating this ticket!
It indeed looks like [36693] broke this again. See #34561.
Looks like the problem was that the patches on that ticket were mostly made before #35237 and the bugfix wasn't incorporated in a new patch afterwards.
The good thing is, we don't need to backport this to 4.4, but only to 4.5.3.
Thought I should add that I modified the code to keep it from happening and to log what URLs are being accessed:
if ( is_array( $meta ) ) { my_log('embed-content.php: - '.$_SERVER['REQUEST_URI'].' - ','/embed.log'); if (isset($meta['sizes'])) { foreach ( $meta['sizes'] as $size => $data ) { if ( $data['width'] / $data['height'] > $aspect_ratio ) { $aspect_ratio = $data['width'] / $data['height']; $measurements = array( $data['width'], $data['height'] ); $image_size = $size; } } } else { $data = $meta; if ( $data['width'] / $data['height'] > $aspect_ratio ) { $aspect_ratio = $data['width'] / $data['height']; $measurements = array( $data['width'], $data['height'] ); } }