From 4899bcd7c42bb7aaeb98cc6db0fcfc3e4cb877f8 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 20 Sep 2010 11:45:30 -0700 Subject: [PATCH] Fix importing an Archive in default order. Update the test to now explicitly test for archive order. Fixes bug #11866. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/GalleryAlbum.pm | 9 +++------ lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm | 6 ++++++ t/Asset/Wobject/GalleryAlbum/addArchive.t | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index a0f373172..fba41dd85 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,7 @@ - fixed #11875: Error loading empty module - fixed #11873: findBrokenAssets.pl doesn't support custom assets - added findBrokenAssets.pl shows the classname of broken assets (William McKee, Knowmad Technologies) + - fixed #11866: Default ordering for Zip files is wrong 7.10.0 - fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index 93dc1db31..6ddd6aef0 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -127,12 +127,9 @@ sub addArchive { $archive->extract( $tempdirName ); # Get all the files in the archive - my @files; - my $wanted = sub { push @files, $File::Find::name; $outputSub->('Found file: %s', $File::Find::name); }; - find( { - wanted => $wanted, - }, $tempdirName ); - + $outputSub->('Getting list of files for sorting purposes'); + my @files = map { File::Spec->catfile($tempdirName, $_); } $archive->files; + # Sort files by date if ($sortBy eq 'date') { # Hash for storing last modified timestamps diff --git a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm index 895a39bb7..67d5bed83 100644 --- a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm +++ b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm @@ -672,6 +672,12 @@ our $I18N = { context => 'label for progress bar in addArchive', }, + 'Getting list of files for sorting purposes' => { + message => 'Getting list of files for sorting purposes', + lastUpdated => 1237403498, + context => 'label for progress bar in addArchive', + }, + 'Found file: %s' => { message => 'Found file %s', lastUpdated => 1237403498, diff --git a/t/Asset/Wobject/GalleryAlbum/addArchive.t b/t/Asset/Wobject/GalleryAlbum/addArchive.t index 170c6c4fc..fc33c8188 100644 --- a/t/Asset/Wobject/GalleryAlbum/addArchive.t +++ b/t/Asset/Wobject/GalleryAlbum/addArchive.t @@ -134,9 +134,9 @@ $album->addArchive( WebGUI::Test->getTestCollateralPath('gallery_archive_sorting # Get all children my $images = $album->getLineage(['descendants'], { returnObjects => 1 }); # Check order -cmp_bag( +cmp_deeply( [ map { $_->get("filename") } @{ $images } ], - [ "photo1.jpg", "photo4.jpg", "photo3.jpg", "photo2.jpg", ], + [ "photo3.jpg", "photo2.jpg", "photo4.jpg", "photo1.jpg", ], "Photos sorted by file order (all files exist)" ); # Empty gallery album