From de9e804d4b9ab0e92ef31f755fe84d565a2366b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com>
Date: Thu, 25 May 2017 17:30:50 +0200
Subject: Adapt to changes in JSON-2.93

---
 ...ct-JSON-encode-decode-availability-by-VER.patch | 52 ++++++++++++++++++++++
 perl-CGI-Ex.spec                                   |  4 ++
 2 files changed, 56 insertions(+)
 create mode 100644 
CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch

diff --git 
a/CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch 
b/CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch
new file mode 100644
index 0000000..4acd4eb
--- /dev/null
+++ b/CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch
@@ -0,0 +1,52 @@
+From 50e59055f733a78d4c3efb443e4020d7177c2344 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@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ř <ppi...@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
+
diff --git a/perl-CGI-Ex.spec b/perl-CGI-Ex.spec
index 875537b..4788176 100644
--- a/perl-CGI-Ex.spec
+++ b/perl-CGI-Ex.spec
@@ -8,6 +8,8 @@ URL:            http://search.cpan.org/dist/CGI-Ex/
 Source0:        
http://www.cpan.org/authors/id/L/LJ/LJEPSON/CGI-Ex-%{version}.tar.gz
 # Restore compatibility with Perl 5.26.0, CPAN RT#121889
 Patch0:         CGI-Ex-2.44-Do-not-use-POSIX-tmpnam.patch
+# Adapt to changes in JSON-2.93, CPAN RT#121893
+Patch1:         
CGI-Ex-2.44-Do-not-detect-JSON-encode-decode-availability-by-VER.patch
 BuildArch:      noarch
 Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo 
$version))
 
@@ -60,6 +62,7 @@ CGI::Ex::App.
 %prep
 %setup -q -n CGI-Ex-%{version}
 %patch0 -p1
+%patch1 -p1
 
 # make rpmlint happy :)
 find samples/ -type f -exec chmod -c -x {} \;
@@ -86,6 +89,7 @@ make test
 %changelog
 * Thu May 25 2017 Petr Pisar <ppi...@redhat.com> - 2.44-5
 - Restore compatibility with Perl 5.26.0 (CPAN RT#121889)
+- Adapt to changes in JSON-2.93 (CPAN RT#121893)
 
 * Sat Feb 11 2017 Fedora Release Engineering <rel...@fedoraproject.org> - 
2.44-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
-- 
cgit v1.1


        
https://src.fedoraproject.org/cgit/perl-CGI-Ex.git/commit/?h=master&id=de9e804d4b9ab0e92ef31f755fe84d565a2366b5
_______________________________________________
perl-devel mailing list -- perl-devel@lists.fedoraproject.org
To unsubscribe send an email to perl-devel-le...@lists.fedoraproject.org

Reply via email to