When entitycache is enabled fields are being duplicated, due to the field_attach_load call in closedquestion_load.

Duplicate this issue by
- enabling closedquestion & entitycache.
- create a question.
- attach a file to it.
- save the question
- edit the question and save it again.

you should now have 2 file attachments to the node instead of 1, if you continue the edit/save step attachments will increase by a factor of 2, so 1, 2, 4, 8, 16 etc.

I am wondering if it is even the right place to attach the $node->question "field", I don't have an alternative to where this should happen instead of now.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lslinnet’s picture

Looking at the hook_load function i saw that some of the code could be optimized away.
So create a little patch for that.

lslinnet’s picture

Found a way to fix it, moved the functionality from hook_load to hook_node_load which basically resolves the issue.
Haven't tested this when loading multiple nodes yet, so would love if someone had the time to do so.

lslinnet’s picture

Status: Active » Needs review
Issue tags: -bug fix

Ohh forgot to change status

jbrown’s picture

FileSize
1.79 KB

Okay - this patch fixes the bug by loading the body field on a clone of the node. I incorporated the fix in #1 also.

This module really needs to be refactored to use entities properly.

lslinnet’s picture

Hey jbrown, have you taken a look at the solution provided in #2?

jbrown’s picture

FileSize
1.74 KB

Okay - improved upon the patch in #2. You can't use reset() like that because you get a strict warning.

HylkeVDS’s picture

It's very likely that the way loading is done is not entirely correct. I wrote that code against one of the first releases of D7.
The problem was that the automatic loading happened way to late in the process.

The loading of attached files might also have to happen sooner than default.

lslinnet’s picture

I have tested and reviewed the rewritten solution from jbrown and it works.

lslinnet’s picture

Status: Needs review » Reviewed & tested by the community

Forgot to change status.

koosvdkolk’s picture

Assigned: Unassigned » koosvdkolk
Status: Reviewed & tested by the community » Active

Will apply patch of #6 a.s.a.p.

koosvdkolk’s picture

Status: Active » Needs review

This should be fixed in the 7.x-2.x-dev i just pushed. Please review.

spazfox’s picture

Status: Needs review » Needs work

I'm having compatibility issues with Closed Question 7.x-2.2 (which appears to include the patch from #6) and Entity Cache, as well, though my specific issue appears to be different from the one originally reported here. I can create a separate issue if that is preferable, but decided to post here since a compatibility issue between these two modules seems to remain.

When Entity Cache is enabled, the fields/body of my Closed Question nodes are often not rendered at all (the Submit and Reset buttons are rendered, however), and these error notices sometimes (but not always) appear: "Unknown node: inlineOption" and "Unknown node: mapping"

Disabling Entity Cache resolves the issue. Clearing all site caches or re-saving the node also resolves the issue, but only temporarily.

Let me know if there is any additional information or testing I can do to help troubleshoot this.

koosvdkolk’s picture

Created a bug report for Entity Cache: http://drupal.org/node/1971666

"Unknown node: inlineOption" and "Unknown node: mapping"

are probably caused by the Closed Question editor.

  • koosvdkolk committed 4248ace on varexport
    Issue #1415100 by lslinnet,jbrown: Fixed fields being duplicated when...