Make WordPress Core

Opened 8 years ago

Closed 8 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: markrh's profile MarkRH Owned by: swissspidy's profile swissspidy
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)

36838.diff (591 bytes) - added by swissspidy 8 years ago.

Download all attachments as: .zip

Change History (10)

#1 @MarkRH
8 years ago

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'] );
				}
         
         }

#2 @MarkRH
8 years ago

I re-added that image as the featured image for that post again for debugging purposes.

#3 @swissspidy
8 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.

@swissspidy
8 years ago

#4 @swissspidy
8 years ago

  • Keywords has-patch added; needs-patch removed

#5 @swissspidy
8 years ago

  • Keywords commit added

This ticket was mentioned in Slack in #core by adamsilverstein. View the logs.


8 years ago

#7 @swissspidy
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 37452:

Embeds: Change attachment metadata condition to prevent a warning in the embeds template.

See #35237.
Fixes #36838 for trunk.

#8 @swissspidy
8 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#9 @ocean90
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 37455:

Embeds: Change attachment metadata condition to prevent a warning in the embeds template.

Merge of [37452] to the 4.5 branch.

Props swissspidy.
See #35237.
Fixes #36838.

Note: See TracTickets for help on using tickets.