On 12/11/14 19:50, Simon McVittie wrote: > Alternatively, CGI::FormBuilder could be augmented to use something like > this > > my @xs; > > if ($q->can("param_fetch")) { > @xs = @{$q->param_fetch('x')}; > } else { > @xs = $q->param('x'); > } > > at each of the locations where Amitai and I patched it.
Since this is, strictly speaking, a regression in our patched CGI::FormBuilder, I've prepared a patch that replaces Amitai's 2 patches, and my additional patch in the same style. (See attached, 0003-*.patch.) The best way to do this upstream would probably be to add a new function Util::param_multi_valued($cgi_or_compatible, $k) encapsulating that logic, but that's new API, which seems undesirable to add downstream; that's also a reasonable argument for not adding Catalyst::Request::param_fetch unless/until Catalyst upstream say yes, I suppose. The attached 0001-*.patch is for Debian's git repo. The patched libcgi-formbuilder-perl passes its tests in sbuild, and so does libcatalyst-controller-formbuilder-perl_0.06-2 when given the patched libcgi-formbuilder-perl as an additional .deb. S
From 89421a62fbf839354371fb1c27b9c94b97ffbef7 Mon Sep 17 00:00:00 2001 From: Simon McVittie <s...@debian.org> Date: Wed, 12 Nov 2014 20:43:56 +0000 Subject: [PATCH] Revise patches from previous release to retain support for objects that mimic the CGI.pm API but do not have param_fetch (Closes: #769240) --- debian/changelog | 8 ++ ...nneeded-warning-from-CGI.pm-4.05-or-newer.patch | 87 ++++++++++++++++++++++ ...nneeded-warning-from-CGI.pm-4.05-or-newer.patch | 20 ----- ...nneeded-warning-from-CGI.pm-4.05-or-newer.patch | 20 ----- ...-use-of-param-that-will-cause-a-warning-i.patch | 19 ----- ...t-cgi_param-is-context-sensitive-just-lik.patch | 4 +- debian/patches/series | 4 +- 7 files changed, 99 insertions(+), 63 deletions(-) create mode 100644 debian/patches/0003-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch delete mode 100644 debian/patches/0004-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch delete mode 100644 debian/patches/0005-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch delete mode 100644 debian/patches/0006-Fix-another-use-of-param-that-will-cause-a-warning-i.patch diff --git a/debian/changelog b/debian/changelog index 3f1081e..09ecb3c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libcgi-formbuilder-perl (3.09-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Revise patches from previous release to retain support for objects + that mimic the CGI.pm API but do not have param_fetch (Closes: #769240) + + -- Simon McVittie <s...@debian.org> Wed, 12 Nov 2014 20:43:04 +0000 + libcgi-formbuilder-perl (3.09-1) unstable; urgency=medium [ Salvatore Bonaccorso ] diff --git a/debian/patches/0003-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch b/debian/patches/0003-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch new file mode 100644 index 0000000..e91c0bc --- /dev/null +++ b/debian/patches/0003-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch @@ -0,0 +1,87 @@ +From: Simon McVittie <s...@debian.org> +Date: Wed, 12 Nov 2014 20:41:26 +0000 +Subject: Avoid unneeded warning from CGI.pm 4.05 or newer + +Based on earlier patches by Amitai Schlair, but modified to retain +support for objects like Catalyst::Request that mimic the CGI interface +but do not have a param_fetch method. +--- + lib/CGI/FormBuilder.pm | 13 ++++++++++++- + lib/CGI/FormBuilder/Field.pm | 14 +++++++++++++- + lib/CGI/FormBuilder/Multi.pm | 14 +++++++++++++- + 3 files changed, 38 insertions(+), 3 deletions(-) + +diff --git a/lib/CGI/FormBuilder.pm b/lib/CGI/FormBuilder.pm +index f01c61c..04b5e72 100644 +--- a/lib/CGI/FormBuilder.pm ++++ b/lib/CGI/FormBuilder.pm +@@ -855,7 +855,18 @@ sub keepextras { + + # Make sure to get all values + for my $p (@keep) { +- for my $v ($self->{params}->param($p)) { ++ my @values; ++ if ($self->{params}->can('param_fetch')) { ++ @values = @{$self->{params}->param_fetch($p)}; ++ } ++ else { ++ # array-context calls to param($p) are deprecated in ++ # CGI.pm, but some other objects that mimic ++ # its interface don't have param_fetch ++ @values = $self->{params}->param($p); ++ } ++ ++ for my $v (@values) { + debug 1, "keepextras: saving hidden param $p = $v"; + push @html, htmltag('input', name => $p, type => 'hidden', value => $v); + } +diff --git a/lib/CGI/FormBuilder/Field.pm b/lib/CGI/FormBuilder/Field.pm +index a649696..8413240 100644 +--- a/lib/CGI/FormBuilder/Field.pm ++++ b/lib/CGI/FormBuilder/Field.pm +@@ -189,7 +189,19 @@ sub cgi_value { + my $self = shift; + debug 2, "$self->{name}: called \$field->cgi_value"; + puke "Cannot set \$field->cgi_value manually" if @_; +- if (my @v = $self->{_form}{params}->param($self->name)) { ++ ++ my @v; ++ if ($self->{_form}{params}->can('param_fetch')) { ++ @v = @{$self->{_form}{params}->param_fetch($self->name)}; ++ } ++ else { ++ # array-context calls to param($p) are deprecated in ++ # CGI.pm, but some other objects that mimic ++ # its interface don't have param_fetch ++ @v = $self->{_form}{params}->param($self->name); ++ } ++ ++ if (@v) { + for my $v (@v) { + if ($self->other && $v eq $self->othername) { + debug 1, "$self->{name}: redoing value from _other field"; +diff --git a/lib/CGI/FormBuilder/Multi.pm b/lib/CGI/FormBuilder/Multi.pm +index 4255ed8..8ef32f7 100644 +--- a/lib/CGI/FormBuilder/Multi.pm ++++ b/lib/CGI/FormBuilder/Multi.pm +@@ -218,7 +218,19 @@ sub navbar { + } + for my $k (@{$self->{keepextras}}) { + next if $k eq $pnam; +- for my $v ($self->{params}->param($k)) { ++ ++ my @values; ++ if ($self->{params}->can('param_fetch')) { ++ @values = @{$self->{params}->param_fetch($k)}; ++ } ++ else { ++ # array-context calls to param($k) are deprecated in ++ # CGI.pm, but some other objects that mimic ++ # its interface don't have param_fetch ++ @values = $self->{params}->param($k); ++ } ++ ++ for my $v (@values) { + push @keep, { name => $k, value => $v }; + } + } diff --git a/debian/patches/0004-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch b/debian/patches/0004-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch deleted file mode 100644 index 0395cab..0000000 --- a/debian/patches/0004-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch +++ /dev/null @@ -1,20 +0,0 @@ -From: Amitai Schlair <schmonz-web-ikiw...@schmonz.com> -Date: Thu, 16 Oct 2014 10:33:57 +0100 -Subject: Avoid unneeded warning from CGI.pm 4.05 or newer - -Origin: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/www/p5-CGI-FormBuilder/patches/patch-lib_CGI_FormBuilder.pm?rev=1.1&content-type=text/plain ---- - lib/CGI/FormBuilder.pm | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/lib/CGI/FormBuilder.pm -+++ b/lib/CGI/FormBuilder.pm -@@ -855,7 +855,7 @@ - - # Make sure to get all values - for my $p (@keep) { -- for my $v ($self->{params}->param($p)) { -+ for my $v (@{$self->{params}->param_fetch($p)}) { - debug 1, "keepextras: saving hidden param $p = $v"; - push @html, htmltag('input', name => $p, type => 'hidden', value => $v); - } diff --git a/debian/patches/0005-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch b/debian/patches/0005-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch deleted file mode 100644 index aaedac9..0000000 --- a/debian/patches/0005-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch +++ /dev/null @@ -1,20 +0,0 @@ -From: Amitai Schlair <schmonz-web-ikiw...@schmonz.com> -Date: Thu, 16 Oct 2014 10:34:45 +0100 -Subject: Avoid unneeded warning from CGI.pm 4.05 or newer - -Origin: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/www/p5-CGI-FormBuilder/patches/patch-lib_CGI_FormBuilder_Field.pm?rev=1.1&content-type=text/plain ---- - lib/CGI/FormBuilder/Field.pm | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/lib/CGI/FormBuilder/Field.pm -+++ b/lib/CGI/FormBuilder/Field.pm -@@ -189,7 +189,7 @@ - my $self = shift; - debug 2, "$self->{name}: called \$field->cgi_value"; - puke "Cannot set \$field->cgi_value manually" if @_; -- if (my @v = $self->{_form}{params}->param($self->name)) { -+ if (my @v = @{$self->{_form}{params}->param_fetch($self->name)}) { - for my $v (@v) { - if ($self->other && $v eq $self->othername) { - debug 1, "$self->{name}: redoing value from _other field"; diff --git a/debian/patches/0006-Fix-another-use-of-param-that-will-cause-a-warning-i.patch b/debian/patches/0006-Fix-another-use-of-param-that-will-cause-a-warning-i.patch deleted file mode 100644 index 5599f44..0000000 --- a/debian/patches/0006-Fix-another-use-of-param-that-will-cause-a-warning-i.patch +++ /dev/null @@ -1,19 +0,0 @@ -From: Simon McVittie <s...@debian.org> -Date: Thu, 16 Oct 2014 10:39:16 +0100 -Subject: Fix another use of param that will cause a warning in recent CGI.pm - ---- - lib/CGI/FormBuilder/Multi.pm | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/lib/CGI/FormBuilder/Multi.pm -+++ b/lib/CGI/FormBuilder/Multi.pm -@@ -218,7 +218,7 @@ - } - for my $k (@{$self->{keepextras}}) { - next if $k eq $pnam; -- for my $v ($self->{params}->param($k)) { -+ for my $v (@{$self->{params}->param_fetch($k)}) { - push @keep, { name => $k, value => $v }; - } - } diff --git a/debian/patches/0007-Comment-that-cgi_param-is-context-sensitive-just-lik.patch b/debian/patches/0007-Comment-that-cgi_param-is-context-sensitive-just-lik.patch index 5fb4d12..8d1885e 100644 --- a/debian/patches/0007-Comment-that-cgi_param-is-context-sensitive-just-lik.patch +++ b/debian/patches/0007-Comment-that-cgi_param-is-context-sensitive-just-lik.patch @@ -6,9 +6,11 @@ Subject: Comment that cgi_param is context-sensitive just like param lib/CGI/FormBuilder.pm | 2 ++ 1 file changed, 2 insertions(+) +diff --git a/lib/CGI/FormBuilder.pm b/lib/CGI/FormBuilder.pm +index 04b5e72..0c2d529 100644 --- a/lib/CGI/FormBuilder.pm +++ b/lib/CGI/FormBuilder.pm -@@ -1175,6 +1175,8 @@ +@@ -1186,6 +1186,8 @@ sub required_tag { sub cgi_param { my $self = shift; diff --git a/debian/patches/series b/debian/patches/series index af743c0..39cb703 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,6 +1,4 @@ pod-encoding.patch pod-spelling.patch -0004-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch -0005-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch -0006-Fix-another-use-of-param-that-will-cause-a-warning-i.patch +0003-Avoid-unneeded-warning-from-CGI.pm-4.05-or-newer.patch 0007-Comment-that-cgi_param-is-context-sensitive-just-lik.patch -- 2.1.3
From: Simon McVittie <s...@debian.org> Date: Wed, 12 Nov 2014 20:41:26 +0000 Subject: Avoid unneeded warning from CGI.pm 4.05 or newer Based on earlier patches by Amitai Schlair, but modified to retain support for objects like Catalyst::Request that mimic the CGI interface but do not have a param_fetch method. --- lib/CGI/FormBuilder.pm | 13 ++++++++++++- lib/CGI/FormBuilder/Field.pm | 14 +++++++++++++- lib/CGI/FormBuilder/Multi.pm | 14 +++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/CGI/FormBuilder.pm b/lib/CGI/FormBuilder.pm index f01c61c..04b5e72 100644 --- a/lib/CGI/FormBuilder.pm +++ b/lib/CGI/FormBuilder.pm @@ -855,7 +855,18 @@ sub keepextras { # Make sure to get all values for my $p (@keep) { - for my $v ($self->{params}->param($p)) { + my @values; + if ($self->{params}->can('param_fetch')) { + @values = @{$self->{params}->param_fetch($p)}; + } + else { + # array-context calls to param($p) are deprecated in + # CGI.pm, but some other objects that mimic + # its interface don't have param_fetch + @values = $self->{params}->param($p); + } + + for my $v (@values) { debug 1, "keepextras: saving hidden param $p = $v"; push @html, htmltag('input', name => $p, type => 'hidden', value => $v); } diff --git a/lib/CGI/FormBuilder/Field.pm b/lib/CGI/FormBuilder/Field.pm index a649696..8413240 100644 --- a/lib/CGI/FormBuilder/Field.pm +++ b/lib/CGI/FormBuilder/Field.pm @@ -189,7 +189,19 @@ sub cgi_value { my $self = shift; debug 2, "$self->{name}: called \$field->cgi_value"; puke "Cannot set \$field->cgi_value manually" if @_; - if (my @v = $self->{_form}{params}->param($self->name)) { + + my @v; + if ($self->{_form}{params}->can('param_fetch')) { + @v = @{$self->{_form}{params}->param_fetch($self->name)}; + } + else { + # array-context calls to param($p) are deprecated in + # CGI.pm, but some other objects that mimic + # its interface don't have param_fetch + @v = $self->{_form}{params}->param($self->name); + } + + if (@v) { for my $v (@v) { if ($self->other && $v eq $self->othername) { debug 1, "$self->{name}: redoing value from _other field"; diff --git a/lib/CGI/FormBuilder/Multi.pm b/lib/CGI/FormBuilder/Multi.pm index 4255ed8..8ef32f7 100644 --- a/lib/CGI/FormBuilder/Multi.pm +++ b/lib/CGI/FormBuilder/Multi.pm @@ -218,7 +218,19 @@ sub navbar { } for my $k (@{$self->{keepextras}}) { next if $k eq $pnam; - for my $v ($self->{params}->param($k)) { + + my @values; + if ($self->{params}->can('param_fetch')) { + @values = @{$self->{params}->param_fetch($k)}; + } + else { + # array-context calls to param($k) are deprecated in + # CGI.pm, but some other objects that mimic + # its interface don't have param_fetch + @values = $self->{params}->param($k); + } + + for my $v (@values) { push @keep, { name => $k, value => $v }; } }