I was in the process of working on our GHOP task to create simpletests to test the db changes. I decided to write it up using the D5 version of CCK, then go and make sure it would work in the D6 version, but in the process found a problem that exists in D5 and D4.7 that we should address.

Basically the GHOP task is to make various changes to the field structure, then test the results in various ways. One of the tests is to do a node_load() on affected nodes to check that the values have changed. So if you add fields to a node and save it, then come back and remove the fields *without editing the node at the same time* a node_load() done on that node will still contain the fields that were removed. This is because that node is cached and we didn't clear the cached value. Doing an actual node_load() and node_save() on each affected node will clean things out, as we are hoping to do in D6, but without doing that, we have nodes in the cache that are in various states of mismatch with the current database schema and values.

My best though right now is to make content_clear_type_cache() more aggressive and have it clear cache_content completely, wiping out all the cached content values to force node_load to get a fresh copy.

Thoughts??

Comments

KarenS’s picture

Edit the previous comment, doing an actual node_load() and node_save() on each node will *not* clean things up if the node_load() brings up the stale values. We have to zap the cache, either finding the nodes that might be affected and zapping them individually, or zap the whole thing.

Or we could have a middle ground. If we add the node type to the cid, we could zap all nodes for a type and at least preserve values for other types.

KarenS’s picture

Status: Active » Fixed

And there is a somewhat related problem, there is no call to content_clear_type_cache() when fields are removed from content types. That's an oversight. The content type cache is cleared when they're added or changed and should also be cleared when they're removed.

I am committing two changes for now -- adding the call to clear the content type cache when fields are removed and wiping the content node data from the cache when fields settings change. We can make changes later if we find a better way to do that.

Making this change in D5 and HEAD. D4.7 doesn't have a function to empty the cache completely, so I just left it.

yched’s picture

Right, good catch. It's surprising this has gone unnoticed for so long...
Adding the node type to the cache cid sounds like a cool idea.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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