Skip Menu |
 

This queue is for tickets about the CGI-Ex CPAN distribution.

Report information
The Basics
Id: 121893
Status: new
Priority: 0/
Queue: CGI-Ex

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

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

Attachments
CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch



Subject: JSON-2.93 broke JSON version detection
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-20904-1495726177-442.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1495726177-20904-2"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 914
Download (untitled) / with headers
text/plain 914b
CGI::Ex::Conf use JSON->VERSION to select support JSON API. However, JSON-2.93 broke/changed the VERSION() method (see CPAN RT#121892) and CGI-Ex test fails now: t/2_fill_20_switcharoo.t ........ ok # Failed test 'Could JSON write' # at t/3_conf_00_base.t line 24. # Error while writing conf file /tmp/12HLKl7fWg # Can't locate object method "objToJSon" via package "JSON" at /builddir/build/BUILD/CGI-Ex-2.44/blib/lib/CGI/Ex/Conf.pm line 556. 'jsonToObj' will be obsoleted. Please use 'decode' instead. at /builddir/build/BUILD/CGI-Ex-2.44/blib/lib/CGI/Ex/Conf.pm line 267. # Failed test 'Could JSON read' # at t/3_conf_00_base.t line 26. # got: undef # expected: 'bar' # Looks like you failed 2 tests of 8. t/3_conf_00_base.t .............. Dubious, test returned 2 (wstat 512, 0x200) Failed 2/8 subtests A fix for CGI-Ex is attached. It should work regardless JSON will be fixed or not.
Subject: CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch
MIME-Version: 1.0
Content-Type: application/octet-stream; name="CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch"
Content-Transfer-Encoding: base64
Content-Length: 1579
From 50e59055f733a78d4c3efb443e4020d7177c2344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Thu, 25 May 2017 17:19:31 +0200 Subject: [PATCH] Do not detect JSON::encode/decode availability by VERSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JSON-2.93 broke JSON->VERSON() <https://rt.cpan.org/Public/Bug/Display.html?id=121892> and that breaks JSON handling in CGI::Ex::Conf. This patch changes JSON->VERSION() to JSON->can() that should work always. Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/CGI/Ex/Conf.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CGI/Ex/Conf.pm b/lib/CGI/Ex/Conf.pm index c9d26f1..e422d9d 100644 --- a/lib/CGI/Ex/Conf.pm +++ b/lib/CGI/Ex/Conf.pm @@ -263,7 +263,7 @@ sub read_handler_json { CORE::read(IN, my $text, -s $file); close IN; require JSON; - my $decode = JSON->VERSION > 1.98 ? 'decode' : 'jsonToObj'; + my $decode = JSON->can('decode') ? 'decode' : 'jsonToObj'; return scalar JSON->new->$decode($text); } @@ -547,13 +547,13 @@ sub write_handler_json { my $ref = shift; require JSON; my $str; - if (JSON->VERSION > 1.98) { + if (JSON->can('encode')) { my $j = JSON->new; $j->canonical(1); $j->pretty; $str = $j->encode($ref); } else { - $str = JSON->new->objToJSon($ref, {pretty => 1, indent => 2}); + $str = JSON->new->objToJson($ref, {pretty => 1, indent => 2}); } local *OUT; open (OUT, ">$file") || die $!; -- 2.9.4


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.