Needs review
Project:
Media Browser Plus
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
19 Sep 2011 at 18:44 UTC
Updated:
29 Apr 2013 at 06:44 UTC
Jump to comment: Most recent file
From git://github.com/Buesing-Sebastian/Drupal---Media-Browser-Plus.git
This is nice, if directory structure is movable. But after moving, need to batched update all of media objects in directory. The phisical move is ok, but the $file->uri and $file->field_folder values leave original after moving.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | move-files-with-file_move-1284216-21.patch | 11.15 KB | jamesharv |
| #15 | moving-folder.patch | 4.15 KB | camdarley |
| #14 | moving-folder.patch | 4.16 KB | camdarley |
| #11 | 1284216-11-move-files-with-file_move.patch | 4.16 KB | camdarley |
| #4 | 1284216-4-Add-batched-update-when-folder-is-moving-on-folder-e.patch | 4.38 KB | szantog |
Comments
Comment #1
Sebastian.Buesing commentedI'll have a look at this tomorrow ;-)
Comment #2
Sebastian.Buesing commentedPatched it on github. Update your rep and change the name of the top folder. This does update all files of the subfolders as well ;-).
I tested it a couple of times, but if you run into any problems please post them here immediatly ;-)
Comment #3
szantog commentedGreat, thanks! I've tested a lot, and it works when edit the folder. But when move in tables admin/content/media/folder_list not yet.
I fixed it. I moved the batch pocess set method to own function as media_browser_plus_folder_update_set_batch($folder), and call it in media_browser_plus_folder_save_folder() and media_browser_plus_folder_list_submit() too
Comment #4
szantog commentedYeepp I've created some shit..
Comment #5
gregbeat commentedFirst off, this is an AWESOME improvement to the default library. Hats off to Sebastian.
I am having a similar issue. In addition, I've added ALT and TITLE tags for my images with media edit fields, and if I attach an image to a node, and then go into the admin/content/media interface and move an image between folders or update the ALT/Title tags, and then go back to my node I have to re-save the node to get the new location URI or ALT/Title Tags. (Or I can go to performance/clear cache to refresh values).
I tried sznatog's path at #4, but it did not fix it for me... but maybe this is a bit different?
UPDATE
after checking the DB directly after making changes, the DB values are all updating as expected. I'm going to look into another method to get my page values to update. This module is working for everything I need it to do.. Good Job!
Comment #6
Sebastian.Buesing commentedI'm not sure how you attach the image to your node, but usually it's done by just adding the fid (file id) and on display it loads the file and the correct URI.
Can you explain what you have used, please?
Comment #7
gregbeat commentedSure thing. I just created an image field for my content type via built in D7 cck. Then I modified my node tpl like so:
$image = image_style_url('banner', $node->field_mediaimage['und'][0]['uri']);
$imagealt = $node->field_mediaimage['und'][0]['field_media_alt']['und'][0]['safe_value'];
$imagetitle = $node->field_mediaimage['und'][0]['field_media_title']['und'][0]['safe_value'];
So I'm just grabbing the image, the alt, and the title tags by checking the node variables before I display. Perhaps I need to use a preprocess function to "refresh" the node?
Comment #8
chaloalvarezj commentedI just applied the patch manually and it seems to be working! Thank you!
Comment #9
camdarley commentedI have the same issue than gregbeat in #5.
I have nodes with an image field. When i move the image previously added to the node between folders, the node display still use the old uri and cannot display the image.
What i have to do is clear the cache or re-save the node.
It's annoying if I have a lot of nodes...
Comment #10
camdarley commentedI think we have a problem in the way media_folder_plus move physical directory and files.
With #4, all file object are updated after directory has been moved with FileTransferLocal in media_browser_plus_move_physical_folder.
That mean if there is a problem during file transfer, file object are updated anyway and files appear broken.
In my thought, moving folder should move all files one by one with a batch process, verify for each file that copy is fine, then update uri. It is nonsense to separate the updating of the database and the physical move.
It's a longer process but I actually think it's a compulsory way to avoid broken uri.
Maybe i'm wrong and maybe there's a better solution, what do you think about it?
Comment #11
camdarley commentedHere is a first try, it seems to be working well:
Comment #12
camdarley commentedAny update on this? I use #11 on a production site and i'ts working very well: no complains from my clients about broken files anymore.
Is there something wrong with this way of moving files?
Comment #13
camdarley commentedI just realize that we can use file_prepare_directory instead of drupal_mkdir :
Comment #14
camdarley commentedPatch for 7.x-2.x version
Comment #15
camdarley commentedSame patch with #13 (I forgot to implement it before posting the preview's one)
Comment #16
kirilius commentedI am using the latest 2.x-dev version of this module. I just moved a folder and although all images in it got physically moved, the paths to the images did not get updated. As a result anywhere on the site where I refer to an image style (former ImageCache), I get a broken link and no image is displayed.
Based on the comments above, the latest patch seems to be working. Is there any chance that it is rolled into a release soon? I don't really know how to apply a patch to the code. I am managing my site through cPanel and I don't have shell access to the server.
In the meantime does aybody know how to recover from the situation (moved folder and brken links)?
Thanks!
Comment #17
camdarley commentedHi Kirilius,
As you can see, I got no answer about my patch...
It's working for the 1.x version of MBP... I didn't have enough time to dive into 2.x and check if it could be working with it.
I am very surprised that no one reviewed my patch, because I still think that the way the files are moved now is nonsense.
Comment #18
camdarley commentedComment #19
dimitriseng commentedAny chance to provide a patch for 2.x? Happy to test, thanks.
Comment #20
das-peter commentedThe comments should follow the standards: http://drupal.org/node/1354#general
media_browser_plus_folder_update_file_locations_batch()contains locations with trailing whitespaces according to the coding standards they should be removed. I'd suggest to configure your IDE to do that for you automatically.I'm not sure if we not should really check first if the folder is empty before call
rmdir. The point is that I think we shouldn't assume that a folder is used by MBP only and thus could contain files / folders that can't be moved. Further I'm not sure if we can be sure that the order of the files returned by the query will provide the correct order for processing. This means there could be attempts to delete parent folders before the children are even processed. And sincermdirwill throw anE_WARNINGthis could lead to some ugly output.How about collecting the folder paths, and handle them once all files are moved?
Sorting could be done using path length, which should be sufficient to have the right child / parent order.
Comment #21
jamesharv commentedThis is a feature which is essential for a client of mine, who is using 7.x-1.0-beta3. So I have written a new patch against 7.x-1.x, based on the work from camdarley, and incorporating the feedback from das-peter.
This is working well for me in a Vanilla Drupal site, and with my client's website (which is still under development and not yet in production use).