computed_field_field should compute on $op='presave'

matt2000 - March 26, 2009 - 00:59
Project:Computed Field
Version:6.x-1.0-beta2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

This implementation of hook_field currently calculates on $op = 'insert' or 'update'.

Computing on 'presave' instead allows for token replacements to occur.

I had to make this change when using auto_nodetitle module with multiple computed_fields in the title string.

#11

Moonshine - May 20, 2009 - 16:52

Interesting... while I think this change should be fine, I'd like to run a couple questions by yched first. So this one is pending a couple answers.

#14

andreiashu - June 26, 2009 - 10:02

I got here because I have the same problem with Computed Field tokens and auto_nodetitle.
Thanks for the fix matt, even if it is not approved yet :)

Cheers !

#24

what4software - July 15, 2009 - 10:56

I understand the fix but I cannot get it to work for me. After I change the code all I get is a blank page after hitting save.

I changed the following:
FROM

case 'insert':
case 'update':
  _computed_field_compute_value($node, $field, $node_field);
break;

TO
case 'presave':
  _computed_field_compute_value($node, $field, $node_field);
break;

Did I miss something? I am using computed_field 6.x-1.0-beta2 with token 6.x-1.12

Thanks

#25

andreiashu - August 11, 2009 - 10:19

Just wanted to give some feedback about this approach: we applied the "patch" and everything works as expected. I have this on a live website.

@what4software, that is because you did it wrong :)
From

case 'insert':
case 'update':
  _computed_field_compute_value($node, $field, $node_field);
break;

It should be:
case 'insert':
case 'update':
case 'presave':
  _computed_field_compute_value($node, $field, $node_field);
break;

#26

andreiashu - August 11, 2009 - 10:24

And here is the trivial patch against the latest beta3.

AttachmentSize
computed_field_on_presave.patch 415 bytes

#27

andreiashu - August 11, 2009 - 10:25
Status:active» needs review

Updating the status so maybe we can get some maintainer feedback.

#28

rpmute - August 14, 2009 - 13:50

patch is good for me too.

#29

GeraldMengisen - August 28, 2009 - 21:24

Patch works for me, too (had the same problem with auto_nodetitle, token and one single computed field in the title)

#30

csc4 - August 31, 2009 - 11:34

Subscribing

#31

memfis - October 11, 2009 - 15:45

Subscribing.

#32

trupal218 - November 2, 2009 - 06:16

patch was successful for me as well - thanks for the great work!
i'm glad i came across this thread

#33

netbear - November 2, 2009 - 07:49

May be this patch will solve the problems like described in this topic: http://drupal.org/node/350404

#34

matt2000 - November 2, 2009 - 17:21

I don't have access from my current location to my original code to check how I did it before, but I'm wondering if having both case 'insert' and case 'presave' is redundant?

 
 

Drupal is a registered trademark of Dries Buytaert.