Hi,

I have a content type with an image field which uses FileField path. I have also enabled the revisioning module. Users are allowed to upload an image but that node will not be published until a moderator publishes that revision.

My problem is, when a user saves a node after removing an existing image and uploading another image(which will be a pending revision), it removes the image attached to the published revision from the server. Since the image attached to the published revision is missing, it gives the error 'Warning: array_key_exists() expects parameter 2 to be array, null given in theme_image_formatter()' . I use this image in few views and because of this issue there are errors in the website.

We are about to go live and this is a serious problem. Please help me to fix this issue. I removed filefield paths option from this image field to check if the problem still exists but it worked fine even the user removed and uploaded files. I need to maintain a file structure for every user so I don't want to get rid of this module. Any help would be very much appreciated.

Thank you.
lavms

Comments

Deciphered’s picture

The best thing you can do to receive prompt help on an issue like this is give me some way to reproduce it, like access to a pre-prepared sandbox where I can see the issue and debug the code.

I'm happy to give you paid support if it's super urgent, but otherwise it can only be when and if I have spare time and the motivation to look into it.

lavms’s picture

Hi Deciphered,
Thank you very much for your quick reply. At the moment I don't have a pre-prepared sandbox for you to test. Could you please check if the following steps would-recreate the issue?
1. Install and enable Revisioning and File (Field) Paths modules
2. Create a new content type with an image field.
3. Edit the content type and set the publishing options as follows
a) Uncheck the published check box and check only the 'Create new revision', and 'New revision in draft, pending moderation (requires "Create new revision")' check boxes
b)Under New revision in draft, select the first option, 'Only when saving test_content content that is not already in draft/pending moderation'
c) Check 'Auto-publish drafts of type test_content (for moderators)' as well
4. For the image field, Enable File (Field) Paths and give a file path and a file name.
5. After saving the new content type, you'll have to create a user who can create and edit this content type and log in as that user to create a new content. Once that user creates a new content, it will be a pending revision and a moderator has to publish that content.
6. If you check for this image file in the server, you'll see the first image our user just saved, image.jpg.
7. Once the moderator publishes the revision, our user should edit the content and remove the existing image to upload another image. once the user saves the content, check the server again and notice the previous image has been deleted. It's wrong to delete the previously uploaded image in my case as that image is still being refereed by another view until the new revision becomes 'published'.

Sometimes step 7 has to be repeated twice or more to re-produce this error.

Please let me know if you couldn't re-create this. I will talk to my manager regarding the paid support.

Regards
lavms

lavms’s picture

Hi Deciphered,
Can I have your email address to discuss about the charges and other things?

Thank you.
Regards
lavms

Deciphered’s picture

Just contact me via my D.o contact form.

lavms’s picture

Excellent. Thank you.

LTech’s picture

was there a fix for this?

neRok’s picture

Issue summary: View changes
Priority: Critical » Normal
Status: Active » Closed (cannot reproduce)

I have just tested this out with all latest versions, and everything works as it should. No files are deleted for any revision (old, pending or new), and if you upload a file with the same name, it has _0 appended (as per core).

I wonder if this was actually a core bug that was fixed at some stage.

coolkind’s picture

Status: Closed (cannot reproduce) » Active

Problem still exist in Drupal 7.27 what I am using:
Here is the reproduce steps:
1. Create a node with a file field and upload one file; At this time go to file_usage table, you can see the count of file is 1;
2. Edit the document;
3. Remove the original file and upload another file;
4. Before the save, please check "create a new revision" under revision options;
5. Save.
6. Check out file_usage table, original file is gone and the count of new file is 2.

The root cause is field_attach_update within function filefield_paths_entity_update(). I thought it is not appropriate to use field_attach_update for revision stuff.

liquidcms’s picture

possibly somewhat related; but the plup module when used with this module causes this issue.

plup is a drag/drop widget for image field.

when adding images they get saved correctly both in db and to correct folder as defined by file field paths definition. when editing and re-saving the files are moved to root file folder and db entry in files_managed becomes screwed up.

Deciphered’s picture

Status: Active » Fixed

Based on #8, issue was fixed with fix in #1481260: Duplicate entries in in forum_index table.

Status: Fixed » Closed (fixed)

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