Removing a video and re-attaching it does not work when CCK options are in use
greg.harvey - June 3, 2009 - 17:55
| Project: | FlashVideo |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | attheshow |
| Status: | needs work |
Description
Hi,
If you switch on managing videos with CCK, after the initial uploaded video and save you cannot change the video it seems. Clicking the "Remove" button against the CCK field appears to work, but the file is not actually removed. The new file is successfully uploaded and processed, but the CCK File Field is not updated, so it continues to show the old video. Same goes for thumbnail.

#1
i'm also having this issue. i want users to be able to get rid of the video, or upload a new one to replace it. googling got me here...hoping someone might have a look...
#2
No response as yet ... I'll try and get time to look at it myself. Seems the new video is uploaded and processed. The issue is the that target CCK field for the processed video does not get updated. Probably something fairly simple to fix, but I'm not familiar with the latest CCK hooks so I'll have some reading up to do before I can look at it. Hence hoping someone else can, because someone who *is* familiar with the CCK hooks can probably fix it much quicker than me! =)
#3
These hooks are something that Mark (attheshow) implemented. I am sure he is away temporarily, but I will make sure I mark this one to be fixed. I might have some time later next week to take a look if he doesn't beat me to the punch.
Thanks,
Travis.
#4
Fantastic - Thanks Travis. I too will take a look if I get time, but unlikely to in that time-frame. De-bugging OG today. Joy! =(
#5
Hey Travis and Mark,
any chance either of you might have a chance to check this out this week? Or anyone else? I love this module, and it has become an integral part of a site I am trying to soft launch this week. Definitely willing to make a donation if someone has the time to get to it in the next couple of days.
thanks!
#6
Hi, I have the same issue. Has someone a solution?
Thanks,
dendie
#7
Just put in a fix for this in the dev version. Please test and let me know how it works.
#8
#9
Check this patch. http://drupal.org/files/issues/flashvideo_delete_0.patch
I posted in http://drupal.org/node/466864
Thanks.
#10
I don't recommend using that patch, by the way. Give the dev version of the module a shot.
#11
Marking it as fixed. Please let me know if anyone finds that the issue is persisting.
#12
Hi,
I don't see any correction. The old video will not be deletet after the uploading and converting of a new one. I tried it with the dev as well as with the rc3 version.
#13
#14
Dear dendie,
It doesn't sound to me like you have the same issue as the one initially outlined. Are you expecting the addition of a new video to remove an existing video?
Could you please outline the steps I would take to reproduce the issue that you're seeing?
-Mark
#15
Hallo attheshow,
thanks for your response.
I have a contetn-type named 'Video'. This content-type is using the fileflield-module to upload a vide. By the great module FlashVideo the uploaded Viedo is beeing converted.
I'm doing the following:
1. I'm creating a 'Video'-content, and uploading an avi-File.
2. I'm starting the cron-job
- The Video is beeing converted an I can watch the video.
- In the filesystem, under 'drupal/sites/default/files/videos_converted' i can also see the two files: video_300.flv and video_300.jpg
3. I'm editing the video-Node and uploading a new video
4. I'm running the cron again
- New video is being convered successfully
- in 'drupal/sites/default/files/videos_converted' apear two new files: cats_303.flv and cats_303.jpg
- but the old two files, video_300.flv and video_300.jpg are stil there!
With FireBug i see also that the tag is showing to the old video_300.flv-file.
So that is my Problem.
My solution for the 6.x-1.5-rc2 version was to insert the following code after the line 1486 in flashvideo.module:
/*
* If they want to remove a file and upload a new one
*/
//Look if the file in filefield is a new one
$cck_table = 'content_type_'. $node->type;
if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) {
$result = db_query("SELECT ".$cck_finished_video_field."_fid, ".$cck_finished_thumbnail_field."_fid FROM ".$cck_table." WHERE nid = ". $node->nid);
}
$r = db_fetch_array($result);
//If its so, remove the old files
if($file->fid > $r[$cck_finished_video_field."_fid"]){
$file_finished = $node->$cck_finished_video_field;
$file_finished = (object)($file_finished[0]);
$file_thumbnail = $node->$cck_finished_thumbnail_field;
$file_thumbnail = (object)($file_thumbnail[0]);
file_delete_by_id($file_finished->fid);
file_delete_by_id($file_thumbnail->fid);
db_query('UPDATE {node} SET status = 0 WHERE nid = %d',$node->nid);
db_query('DELETE FROM {flashvideo} WHERE nid = %d AND status = 3',$node->nid);
}
I know, that this code is just for me, because it's just working for one video per node. There could be other problems as well, I think.
But I hope you can reproduce the issue.
I attach my flashvideo.module to this comment
Thanks
dendie
#16
Could someone reproduce this issue?
#17
I'm not really sure if this is the same issue or not, but it sounds similar.
I'm getting these errors if I try to upload a new video into a cck-field which already has a video in it:
* user warning: Duplicate entry '357' for key 1 query: INSERT INTO content_field_finished_thumbnail (vid, nid, field_finished_thumbnail_fid, field_finished_thumbnail_list) VALUES (357, 357, 796, 0) in /home/nrk/drupal/sites/all/modules/flashvideo/flashvideo.module on line 754.* user warning: Duplicate entry '357' for key 1 query: INSERT INTO content_field_finished_video (vid, nid, field_finished_video_fid, field_finished_video_list) VALUES (357, 357, 797, 0) in /home/nrk/drupal/sites/all/modules/flashvideo/flashvideo.module on line 767.
I'm looking at the code and on line 750:
// Get rid of the initial NULL entry.db_query("DELETE FROM {content_". $cck_finished_thumbnail_field ."} WHERE nid = %d AND ". $cck_finished_thumbnail_field ."_fid IS NULL", $newfile->nid);
If I remove the "AND ". $cck_finished_thumbnail_field ."_fid IS NULL" from that query it deletes the previous entry before it tries to insert the new one and everything works like it should.
But line 750 is already inside the "if ($found == 0) {" part of the code so why doesn't it find my file?
#18
#19
Since there's no actual patch here that needs work, I'm switching the status to "active".
#20
Hi@all,
@attheshow: could you please review this patch?
this patch already includes the patch from #556994: Output directory will not be created, when it does not exists
#21
Hi Guys.
I’ve tried to run the patch and code stuck with error :
“PHP Fatal error: Call to undefined function file_delete_by_id() in /home/drupal_root/sites/default/modules/flashvideo/flashvideo.module on line 1596”
I’ve run the grep 'file_delete_by_id' * -Rn and the function shows only in patch and patched file.
I’m runing flash video 6.x-1.5-rc4 .
Could you give me an advice what to replace the function “ile_delete_by_id” with ?
#22
My fault,
I have used a function I wrote in an other module. This function only deletes a file from the filesystem by its database-id (table files).
#23
Is it another contrib module? You could patch the .info file to make it a dependency if it's in common use.
#24
no, it is not a contrib module. It is just an util-module with useful functions for my project.
#25
I think this patch should correct the bug. It is for the latest dev.
#26
subscribing
#27
@dendie thx for the work.
I’m now overloaded with release on my prodsite and I’ll test the fix as soon as I can.
Meanwhile it is always welcome if there’s anybody who could have look at it.
#28
Tested, it appears to do the trick. +1
#29
OK, one thing the patch in #25 does not do is remove the data from the field that holds the information about the video.
A little background to explain this better:
So, when using cck fields to upload videos, the flashvideo module requires two fields: Field #1 is used for uploading the raw video and Field #2 is for holding the data about the converted video.
If I go in and and remove the video from Field #1, Field #2 still contains all the data about the converted video.
Now, the problem is that if I want a view to display these videos, I'm in trouble. Because the view will show the video in Field #2 even though the user intended to remove the video from the website when he/she clicked on the "Remove" button next to the video.
I hope this is clear.
#31
#32
Subscribing. I am really in need of the filefield option.
#33
When I was troubleshooting regenerating thumbnails, I have found that when you add the field "flashvideo_regen_thumb" taken from here: http://www.travistidwell.com/flashvideo_cck it would remove the converted video AND the thumbnail from the node. Then CRON would pick up this change and re-encode the video and recreate the thumbnail. If I am incorrect please yell at me :). Anyway why not just add a checkbox to regenerate the thumb/video when you want to add a new video? So remove old orginal, upload new orginal, check the box to regenerate the thumb/video and BAM! No need for patch.
-iLLin
#34
This doesn't work for me. I have added 3 CCK fields, and the video and thumb regenerate override fields. (I've tried it in all kinds of variations with those fields) I also have it set to convert immediately. When I remove the video and upload a new one or set a different thumbnail time, then re-save the video, it will regenerate both the thumbnail AND the video (even if I have only changed one or the other) but it will only remove the video or thumbnail I have selected to be changed from the server. If I didn't want to change the video, just the thumbnail, it will regenerate the video anyway and leave the old video floating around on my server unmanaged. I don't mind if it will regenerate the video anyway, since it would be the same video as the original, but it HAS to get rid of the actual old file... And I can't count on my users knowing that they will have to select BOTH boxes to make a clean update.