The flag form element is defined as 'flag' in flag_content_extra_fields($type_name):

$extra['flag'] = array(
      'label' => t('Flags'),
      'description' => t('Flags fieldset.'),
      'weight' => 0
    );

...but the flag weight is called in flag_form_alter() like so:

 if (count($flags)) {
      $form['flag'] = array(
        '#type' => 'fieldset',
        '#weight' => module_exists('content') ? content_extra_field_weight($form['#node']->type, 'flags') : 1,
        '#tree' => TRUE,
        '#title' => t('Flags'),
        '#collapsible' => TRUE,
      );
    }

which causes content_extra_field_weight() to always fail here:

  // 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])) { 
    //the above looks for "$type['extra']['flags']" instead of "$type['extra']['flag']" (the value that is actually set)
    content_clear_type_cache();
    $type = content_types($type_name);
  }

which eventually causes nukage of cache_content in cache_clear_all(), and that seems bad :).

Apologies if I'm missing something, I'm not very familiar with cck internals.

Thanks!

Comments

cfennell’s picture

StatusFileSize
new515 bytes

Attaching patch that calls 'flag' instead of 'flags'.

emmajane’s picture

Status: Active » Reviewed & tested by the community

Patch applies cleanly to 6.x-2.x branch.

quicksketch’s picture

Title: calling 'flags' instead of 'flag' in content_extra_field_weight() always triggers content_clear_type_cache(); » Calling 'flags' instead of 'flag' in content_extra_field_weight() always triggers content_clear_type_cache();
Status: Reviewed & tested by the community » Fixed

Yay thanks guys. Committed to 6.x-2.x branch. Same problem does not appear in the 7.x-2.x branch.

cfennell’s picture

Excellent, thank you!

Status: Fixed » Closed (fixed)

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

joachim’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)
joachim’s picture

Issue tags: +Novice

1.x is no longer supported, though I'll leave this open for a bit more as there's a patch here.

If someone ports this I'll commit & make a final 1.x release.

cck’s picture

Assigned: Unassigned » cck
StatusFileSize
new587 bytes

6.x-1.x patch ported from flag-content_clear_type_cache-1469442.patch

joachim’s picture

Status: Patch (to be ported) » Needs review

Thanks!

Let's fire up the testbot...

joachim’s picture

Status: Needs review » Fixed

Committed!

Issue #1469442 by cck, cfennell, emmajane: Fixed calling 'flags' instead of 'flag' in content_extra_field_weight() always triggers content_clear_type_cache().

I'll roll a 1.5 release with this and then we will consider the 1.x branch closed.

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