Skip Menu |

This queue is for tickets about the MooseX-Singleton CPAN distribution.

Report information
The Basics
Id: 72923
Status: new
Priority: 0/
Queue: MooseX-Singleton

People
Owner: Nobody in particular
Requestors: rod.taylor [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.27
Fixed in: (no value)



Subject: Can't call method "has_value" on an undefined value
Subject: singleton_failure.pl
#!/usr/bin/env perl use v5.12.4; use SingletonObj; my $setupDBH = SingletonObj->setup( { user => 'auto' } );
From: rod.taylor [...] gmail.com
Please ignore the previous message (Clicked create instead of Add More Files). Basically, DEMOLISH is causing an error to be thrown. (in cleanup) Can't call method "has_value" on an undefined value at /usr/local/lib/perl/5.12.4/Class/MOP/Class.pm line 862 during global destruction. Attached is minimal code to recreate the error. I also cannot seem to combine them into a single file or remove the _setup accessor withou the error disappearing. I only seem to get the issue when using MooseX::Singleton and not straight Moose but I'm not entirely certain it is a MooseX bug. Tried with Moose 2.0204 and 2.0401.
Subject: SingletonObj.pm
package SingletonObj; use v5.12.4; use MooseX::Singleton; has '_dbh' => ( is => 'rw', isa => 'DBI::db', ); has '_setup' => ( is => 'rw', isa => 'Int', default => 0 ); sub setup { my $self = shift; if ( not $self->_setup ) { # Perform configuration of singleton } return; } sub connected { my $self = shift; # Used to check _dbh->ping here too but determined the overhead # could be too high as this function may be called several times # during a single page build. if ( $self->_dbh ) { say "Return DB State"; } return 0; } sub DEMOLISH { my ($self) = @_; if ( $self->connected ) { say "Disconnect from DB"; } return; } 1;
Subject: singleton_failure.pl
#!/usr/bin/env perl use v5.12.4; use SingletonObj; my $setupDBH = SingletonObj->setup( { user => 'auto' } );