While working on #361446: missing list of signup users inside node which makes nice use of the whole "extra fields" API in CCK to drag + drop signup info to control where on the node it is displayed, I ran into a bug in content_extra_field_weight(). It's a pretty small function:

function content_extra_field_weight($type_name, $pseudo_field_name) {
  $type = content_types($type_name);

  // If we don't have the requested item, this may be because the cached
  // information for 'extra' fields hasn't been refreshed yet.
  if (!isset($type['extra'][$pseudo_field_name])) {
    content_clear_type_cache();
  }

  if (isset($type['extra'][$pseudo_field_name])) {
    return $type['extra'][$pseudo_field_name]['weight'];
  }
}

The problem is that if we hit the case where we need to call content_clear_type_cache(), we leave $type with the same uninitialized values, test it again immediately thereafter, (no surprise) the weight is still undefined, so we return NULL.

The solution is trivial, after we clear the cache, we need to refresh $type...

CommentFileSizeAuthor
#1 363456_content_extra_field_weight.1.patch654 bytesdww

Comments

dww’s picture

Status: Active » Needs review
StatusFileSize
new654 bytes

Patch applies cleanly to either DRUPAL-6--2-1 or the end of DRUPAL-6--2.

yched’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Needs review » Patch (to be ported)

Right, committed to D6 branch. Thanks !

This area has changed quite a bit in D7 (and might still change in the future, for that matter). Not sure if and how this should be foreported.
Moving to D7 as a reminder.

andypost’s picture

is this issue still active?

karens’s picture

Status: Patch (to be ported) » Fixed

This code is in core in D7, nothing to do here.

Status: Fixed » Closed (fixed)

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