Using PHP-text option, new nodes won't create proper text from $title.

BUT, if I edit the PHP-text-code and change my varible once from placeholderx to placeholdery, the new node that generated a non functional Image, now generates a proper text. But if i make a new node again, it won't work and I have to reset the PHPcode with a new varible name again... ?

This is only on $title, and not on my body-code...

The PHP-code in question:

TITLE

foreach ($image_context['referring_entities']['field_wordimage']['node'] as $nid => $node) {
  $titlexqx = $node->title;
}
return $titlexqx;

BODY

foreach ($image_context['referring_entities']['field_wordimage']['node'] as $nid => $node) {
  $other_field_value = $node->body['und'][0]['value'];
}
return $other_field_value;

Is my PHP code wrong somehow or is it an issue with imagecache Actions?

Please advice!!

BR,
Max

Comments

dman’s picture

It working the second time is likely to be due to imagecache flushing all derivatives when the rule is changed. It may be that making no change at all has the same effect.

Why it's not working the first time MAY be a race condition (just guessing here) that the data about the new node is *not available yet* when the node is first saved.
Imagecache changed in core 7.20 to do some silly things with image generation, and it MAY BE that the derivative is getting built for you before the node is fully saved. That makes the 'referring entities' unavailable at that instant.

To test that, do you get the same problem if
* creating a node. Save once
* edit the node and add an image. The node data may be more persistent in this case.

Just an OTTOMH guess right now. To dig further, I'd start logging data into watchdog or something from your custom code.

MxRhd’s picture

Ok, thank you, I'll look around.

So it's not my PHP-code that's in a bad format?

MxRhd’s picture

Status: Active » Closed (fixed)

Hmm. Turns out that when I disable "Enable GraphicsMagick support", this error goes away.

Thank you for nudgeing me in the right direction and sorry to blaim the module when it was a configuration error!