Problem/Motivation

An 'Unsupported operand types' fatal error occurs when the drupalgram_caption theme is rendered and has no caption.

This error occurs because the serialized value for the caption array is stored as a NULL and when it gets passed to the theme, it can't extend null with the default options.

NULL += array() is what is causing this error in theme.inc.

Proposed resolution

A resolution for this is to make sure that we are passing an array to the theme function.

CommentFileSizeAuthor
#2 empty_captions_cause-2853608-2.patch574 bytesdasginganinja

Comments

dasginganinja created an issue. See original summary.

dasginganinja’s picture

Status: Active » Needs review
StatusFileSize
new574 bytes

The $values variable that get passed into the render function for the caption field handler gets unserialized at the start of the function. When the unserialized data, $caption, has a NULL value we replace that with an empty array to allow core's theme function to extend the data it is expecting.

Ideally we should be correcting the data before it gets serialized so that we don't have to worry about it unserialize to a NULL value but this fixes the current behavior.

dasginganinja’s picture

daniel korte’s picture

  • Daniel Korte committed ea807d9 on 7.x-1.x
    Issue #2853608 by dasginganinja, Daniel Korte: Empty Captions cause...
daniel korte’s picture

Status: Needs review » Fixed

Simplified the patch in commit. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.