Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 55689
Status: rejected
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: PURDY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.36
  • 0.50
Fixed in: (no value)



Subject: Storable retrieval failure
This is probably me, but I'm having a hard time figuring out what's going on. I'm storing a DateTime and it seems that when I push a new item to the storable array, which includes DateTime, it corrupts the Storable file, such that I can no longer retrieve(). :( Here's the error message: Error executing run mode 'start': Parameter #1 (undef) to DateTime::Locale::load was an 'undef', which is not one of the allowed types: scalar at /usr/local/share/perl/5.8.4/DateTime/Locale.pm line 199 DateTime::Locale::load('undef', 'undef') called at /usr/local/share/perl/5.8.4/DateTime/Locale/Base.pm line 135 DateTime::Locale::Base::STORABLE_attach('DateTime::Locale::en', 0, 'undef') called at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_retrieve.al) line 331 eval {...} called at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_retrieve.al) line 331 Storable::_retrieve('/path/to/logs/imports.frz', 0) called at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/retrieve.al) line 303 Storable::retrieve('/path/to/logs/imports.frz') called at StoreImportApp.pm line 34 StoreImportApp::start('StoreImportApp=HASH(0x81515dc)') called at /usr/local/share/perl/5.8.4/CGI/Application.pm line 152 eval {...} called at /usr/local/share/perl/5.8.4/CGI/Application.pm line 151 CGI::Application::run('StoreImportApp=HASH(0x81515dc)') called at /path/to/cgi/store_import.cgi line 9, at StoreImportApp.pm line 34 at /path/to/cgi/store_import.cgi line 9
I'll work on a simplified test case script and see if I can reproduce it.
I can't reproduce the bug, so I'm rejecting my own ticket. ;) They should all be this easy! If I get any more information, I'll revisit. Thanks!
Subject: 04-store_import_bug.t
#!/usr/bin/perl -w use strict; $|++; use Test::More tests => 13; use DateTime; use Storable; my $tmp_file = time() . '.frz'; ok( ! -e $tmp_file, 'storable file not there' ); simulate_order_import( 36, $tmp_file ); ok( -e $tmp_file, 'storable file is there now' ); my $data = undef; eval { $data = retrieve( $tmp_file ); }; ok( ! $@, 'no error when retrieving Storable data' ); ok( $data, '$data is not undef' ); simulate_order_import( 43, $tmp_file ); ok( -e $tmp_file, 'storable file is there now' ); $data = undef; eval { $data = retrieve( $tmp_file ); }; ok( ! $@, 'no error when retrieving Storable data' ); ok( $data, '$data is not undef' ); simulate_order_import( 1, $tmp_file ); ok( -e $tmp_file, 'storable file is there now' ); $data = undef; eval { $data = retrieve( $tmp_file ); }; ok( ! $@, 'no error when retrieving Storable data' ); ok( $data, '$data is not undef' ); simulate_order_import( 3, $tmp_file ); ok( -e $tmp_file, 'storable file is there now' ); $data = undef; eval { $data = retrieve( $tmp_file ); }; ok( ! $@, 'no error when retrieving Storable data' ); ok( $data, '$data is not undef' ); sub simulate_order_import { my ( $num, $tmp_file ) = @_; my $stats = { orders => 0, subs => 0, start => undef, start_pretty => '', end => undef, end_pretty => '', upload_date => DateTime->now( time_zone => 'America/New_York' )->iso8601(), user => $ENV{'REMOTE_USER'}, }; for ( 1..$num ) { my $order_date = DateTime->new( month => 3, day => int(rand(10))+1, year => '2010', time_zone => 'America/New_York', ); if ( !$stats->{'start'} || $stats->{'start'} > $order_date ) { $stats->{'start'} = $order_date; $stats->{'start_pretty'} = $order_date->mdy('/'); } if ( !$stats->{'end'} || $stats->{'end'} < $order_date ) { $stats->{'end'} = $order_date; $stats->{'end_pretty'} = $order_date->mdy('/'); } $stats->{'orders'}++; $stats->{'subs'}++; } delete $stats->{'start'}; delete $stats->{'end'}; if ( $stats->{'subs'} > 0 ) { my $frozen_data = {}; if ( -e $tmp_file ) { $frozen_data = retrieve($tmp_file); } push @{ $frozen_data->{'imports'} }, $stats; store( $frozen_data, $tmp_file ); } } END { unlink $tmp_file; } __END__ This is a test script to isolate a bug I'm running into to try & figure out what's going on. It seems that when I open a Storable file and add more data to it, the Storable file gets corrupted such that I cannot retrieve() any more. Author: Jason Purdy