Closed (fixed)
Project:
Gallery Assist Upload and Import Helper
Version:
6.x-1.0-alpha1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2010 at 15:44 UTC
Updated:
22 Sep 2010 at 18:00 UTC
I just fixed an older version of Gallery Assist by changing the file_save_upload portion of the code:
if (is_dir($upload_dir) && $node->newfile['name']['pictures'. $i]) {
//if (file_save_upload('pictures'. $i, $validators, $upload_dir, $replace = FILE_EXISTS_REPLACE)) {
$this_file = file_save_upload('pictures'. $i, $validators, $upload_dir, $replace = FILE_EXISTS_REPLACE);
rename($filepath, $new_filepath);
image_scale($new_filepath, $gallery_assist_thumbnail, 80, 80);
if ($conf['use_imagecache'] == 0) {
$thmb_size = $conf['upload_thm'];
image_scale($new_filepath, $upload_thm, $thmb_size, $thmb_size);
$imageinfo = image_get_info($new_filepath);
$my_dim_ref = $imageinfo['width'] > $imageinfo['height'] ? $imageinfo['width'] : $imageinfo['height'];
$prev_size = $conf['upload_prev'];
if ($prev_size <= $my_dim_ref) {
image_scale($new_filepath, $upload_prev, $prev_size, $prev_size);
}
else {
rename($new_filepath, $upload_prev);
}
// Clear the cached filesize and refresh the image information.
clearstatcache();
}
file_set_status($this_file, 1);
The 2 lines referencing $this_file are new. Comment out the if statement and its closing brace.
Thanks to ricky1975 in another thread he tipped off to the fact the GA files uploaded were set with a status of 0, triggering Drupal garbage collection on them, resulting in broken galleries.
After this change, files are now status 1, I ran cron and they were left untouched.
It looks like file_set_status() is in the newer versions of GA, but I know a lot of people are still using older versions experiencing this problem. Hope this helps.
Comments
Comment #1
kevinquillen commentedEdit: I noticed this from 6.x-1.0 to 6.x-6.16
Comment #2
deggertsen commentedI'm a bit confused. I can't find much of the code as you put it above in either version 6.x-1.10 or 6.x-1.15 so I can't figure out what to change. I can find slight variations under "Implementation of hook_save()" but nothing just how you put it above, much of it has "$upl_file->filepath" in there. Are you saying that you replaced everything under the "Implementation of hook_save()" with the code you posted above?
Could you possibly generate a patch and attach it for the current stable release so that I can just apply it and test it?
Thanks for your work on this!
Comment #3
kevinquillen commentedNo I only changed the part where it wrapped the code with the if (file_save_upload(.. part and just assigned $this_file to file_save_upload inside of function gallery_assist_save().
This is an older version of GA (December-ish). Unfortunately I did this editing on the live server so I can't generate a patch right now. I basically searched for 'file_save_upload' and this was the only spot it turned up in GA.
I commented out the if, and added:
Comment #4
deggertsen commentedIt looks like that portion has been changed quite a bit to accommodate Gallery Assist Upload and Import Helper so I think it will need to be modified for more recent versions.
The if statement that you are talking about now looks like this:
And the code inside the beginning if statement of the code you posted looks like:
It looks to me like the newer version is attempting to set the files to a 1 status with "file_set_status($upl_file, 1);" so I assume that what you did only works for the older versions.
Comment #5
kevinquillen commentedYeah, this still happens in the newest version??
Was exactly what was missing in the older versions. The sites I was looking at had 3 different versions.
On the other hand, can it be explained why Gallery Assist needs img/thm/prev and its own foldering structure? Why not just require Imagecache, remove the if/else code regarding Imagecache, lose some of the bloat and whatnot.
If this doesn't stop images disappearing... it -seemed- to work, but it sounds like you are saying it still happens in the newer versions?
Comment #6
deggertsen commentedThat's right. I'm still having the same problem and it seems that others are too according to some of the other issues in the queue.
I agree with you that this module should just require imagecache as it just makes sense for performance reasons and simplicity reasons.
Comment #7
kevinquillen commentedOther than that, I don't see any code at all pertaining to file/image deletion either with GA functions or core Drupal functions (file_delete etc) OR db_query doing anything it shouldn't be doing. Puzzling!
Comment #8
deggertsen commentedI noticed in the database that under the table "gallery_assist_translated" there are less values (267, starting with pid 340) than there are in "gallery_assist_item" (441, starting with pid 1). Shouldn't those two values be the same? Just looking at it briefly it looks like gallery_assist_translated is supposed to have an entry for each "gallery_assist_item". Maybe that gives a clue?
Comment #9
kevinquillen commentedHmmm... Wasn't aware it was turned on. Wouldn't translation happen through t() functions and related modules if that's the case? What is that table for?
Comment #10
FreeFox commentedI downloaded the latest dev version (Today = 2010-07-20) and still the status of the files = 0
Comment #11
kevinquillen commentedIs it missing from gallery_assist_imagecache and gallery_assist_lightboxes etc
Comment #12
deggertsen commentedThere are several duplicate issues of this. Maybe we can all pull together and get this fixed?
#755130: Images from Gallery Assit directory dissapeared
#872828: Once Again, All of My Galleries Have Disappeared
#667732: The loaded photos leave
#640724: Whole gallery is disappeared
#619802: Uploaded original picture files are deleted
Comment #13
Tran commentedThis is a terrific module. If only it would stop breaking.
Comment #14
Tran commentedMy gut tells me it's an issue with Run Cron, because when I was running a poormanscron, it was deleting galleries within hours.
Now, it seems to happen when I update modules, which often involves a run cron.
I've published some more galleries and will test this today.
Comment #15
kevinquillen commentedI think that has to do with the garbage collection removing files that are set as temporary status.
Comment #16
deggertsen commentedThat seems to be the problem. But looking into the code it appears that the files are set to the correct status... Maybe somewhere else that is overridden though?
Comment #17
kevinquillen commentedYeah, thats what I thought I fixed in my original post.
It seems the easiest thing at this point is think about a rewrite. There is a lot of duplicated code, and not a lot of understanding.
Comment #18
Tran commentedJust to clarify.
I build a gallery.
A week later, poof, all the pictures are gone.
However, using FTP, I can see that all my images and thumbs are still in the gallery assist filed with the same name as the node. And when I edit the file, all of the pictures are gone, obviously. However, I can see there's a pager, and if there are 81 files in my FTP file, the pager still recognizes 81 files.
But they simply aren't loading.
Has Juan abandoned the project?
Comment #19
jcmc commentedHello Kevin Quillen, deggertsen, midek
I will only inform you that I'm back.
No midek, I haven't abandoned the project, I was only very "busy" the last months.
The whole time I was trying to find the cause of this issue in the module "Gallery-Assist".
The supposition of deggertsen in #4 is correct. I have never asked the people, which have this problem, if they are using the Gallery Assist Upload and Import Helper module and there is one of the causes (maybe the once).
The function "file_set_status()" which set the status of uploaded files to permanent was added in GA version 1.8-beta2. In GA-UPPORT never, although it is very important.
I am now by developing some requested features, the updates, bug fixes etc and want upload the newest stabile (relative ;-) version as a BETA tomorrow.
Regards and Thanks
Juan Carlos
Comment #20
Tran commentedThanks Juan.
I am anxious to begin reloading galleries but I am afraid to start if the problem is not corrected.
Comment #21
FreeFox commentedHi Juan,
Thanks for the heads-up. I didn't see the new release, have you posted one already?
I guess many people are waiting for the fix and you will make many people happy.
Thanks in advance
FF
Comment #22
jcmc commentedFor the first I change this report to the right module.
Comment #23
jcmc commentedHello all,
I released version 1.0 alpha 1 GA-UPPORT and need testers and feedback concerning to the great theme "Images disappear".
Regards
Juan Carlos
Comment #24
FreeFox commentedJust installed alpha 1. I created a gallery, saved, clicked edit again and got this error:
Fatal error: Call to undefined function gallery_assist_check_access() in xxx/sites/all/modules/gallery_assist_upport/gallery_assist_upport.module on line 99
Greetz
FF
Comment #25
jhans commentedI installed also the alpha and images disappearing. No idea why. Also my already published galleries crashed.
Regards
Joachim
Comment #26
jcmc commentedHello FreeFox,
the error is caused because you need to update to the GA 1.16-alpha1 version.
It is so that with the implementation of the public status settings the new conditions (sub-permissions) are to be checked by the module GA-UPPORT too.
I wrote it just now in the release notes.
Sorry for the late information.
Regards
Juan Carlos
Comment #27
jcmc commentedHello jhans,
I hope this was not in the production server. It is recommended to having a test.server for that. In drupal is a alpha version = test.
Your report give me a idea:
The old version from GA-UPPORT haven't set the file status to 1 and this mean by updates and cron runs the system delete after a determined time all uploaded files with status 0.
I would be grateful if you test to run in your mysql database the statement "UPDATE files SET status = 1 WHERE filepath LIKE ''%files/gallery_assist%".
Is this the solution, I have to integrate it in the next update function.
Can you test it? I have the problem that by my installations or old or new I never got this issue.
I thank you in advance
Regards
Juan Carlos
Comment #28
jhans commentedHi jcmc
Thanks for the reply.
I'll give it a test next week when I am hanging around in a hotel. I have to set that up because I want to bring the website online. By the way I got an error after installing the version saying the node table cannot be found. During the installation I entered a table prefix so the node table has a different name, it's called drupalnode. Here is the error message:
user warning: Table 'db1189643-sccd.node' doesn't exist query: SELECT n.nid, n.title, g.data, p.tpath, p.opath FROM node n JOIN gallery_assist g ON g.nid = n.nid JOIN gallery_assist_item p on p.gref = g.gref WHERE g.uid = 1 AND p.cover = 1 ORDER BY n.created DESC LIMIT 7 in /is/htdocs/wp1189643_SIGGT33CP7/www/sccweb/sites/all/modules/gallery_assist/gallery_assist.module on line 3916.
I like the gallery but I'am playing around now for month. Please help jcmc to get this stuff stable. I am not a developer but if you need help in translation some stuff let me know. The german translation for "public" is "öffentlich" and not "öffentlisch" :-)
Thanks and cheers
Joachim
Comment #29
jhans commentedHi
the bug mentioned in my last post was fixed by myself. Curly brackets where missing for the tables in the SELECT statement starting at line 3885 in the gallary_assist.module.
I have no idea to publish a patch file, so you have to fix it on your site.
Regards
Comment #30
jcmc commentedthanks, I will do that.
Comment #31
FreeFox commentedHi jcmc,
Thanks for your answer in #26.
Today (2010-09-08 15.30 CET) I removed and reinstalled GA and GA-Upport.
gallery_assist-6.x-1.16-beta1
gallery_assist_upport-6.x-1.0-alpha2
When doing an update in Drupal I get this error:
Fatal error: Cannot redeclare gallery_assist_update_1() (previously declared in xxx/sites/all/modules/gallery_assist/gallery_assist.install:473) in xxx/sites/all/modules/gallery_assist_upport/gallery_assist_upport.install on line 18
I checked and you have indeed 2 functions with the same name.
Kind Regards
FreeFox
Comment #32
jcmc commentedups! sorry
copy and paste capital error.
It is now fixed. Please use update alpha 3
Thanks Juan
Comment #33
jcmc commentedTested at http://assist-series.com.