Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#51062 closed defect (bug) (wontfix)

Twenty Fifteen: PHP Warning: Illegal string offset 'height'

Reported by: krapanj's profile krapanj Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:


[19-Aug-2020 06:51:02 UTC] PHP Warning: Illegal string offset 'height' in /home2/saxonfou/public_html/krapanj/wp-content/themes/twentyfifteen/inc/template-tags.php on line 125
[19-Aug-2020 07:34:55 UTC] PHP Warning: Illegal string offset 'width' in /home2/saxonfou/public_html/krapanj/wp-content/themes/twentyfifteen/inc/template-tags.php on line 124

Attachments (1)

51062.diff (742 bytes) - added by Hareesh Pillai 3 years ago.

Download all attachments as: .zip

Change History (8)

This ticket was mentioned in Slack in #themereview by carike. View the logs.

3 years ago

#2 @carike
3 years ago

  • Component changed from General to Bundled Theme

#3 @carike
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Someone from our Themes team tried to replicate this on a test setup, but could not re-create the error.
I'm going to ask that you please post on the Support Forums over here:
If it does turn out to be an issue in the bundled theme that can be replicated, this issue can always be re-opened.
All the best!

#4 @SergeyBiryukov
3 years ago

  • Resolution changed from maybelater to worksforme
  • Summary changed from Twentyfifteen errors to Twenty Fifteen: PHP Warning: Illegal string offset 'height'

#5 @carike
3 years ago

Just want to link to the Slack conversation here:

Also an extra check before accessing the array would still be good to get added there even if this can't be replicated in a normal install. Defensive code is never a bad thing in these situations.

Will re-open after the weekend :)

@Hareesh Pillai
3 years ago

#6 @Hareesh Pillai
3 years ago

  • Keywords has-patch added
  • Resolution worksforme deleted
  • Status changed from closed to reopened

Attached patch 51062.diff checks if the offset is set, else falls back to 0.

#7 @desrosj
3 years ago

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

Welcome to Trac @krapanj!

I've been looking this over, here are ways that this issue can be reproduced:

  • A function hooked onto wp_get_attachment_metadata that removes the width index.
  • The width index missing from the _wp_attachment_metadata post meta key for an attachment. This would only happen if the wp_generate_attachment_metadata filter is used to remove the width index.

However, both of these scenarios are, in my opinion, "wrong" ways to alter an attachment's metadata.

Core documents that wp_get_attachment_metadata() returns an array with width, height, file, sizes, and image_meta indexes. Any function hooking into the filters above removing these core indexes will likely result in problems.

If a check is added for the height and width indexes here, it would "mask" the problem, making it extremely difficult to debug what is happening. Removing any of these indexes is also likely to cause issues elsewhere in the default WordPress Core behavior. So hiding the notice is not ideal.

@krapanj it's likely you have a plugin (or potentially code within a child theme) that is using one of the above hooks to alter the metadata as described. I recommend trying to find the code responsible and submitting a ticket to that plugin, or correcting the code in your child theme if that is your current set up.

If you're unsure how to do that, you can open a ticket in the support forums for some more guidance. You can reference this issue and my explanation above to help give the amazing volunteers full context.

Note: See TracTickets for help on using tickets.