As reported here if I activate a new field and I try to add it to a previously created Content Type it doesn't appear in the list unless I don't edit and save the content type itself (no real changes are needed). This looks more a usability problem than a real bug but could be confusing. Maybe it's a cache problem I don't know...

CommentFileSizeAuthor
#11 content_admin.inc_2.patch690 bytesyched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dodorama’s picture

Status: Active » Closed (duplicate)
yched’s picture

Status: Closed (duplicate) » Active

this one is actually clearer (plus it's the first report for the issue)

drewish’s picture

you need to clear the cache. the devel module makes it easy to do this.

drewish’s picture

sorry, should have read this more clearly.

KarenS’s picture

Priority: Minor » Normal

I just ran into this on a new install where some cck fields were installed already and then another one was added. The usual recommendation for clearing the cache (go to the modules page and save it) did nothing to help the problem, the new field still would not appear on the list. You either have to manually empty the cache table (something most users cannot do) or save the content type to get the field to appear.

So it looks like we need to be sure to clear the field list cache when a new module is added. I couldn't figure out exactly where to do that, but maybe someone else can.

I'm upping this to normal -- it's *really* confusing when you install a new module and it doesn't appear on the list.

dodorama’s picture

Yeah, many people facing this problem believes they have problem with contributed modules. Is that possible to mark this as annoying? :)
@karen (and all CCK contrib modules developers). Maybe to avoid people submitting issues because of this it could be useful to put a warning on module homepage and readme.

yched’s picture

marked http://drupal.org/node/85977 as a dupe

This _is_ annoying in fact :-)

RobRoy’s picture

So to automate this do we just need some sort of cache_clear() call in each CCK contrib module's hook_install()? Installing devel and clearing the cache is obviously not a proper solution.

yched’s picture

Yes, something like cache_clear('content_type_info');, probably

yched’s picture

Er, wait, probably rather a call to content_clear_type_cache();, actually...

I don't know much about hook_install, so I don't know exactly what you're allowed to call in there, or what is available.

yched’s picture

FileSize
690 bytes

OK, I gave it a closer look.
Problem is, to be consistent, we have to clear the cached content types info on a field module install AND uninstall (because of the symmetric less-talked-about but related issue : "newly desactivated fields still appear etc...")

But 4.7 doesn't offer an _uninstall hook (5.0 does...)

So I came up with another approach : delete the cached info when the "add_field' form is displayed.
I has the advantage of being a simple 3-line addition to content_admin.inc, no per-field-module patch needed.

Patch for 4.7 (I think 5.0 would offer a more elegant solution for the $_POST['edit'] check)

yched’s picture

Status: Active » Needs review

Forgot to set the status
Plus we have another dupe for this :-) http://drupal.org/node/86378

yched’s picture

bump - this could use some reviews - and save much unnecessary support requests :-)

KarenS’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm this works. I tested without the patch to add and remove a field and got the previous behavior (it showed up when it shouldn't and didn't when it should). I then applied the patch and tested both adding and removing a field and the field list displayed properly.

Thanks yched! I'm marking this RTBC.

KarenS’s picture

Status: Reviewed & tested by the community » Fixed

I've committed this change to both 4.7 and cvs. If someone comes up with a more elegant solution for the 5.0 version, we can make that change, but this is a critical bug and this fix will work, so I'm committing it.

Anonymous’s picture

Status: Fixed » Closed (fixed)