
theory at bricolage
Mar 19, 2009, 10:22 PM
Post #1 of 1
(499 views)
Permalink
|
|
[8514] A few fixes backported from trunk:
|
|
Revision: 8514 Author: theory Date: 2009-03-19 22:22:52 -0700 (Thu, 19 Mar 2009) ViewCVS: http://viewsvn.bricolage.cc/?rev=8514&view=rev Log Message: ----------- A few fixes backported from trunk: * Get DTDValidate working properly with recent versions of XML::LibXML. * Get rid of `cat_dir()` mocking in media tests that wasn't doing anytying. * Fix a couple of bugs when uploading an image before saving it. The UI doesn't do this, so not noting it in Changes. * Get rid of the exported `get_user_id()` in the Media class. Modified Paths: -------------- bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media/Image.pm bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media.pm bricolage/branches/rev_1_10/lib/Bric/Changes.pod bricolage/branches/rev_1_10/lib/Bric/Dist/Action/DTDValidate.pm bricolage/branches/rev_1_10/t/Bric/Biz/Asset/Business/Media/DevTest.pm Modified: bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media/Image.pm =================================================================== --- bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media/Image.pm 2009-03-20 04:51:36 UTC (rev 8513) +++ bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media/Image.pm 2009-03-20 05:22:52 UTC (rev 8514) @@ -465,7 +465,7 @@ sub upload_file { my $self = shift; $self->SUPER::upload_file(@_); - $self->create_thumbnail(1) if USE_THUMBNAILS; + $self->create_thumbnail(1) if USE_THUMBNAILS && !$self->_get('_upload_data'); return $self; } Modified: bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media.pm =================================================================== --- bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media.pm 2009-03-20 04:51:36 UTC (rev 8513) +++ bricolage/branches/rev_1_10/lib/Bric/Biz/Asset/Business/Media.pm 2009-03-20 05:22:52 UTC (rev 8514) @@ -45,7 +45,7 @@ use Bric::Util::Grp::Media; use Bric::Util::Time qw(:all); use Bric::App::MediaFunc; -use Bric::App::Session qw(get_user_id); +use Bric::App::Session; use File::Temp qw( tempfile ); use Bric::Config qw(:media :thumb MASON_COMP_ROOT PREVIEW_ROOT); use Bric::Util::Fault qw(:all); @@ -1633,7 +1633,7 @@ my $method = $auto_fields->{$name}; my $val = $media_func->$method(); $dt->set_value(defined $val ? $val : ''); - $dt->save; + $dt->save if $dt->get_id; } } } @@ -1896,8 +1896,8 @@ $self->_insert_instance(); if (my $upload_data = $self->_get('_upload_data')) { # Ah, we need to handle a file upload. + $self->_set(['_upload_data'] => [undef]); $self->upload_file(@$upload_data); - $self->_set(['_upload_data'] => [undef]); # Update to save the file location data. $self->_update_instance; } @@ -2376,7 +2376,7 @@ _output_preview_msgs => 0, }); - $burner->preview($self, 'media', get_user_id, $_->get_id) + $burner->preview($self, 'media', Bric::App::Session::get_user_id, $_->get_id) for $self->get_output_channels; $self->_set(['needs_preview'] => [0]); } Modified: bricolage/branches/rev_1_10/lib/Bric/Changes.pod =================================================================== --- bricolage/branches/rev_1_10/lib/Bric/Changes.pod 2009-03-20 04:51:36 UTC (rev 8513) +++ bricolage/branches/rev_1_10/lib/Bric/Changes.pod 2009-03-20 05:22:52 UTC (rev 8514) @@ -16,6 +16,17 @@ =head2 Bug Fixes +=over + +=item + +Fixed a compatibility issue in Bric::Dist::Action::DTDValidate. Apparently +C<get_last_error()> was removed from L<XML::LibXML|XML::LibXML> 1.59 "for +thread-saftey reasons." This change backward-compatible with older versions of +XML::LibXML. [David] + +=back + =head1 VERSION 1.10.7 (2009-03-12) =head2 Improvements Modified: bricolage/branches/rev_1_10/lib/Bric/Dist/Action/DTDValidate.pm =================================================================== --- bricolage/branches/rev_1_10/lib/Bric/Dist/Action/DTDValidate.pm 2009-03-20 04:51:36 UTC (rev 8513) +++ bricolage/branches/rev_1_10/lib/Bric/Dist/Action/DTDValidate.pm 2009-03-20 05:22:52 UTC (rev 8514) @@ -155,14 +155,10 @@ status_msg "Validating $uri"; # Parse the file. - my $doc = eval { $parser->parse_file($path) }; + eval { $parser->parse_file($path)->validate }; - # Handle any parsing exceptions. + # Handle any parsing or validation exceptions. handle_err($@, 'Error parsing XML', $path, $uri, 1) if $@; - - # Now validate the XML. - handle_err($parser->get_last_error, 'XML validation error', - $path, $uri) unless $doc->is_valid; } } return $self; Modified: bricolage/branches/rev_1_10/t/Bric/Biz/Asset/Business/Media/DevTest.pm =================================================================== --- bricolage/branches/rev_1_10/t/Bric/Biz/Asset/Business/Media/DevTest.pm 2009-03-20 04:51:36 UTC (rev 8513) +++ bricolage/branches/rev_1_10/t/Bric/Biz/Asset/Business/Media/DevTest.pm 2009-03-20 05:22:52 UTC (rev 8514) @@ -951,25 +951,13 @@ my $self = shift; my $class = $self->class; - # Cache the cat_dir sub, and set up a path that's okay to write to. - my $cat_dir = \&Bric::Util::Trans::FS::cat_dir; - - my @paths = (undef, $cat_dir->(undef, $ENV{BRIC_TEMP_DIR}, '_media')); - - my $mock_fs = Test::MockModule->new('Bric::Util::Trans::FS'); - $mock_fs->mock(mk_path => 1); - $mock_fs->mock(cat_dir => sub { - return shift @paths if @paths; - goto $cat_dir; - }); - # Let's force lowercase-only. $self->{oc} = my $oc = $self->get_elem->get_output_channels->[0]; $oc->set_uri_case(LOWERCASE)->save; ok my $media = $self->construct( name => 'Flubberman', - file_name => 'fun.foo', + file_name => 'Some file.png', ), 'Create a new media object'; # Upload a file before saving the media.
|