Skip Menu |

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

Report information
The Basics
Id: 46086
Status: resolved
Worked: 45 min
Priority: 0/
Queue: MooseX-Singleton

People
Owner: Nobody in particular
Requestors: perl [...] evancarroll.com
Cc: jquelin [...] cpan.org
AdminCc:

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



Subject: awkward warnings violation
Name "POE::Kernel::singleton" used only once: possible typo at /usr/local/share/perl/5.10.0/MooseX/Singleton/Meta/Class.pm line 53.
Subject: Re: [rt.cpan.org #46086] awkward warnings violation
Date: Thu, 14 May 2009 14:44:57 -0500 (CDT)
To: Evan Carroll via RT <bug-MooseX-Singleton [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Thu, 14 May 2009, Evan Carroll via RT wrote: Show quoted text
> Thu May 14 15:41:44 2009: Request 46086 was acted upon. > Transaction: Ticket created by ECARROLL > Queue: MooseX-Singleton > Subject: awkward warnings violation > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: perl@evancarroll.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=46086 > > > > Name "POE::Kernel::singleton" used only once: possible typo at > /usr/local/share/perl/5.10.0/MooseX/Singleton/Meta/Class.pm line 53.
Can you reproduce this without POE and submit a test? I think it's probably easy enough to fix. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
I've hit this problem in some commercial code. It boils down to this: package Foo; use strict; use warnings; use MooseX::Singleton; Foo->_clear_instance; 1; Load that module and you'll get the warning. I'm not sure why the code in question finds it necessary to clear the instance on module load, its in a method called reset() and hdp wrote it. The fix is to add a "use warnings 'once'" to clear_singleton.
On Fri Jul 02 22:00:53 2010, MSCHWERN wrote: Show quoted text
> Load that module and you'll get the warning. I'm not sure why the code > in question finds it necessary to clear the instance on module load, its > in a method called reset() and hdp wrote it.
Code's open sourced now, though the history is truncated, if you want to puzzle it out. http://github.com/opensourcery/elementalClinic/blob/master/app/lib/eleMentalClinic/Config.pm
From: robin.ge [...] gmail.com
We have also had this issue, adding: no warnings 'once'; At line 24 "fixed" it, R
On Fri Oct 15 11:28:58 2010, robinedwards wrote: Show quoted text
> We have also had this issue, > > adding: > > no warnings 'once'; > > At line 24 "fixed" it, > > R
This is the fix I made for the same issue. no strict 'refs'; no warnings 'once'; return ${"$pkg\::singleton"} = super;
Subject: Re: [rt.cpan.org #46086] "name used only once" warning from MX::Singleton
Date: Fri, 25 Feb 2011 09:24:22 -0600 (CST)
To: Chisel Wright via RT <bug-MooseX-Singleton [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Fri, 25 Feb 2011, Chisel Wright via RT wrote: Show quoted text
> Queue: MooseX-Singleton > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=46086 > > > On Fri Oct 15 11:28:58 2010, robinedwards wrote:
>> We have also had this issue, >> >> adding: >> >> no warnings 'once'; >> >> At line 24 "fixed" it, >> >> R
> > This is the fix I made for the same issue. > > no strict 'refs'; > no warnings 'once'; > return ${"$pkg\::singleton"} = super;
I don't suppose you have a test case? -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
This one fails for me both with Moose-1.25 and Moose-2.0000 on MooseX::Singleton 0.26 -- Pavel Shaydo
Subject: warning_once.t
use Test::More qw(no_plan); use Test::NoWarnings; BEGIN { package Singleton; use MooseX::Singleton; has attribute => (is => 'rw'); sub BUILD { shift->attribute(1); } } BEGIN { Singleton->initialize } my $s = Singleton->instance; ok $s->attribute, "Attribute is set";
On Fri Feb 25 15:24:32 2011, autarch@urth.org wrote: Show quoted text
> I don't suppose you have a test case? >
Sorry - I don't know how I missed this response. My test is very similar to the last comment in the thread. For some reason 'override _construct_instance => sub { ... }' seems overly sensitive to 'once' warnings where 'sub clear_singleton' isn't. I've attached a patch and a test that should fail until the patch is applied. This was written and tested against: $MooseX::Singleton::Role::Meta::Class::VERSION = '0.27';
Subject: warnings_once.patch
--- /tmp/Meta-Class.pm.original 2011-11-21 17:57:36.000000000 +0000 +++ /opt/xt/xt-perl/lib/site_perl/5.14.2/MooseX/Singleton/Role/Meta/Class.pm 2011-11-21 17:57:39.000000000 +0000 @@ -40,6 +40,7 @@ my $pkg = $class->name; no strict 'refs'; + no warnings 'once'; return ${"$pkg\::singleton"} = super; };
Subject: warnings_once.t
# test script for: https://rt.cpan.org/Ticket/Display.html?id=46086 use Test::More qw(no_plan); use Test::NoWarnings; BEGIN { package OnlyUsedOnce; use strict; use warnings; use MooseX::Singleton; } BEGIN { OnlyUsedOnce->initialize; } my $s = OnlyUsedOnce->instance;
Show quoted text
> My test is very similar to the last comment in the thread.
Fixed in HEAD http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/MooseX-Singleton.git;a=commit;h=0f22810a8a14902c7724ea80a9951829e42ac8eb