I updated from the Sept. 15th to the Sept. 29th version and don't get any output out of the module since then. I found that when I move the _computed_field_compute_value() function back from the 'load' hook to the 'view' hook it will work again.

This is of course not a nice solution, because I'd very much like to be able to use stuff during the 'load' phase. Strange....

CommentFileSizeAuthor
#9 computed_field.87619.patch501 bytesyhager

Comments

wrunt’s picture

Have you tried updating to the latest 4.7 version of cck?

pgassner’s picture

Category: bug » support
Priority: Normal » Minor

I'm using the CCK released on Sept. 19th for Drupal 4.7

I just tried it again and it seemed to work even without my modification. Now, that is a strange thing, because I didn't change anything during the night - could this be a cacheing problem? It seems like it because several hours passed since I last loaded the page and now it works. When I updated the code to the 9/29 version yesterday the output disappeared immediately, when I switched it back, the output was there again.

I'm not really sure, how the drupal hook system works internally, but I could imagine it cacheing module hooks. I tried to disable and enable computed_field, as well as the content module, though, so everything would get loaded again - and it didn't help then.

Another possibility could be the contemplate module. Enabling and disabling it didn't make a change, but maybe it cached something that I didn't want it to. At the moment it is enabled but I haven't changed its template.

I'd be very interested to hear what you think of this situation, whether it could be a cache thing on the Drupal, CCK, contemplate side or whether this is a silly server or whatever.

Thanks!

pgassner’s picture

Category: support » bug

Now, I don't know whether I want to much from this module or whether this really is a bug.

I'm trying to use the computed field to gather information from other content_types and can't really get it to work the way I want it to without having the _computed_field_compute_value function in both the «load» and the «view» hook. If it's only in the «load» hook the fields' contents do not update unless I edit and save the node. This seems to make perfect sense to save DB-queries, but in my situation it doesn't work: another content_type could be updated and this should be reflected here.

To me these problems seem to have the same source that's why I still post this in this bug report.

zacherbaugh’s picture

Priority: Minor » Normal

pgassner, I don't think you're asking too much! The documentation in the README.txt and on the project page says this:

If this [ie. Store using the database settings below] is checked then the field is computed on node save and stored. If it isn't stored then it will be recomputed every time you view a node containing this field.

which the behavior that you, I, and this user are looking for.

I've been trying to reproduce the fix you described in #3 involving adding a _computed_field_compute_value call to the «view» hook, but so far I get duplicates of my data (one updated correctly, one not). Can you post a code snippet of the computed_field_field function? It would be helpful to me, and also might help wrunt to fix this.

and wrunt, thanks for an excellent module!!

zacherbaugh’s picture

I;'m still trying to get this to work as advertised. I'm using the version updated 27 Nov. 2006. In looking at the changelog, I find this:

29th September 2006
...
* Made non-stored computed fields compute on load, rather than view.

which would appear to directly contradict the project page as cited in #4.

Here's how I've hacked the «view» hook in computed_field.module to make non-stored fields compute on view (only one line was added):

/**
 * Implementation of cck hook_field
 */
function computed_field_field($op, &$node, $field, &$node_field, $teaser, $page) {
  switch ($op) {
...
    case 'view':
      if ($field['display']) {
        if (empty($node_field)) {
          $node_field[0]['view'] = content_format($field, $node_field[0], 'default', $node);
        }
        else {
          foreach ($node_field as $delta => $item) {
// The next line was added to make non-stored fields recompute on view
            _computed_field_compute_value($node, $field, $node_field);
            $node_field[0]['view'] =  content_format($field, $node_field[0], 'default', $node);
          }
        }
        return theme('field', $node, $field, $node_field, $teaser, $page);
      }
      break;
...
  }
}

To make this work properly, I also have to be sure that the field is cleared out before use in any computed code (ex. $node_field[0]['value'] = "";); otherwise, I get multiple copied of the computed result.

f.mardini’s picture

Hi,
I am having issues here as well.
I don't even get the computed field to appear in the form for creating the node (it is also not displayed in the view).
I am using drupal 5 with the latest CCK

denegen’s picture

Version: 4.7.x-1.x-dev » 5.x-1.1
Priority: Normal » Critical

Using Drupal 5.1, CCK 5.x-1.4 and Computed Field dated 2006-Nov-27.

No output is given in a view or edit page. It looks like no hook functions from the module are called at load or view.

Anonymous’s picture

+1

yhager’s picture

StatusFileSize
new501 bytes

I believe that this happens because the function computed_field_field_settings() does not handle correctly the case where it is called with $op='callbacks', as documented in hook_field_settings() on cck/field.php.

Patch attached.

yhager’s picture

Status: Active » Needs review
wrunt’s picture

Assigned: Unassigned » wrunt
Priority: Critical » Normal
Status: Needs review » Fixed

Thanks yhager, I've added your change to cvs, but it seemed to work for me even before making the change.

Anonymous’s picture

Status: Fixed » Closed (fixed)
rubenk’s picture

Version: 5.x-1.1 » 5.x-1.2
Status: Closed (fixed) » Active

Even after this patch looks like it was rolled into release 5.2 I have problems where

I use the code provided to link back to the node.
I set the field to "display raw text in the content type field settings for my given content type.
When i PREVIEW a submitted node, it WORKS, I see the link back to the node BUT
When I submit it and view the node after submittal it's GONE.

MAGIC? I opened this back up because it seems related. Strange Behavior. I am fully up to date with
Computed Field 5.x-1.2
Content Construction Kit (CCK) 5.x-1.6-1

Zoologie.de’s picture

Same here no output. no field no nothing although it pretends to be there :/

CCK 1.6 and computed field downloaded today :/

Ckicked display field did store in data base, tried to add to a group ... nothing ... :(

sin’s picture

Try latest patch at http://drupal.org/node/134661
Works for me.

deekayen’s picture

5.x is unsupported. re-open for 6.x if applicable

deekayen’s picture

Status: Active » Closed (won't fix)