Download & Extend

Removing a video and re-attaching it does not work when CCK options are in use

Project:FlashVideo
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:attheshow
Status:needs review

Issue Summary

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.

Comments

#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

Version:6.x-1.5-rc2» 6.x-1.x-dev
Status:active» needs review

Just put in a fix for this in the dev version. Please test and let me know how it works.

#8

Assigned to:Anonymous» attheshow

#9

#10

I don't recommend using that patch, by the way. Give the dev version of the module a shot.

#11

Status:needs review» fixed

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

Status:fixed» active

#14

Status:active» postponed (maintainer needs more info)

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

AttachmentSize
flashvideo.module.txt 110.61 KB

#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

Priority:normal» critical
Status:postponed (maintainer needs more info)» needs work

#19

Status:needs work» active

Since there's no actual patch here that needs work, I'm switching the status to "active".

#20

Status:active» needs review

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

AttachmentSize
flashvideo.patch 2.34 KB

#21

Version:6.x-1.x-dev» 6.x-1.5-rc4

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

Version:6.x-1.5-rc4» 6.x-1.x-dev

I think this patch should correct the bug. It is for the latest dev.

AttachmentSize
flashvideo.patch 2.88 KB

#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

Status:needs review» needs work

#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.

#35

Dendie #25
The patch is not working on cvs dev flashvideo revision 1.73.2.114.
The cvs flash.video module stop at line 1187 while the fix is trying to patch line 1579.
Could you please tell me what cvs version did you use ?
Thx

#36

Steve Dondley #28 you mention that it works for you. Can you tell me what’s your cvs version ?

#37

To Comment #34, it only works on cron. You basically que it up, doesn't matter if you have the option to convert immediately, that option doesn't work on edit.

#38

@lamachine_fr:

// $Id: flashvideo.module,v 1.73.2.112 2009/08/16 22:08:30 attheshow Exp $

#39

Can’t get work the patches on flash module stable release.

Code should be placed in the condition that trigger db and files cleaning. The condition is evaluating “$node->$cck_original_video_field['field_name']” and “$node->$cck_finished_video_field['field_name']” in flashvideo.module line (1555). flashvideo 6.x-1.5 2009-Dec-27 .

Both variables are evaluated by function count. The function return always 1, in both cases, if the attached file has been deleted or not, the code after the condition is not triggered in any cases.

IMHO this is the reason that the associated flv and thumbnail files are not deleted.

#40

I have the same problem and it works great, when you delete this condition.

So it checks every time for deleted files, not only when count changed.

So here a little patch, which delete this condition. The code inside this condition checks if a file is really deleted, so it works fine, without that condition.

AttachmentSize
flashvideo-481116.patch 1.73 KB

#41

@kfritsche thx for going through.
Taking off the condition does the trick.

For those who need to check out:

Files to be deleted while removing / reattaching video:
sites/default/files/thumbs/filename.jpg
sites/default/files/flv/filename.flv
sites/default/files/video/filename.wmv

Server side checking:
find sites/default/files/ -name \*filename\* -type f

DB side checking :
SELECT * FROM `files` WHERE filename LIKE "%filename%";
SELECT * FROM `flashvideo` WHERE nid = node_id

#42

1. When uploading an MP4 or FLV file remains listed on edit node page, but does not show up when viewing the node.
2. When uploading an avi, wmv, mpeg, etc, the video shows up when viewing the node, but does not get listed when you are editing the node.

Both issues occur when using single file upload.

I've downloaded the dev version and applied the patches from #25 #40

I've attached a patch that corrects both issues.

AttachmentSize
flashvideo.patch 5.82 KB

#43

I have started working on a patch and so far have a simple one that fixes 'remove original video', whereas before the converted video and thumbnail fields would remain after removal. So now I can remove the original then later upload a new video which will convert.

AttachmentSize
flashvideo-remove.diff 1.38 KB

#44

If you have problems with file field integration check this http://drupal.org/node/807882
There are examples and podcasts how to use it.

#45

I have a working patch for this bug and several other bugs in Flashvideo when using CCK filefield.

The bugs fixed are:
- removing the original video leaves thumbnails/converted video
- can't remove a video and upload a new one in a single node save operation
- indices (video_index) above the removed video won't get fixed except for the first one (also optimized by only doing a single sql query)

AttachmentSize
flashvideo-remove-cck.patch 4.69 KB

#46

I tested tomotomo's patch and everything seems to be working.

#47

I tested this patch and it corrected the errors I was seeing when I removed a video using the CCK field.

I did notice that after a video is removed, there is still a link to

Transcode video_MIA.png with FFmpeg

where the placeholder image filename is still there from a failed image generation.

Not sure if another patch is needed, I'd be fine with adopting this one as is.

#48

"RTBC" - anyone?

#49

attheshow? Let me know if there's any issues with my patch.

#50

+1 for tomotomo's patch

#51

Status:needs work» needs review

Ugh, it needs to be set to "needs review" if you want attheshow to notice it!

#52

Patch works just fine for me - thanks a lot!

#53

Experiencing this issue. CCK single video uploads can not be updated. Adding new video produces the following thumbnail error

* user warning: Duplicate entry '173' for key 1 query: INSERT INTO content_field_thumb (vid, nid, field_thumb_fid, field_thumb_list) VALUES (173, 173, 385, 0) in /var/www/html/blackdiamond/sites/all/modules/flashvideo/flashvideo.module on line 758.
* user warning: Duplicate entry '173' for key 1 query: INSERT INTO content_field_flash_video (vid, nid, field_flash_video_fid, field_flash_video_list) VALUES (173, 173, 386, 0) in /var/www/html/blackdiamond/sites/all/modules/flashvideo/flashvideo.module on line 777.

Thumbnail and video are successfully created but the node is showing the old values.

This happens on cron conversions as well as immediate conversions.