Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 81791
Status: rejected
Priority: 0/
Queue: Net-DNS

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

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



Subject: [PATCH] Restore Net::DNS::RR->new_from_hash
Subject: [PATCH] Restore Net::DNS::RR->new_from_hash There are a number of packages that expect Net::DNS::RR to have new_from_hash() as an alternate constructor. While recent Net::DNS claims compatability with prior versions, for some reason this constructor disappeared in favor of the similarly named new_hash(). This patch restores new_from_hash(), adds a test to ensure it doesn't disappear again, and tweaks the pod tests a bit. Thanks! :)
Subject: 0001-Restore-Net-DNS-RR-new_from_hash.patch
From 0413d9511624d80ce22168b278df126663def25e Mon Sep 17 00:00:00 2001 From: Chris Weyl <cweyl@alumni.drew.edu> Date: Fri, 7 Dec 2012 20:44:45 -0800 Subject: [PATCH] Restore Net::DNS::RR->new_from_hash There are a number of packages that expect Net::DNS::RR to have new_from_hash() as an alternate constructor. While recent Net::DNS claims compatability with prior versions, for some reason this constructor disappeared in favor of the similarly named new_hash(). This patch restores new_from_hash(), adds a test to ensure it doesn't disappear again, and tweaks the pod tests a bit. Thanks! :) --- MANIFEST | 1 + lib/Net/DNS/RR.pm | 4 ++++ t/00-pod.t | 33 +++++++++++++++------------------ t/80-compat.t | 11 +++++++++++ 4 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 t/80-compat.t diff --git a/MANIFEST b/MANIFEST index ca2a015..aa366af 100644 --- a/MANIFEST +++ b/MANIFEST @@ -146,6 +146,7 @@ t/08-online.t t/10-recurse.t t/11-inet6.t t/13-udp-trunc.t +t/80-compat.t t/99-cleanup.t t/NonFatal.pm t/TestData.pm diff --git a/lib/Net/DNS/RR.pm b/lib/Net/DNS/RR.pm index dccad7d..9386497 100644 --- a/lib/Net/DNS/RR.pm +++ b/lib/Net/DNS/RR.pm @@ -162,6 +162,9 @@ If omitted, C<ttl> defaults to 0 and C<class> defaults to IN. Omitting the optional fields is useful for creating the empty RDATA sections required for certain dynamic update operations. +The older new_from_hash() constructor will still work; it just delegates to +new() directly. + =cut sub new_hash { @@ -198,6 +201,7 @@ sub new_hash { return $self; } +sub new_from_hash { warn 'in new_from_hash()'; shift->new_hash(@_) } =head2 decode diff --git a/t/00-pod.t b/t/00-pod.t index 6563213..f122578 100644 --- a/t/00-pod.t +++ b/t/00-pod.t @@ -1,26 +1,23 @@ # $Id: 00-pod.t 1068 2012-12-06 10:38:51Z willem $ -use Test::More; -use File::Spec; -use File::Find; use strict; +use warnings; -eval "use Test::Pod 0.95"; +# test iff we're a in release testing +BEGIN { + unless ($ENV{RELEASE_TESTING}) { + require Test::More; + Test::More::plan(skip_all => 'these tests are for release candidate testing'); + } +} -if ($@) { - plan skip_all => "Test::Pod v0.95 required for testing POD"; -} else { - Test::Pod->import; - - my @files; - my $blib = File::Spec->catfile(qw(blib lib)); - - find( sub { push(@files, $File::Find::name) if /\.p(l|m|od)$/}, $blib); +use Test::More; - plan tests => scalar @files; +# test iff we have a recent level of Test::Pod +use Test::Requires { + 'Test::Pod' => '1.00', +}; - foreach my $file (@files) { - pod_file_ok($file); - } -} +all_pod_files_ok(); +done_testing; diff --git a/t/80-compat.t b/t/80-compat.t new file mode 100644 index 0000000..9cd87eb --- /dev/null +++ b/t/80-compat.t @@ -0,0 +1,11 @@ +use strict; +use warnings; + +# ABSTRACT: A simple check to make sure we don't lose new_from_hash() again + +use Test::More; +use Net::DNS::RR; + +can_ok 'Net::DNS::RR', 'new_from_hash'; + +done_testing; -- 1.8.0.1
From: rwfranks [...] acm.org
On Fri Dec 07 23:51:32 2012, RSRCHBOY wrote: Show quoted text
> Subject: [PATCH] Restore Net::DNS::RR->new_from_hash > > There are a number of packages that expect Net::DNS::RR to have > new_from_hash() as an alternate constructor. While recent Net::DNS > claims compatability with prior versions,
The published interface has not changed and is therefore the claim of compatibility is justified. If you write code which makes use of unpublished interfaces, subroutines and/or data structures, you do so at your own risk. The documentation (for 0.68) makes it very clear that it is the new() constructor which is used for this purpose. The only mention of "hash" is in parenthesis to differentiate the separate forms of new() usage. new (from hash) $rr = Net::DNS::RR->new( name => "foo.example.com", ttl => 86400, class => "IN", type => "A", address => "10.1.2.3", ); $rr = Net::DNS::RR->new( name => "foo.example.com", type => "A", ); Returns an RR object of the appropriate type, or a Net::DNS::RR object if the type isn't implemented. See the manual pages for each RR type to see what fields the type requires.
We have discussed it internally and decided to not put it back. I would still be interested to know which software used this method as we are planning a mechanism to warn software package developers of upcoming Net::DNS releases in the future. Perhaps those packages need some extra attention? Thanks for you report and supplied workaround. Your effort is mich appreciated. -- Willem