From 9b00fb49fe7c9c95901f60b7e47196c7cf43fee4 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 4 Jun 2019 06:53:59 +0200
Subject: add upstream patches for sqlite3 and imagick

---
 4d9b98524d4a6ebc1541d9a354c1f2511efac6d0.patch |  62 ++++++++++++++
 effa54cf9433bc4aff5d77b453e4351215aeec14.patch | 109 +++++++++++++++++++++++++
 php-bartlett-php-compatinfo-db.spec            |  13 ++-
 3 files changed, 183 insertions(+), 1 deletion(-)
 create mode 100644 4d9b98524d4a6ebc1541d9a354c1f2511efac6d0.patch
 create mode 100644 effa54cf9433bc4aff5d77b453e4351215aeec14.patch

diff --git a/4d9b98524d4a6ebc1541d9a354c1f2511efac6d0.patch b/4d9b98524d4a6ebc1541d9a354c1f2511efac6d0.patch
new file mode 100644
index 0000000..e1c28a9
--- /dev/null
+++ b/4d9b98524d4a6ebc1541d9a354c1f2511efac6d0.patch
@@ -0,0 +1,62 @@
+From 4d9b98524d4a6ebc1541d9a354c1f2511efac6d0 Mon Sep 17 00:00:00 2001
+From: Laurent Laville <laurent.laville@gmail.com>
+Date: Sat, 25 May 2019 08:38:56 +0200
+Subject: [PATCH] to fix issue GH-29 (see also
+ https://github.com/Imagick/imagick/commit/bf56a61aa565cb2a6a70d5ff4106aed967726b11)
+
+---
+ data/references/Imagick.const.json | 42 +++++++++++++++++++++++++++++-
+ 1 file changed, 41 insertions(+), 1 deletion(-)
+
+diff --git a/data/references/Imagick.const.json b/data/references/Imagick.const.json
+index d57dd6f..d75a135 100644
+--- a/data/references/Imagick.const.json
++++ b/data/references/Imagick.const.json
+@@ -5379,5 +5379,45 @@
+         "php_min": "5.4.0",
+         "php_max": "",
+         "lib_imagemagick": ">=6.9.3"
++    },
++    {
++        "ext_name_fk": 29,
++        "class_name": "Imagick",
++        "name": "COMPOSITE_STEREO",
++        "ext_min": "3.4.4RC1",
++        "ext_max": "",
++        "php_min": "5.4.0",
++        "php_max": "",
++        "lib_imagemagick": ">=6.9.10"
++    },
++    {
++        "ext_name_fk": 29,
++        "class_name": "Imagick",
++        "name": "STYLE_BOLD",
++        "ext_min": "3.4.4RC1",
++        "ext_max": "",
++        "php_min": "5.4.0",
++        "php_max": "",
++        "lib_imagemagick": ">=6.9.11"
++    },
++    {
++        "ext_name_fk": 29,
++        "class_name": "Imagick",
++        "name": "COLORSPACE_LINEARGRAY",
++        "ext_min": "3.4.4RC1",
++        "ext_max": "",
++        "php_min": "5.4.0",
++        "php_max": "",
++        "lib_imagemagick": ">=6.9.9"
++    },
++    {
++        "ext_name_fk": 29,
++        "class_name": "Imagick",
++        "name": "RESOURCETYPE_LISTLENGTH",
++        "ext_min": "3.4.4RC1",
++        "ext_max": "",
++        "php_min": "5.4.0",
++        "php_max": "",
++        "lib_imagemagick": ">=6.9.10"
+     }
+-]
+\ No newline at end of file
++]
diff --git a/effa54cf9433bc4aff5d77b453e4351215aeec14.patch b/effa54cf9433bc4aff5d77b453e4351215aeec14.patch
new file mode 100644
index 0000000..2bdab62
--- /dev/null
+++ b/effa54cf9433bc4aff5d77b453e4351215aeec14.patch
@@ -0,0 +1,109 @@
+From effa54cf9433bc4aff5d77b453e4351215aeec14 Mon Sep 17 00:00:00 2001
+From: Laurent Laville <laurent.laville@gmail.com>
+Date: Mon, 3 Jun 2019 23:21:49 +0200
+Subject: [PATCH] fix issue GH-30
+
+---
+ data/references/Sqlite3.iniEntries.json | 11 ++++++++++-
+ src/ExtensionFactory.php                |  9 +++++++++
+ src/ReferenceCollection.php             | 11 ++++++++---
+ src/SqliteStorage.php                   |  2 +-
+ 4 files changed, 28 insertions(+), 5 deletions(-)
+
+diff --git a/data/references/Sqlite3.iniEntries.json b/data/references/Sqlite3.iniEntries.json
+index 25bd246..6963f0e 100644
+--- a/data/references/Sqlite3.iniEntries.json
++++ b/data/references/Sqlite3.iniEntries.json
+@@ -6,5 +6,14 @@
+         "ext_max": "",
+         "php_min": "5.3.0",
+         "php_max": ""
++    },
++    {
++        "ext_name_fk": 75,
++        "name": "sqlite3.defensive",
++        "ext_min": "5.6.40",
++        "ext_max": "",
++        "php_min": "5.6.40",
++        "php_max": "",
++        "lib_sqlite": ">=3.26"
+     }
+-]
+\ No newline at end of file
++]
+diff --git a/src/ExtensionFactory.php b/src/ExtensionFactory.php
+index 179f058..65df0fb 100644
+--- a/src/ExtensionFactory.php
++++ b/src/ExtensionFactory.php
+@@ -105,6 +105,15 @@ public function getMetaVersion(?string $key = null, ?string $extname = null) : a
+                     );
+                 }
+             }
++
++        } elseif (in_array('sqlite3', array($this->name, $extname))) {
++            if (method_exists('sqlite3', 'version')) {
++                $v = \SQLite3::version();
++                $meta = array(
++                    'version_number' => $v['versionNumber'],
++                    'version_text'   => $v['versionString'],
++                );
++            }
+         }
+ 
+         if (isset($key) && array_key_exists($key, $meta)) {
+diff --git a/src/ReferenceCollection.php b/src/ReferenceCollection.php
+index 1fa63ae..3e34790 100644
+--- a/src/ReferenceCollection.php
++++ b/src/ReferenceCollection.php
+@@ -98,6 +98,10 @@ public function addIniEntry($rec)
+             $rec['deprecated'] = '';
+         }
+ 
++        if (!isset($rec['lib_sqlite'])) {
++            $rec['lib_sqlite'] = '';
++        }
++
+         if (is_array($row)) {
+             if ($row == $rec) {
+                 // nothing to do
+@@ -326,6 +330,7 @@ protected function doInitialize()
+             ' ext_min VARCHAR(16), ext_max VARCHAR(16),' .
+             ' php_min VARCHAR(16), php_max VARCHAR(16),' .
+             ' deprecated VARCHAR(16),' .
++            ' lib_sqlite VARCHAR(16), ' .
+             ' PRIMARY KEY (ext_name_fk, name))'
+         );
+         $this->dbal->exec(
+@@ -398,8 +403,8 @@ protected function doInitialize()
+         );
+         $this->stmtIniEntries = $this->dbal->prepare(
+             'REPLACE INTO ' . $tblIniEntries .
+-            ' (ext_name_fk, name, ext_min, ext_max, php_min, php_max, deprecated)' .
+-            ' VALUES (:ext_name_fk, :name, :ext_min, :ext_max, :php_min, :php_max, :deprecated)'
++            ' (ext_name_fk, name, ext_min, ext_max, php_min, php_max, deprecated, lib_sqlite)' .
++            ' VALUES (:ext_name_fk, :name, :ext_min, :ext_max, :php_min, :php_max, :deprecated, :lib_sqlite)'
+         );
+         $this->stmtClasses = $this->dbal->prepare(
+             'REPLACE INTO ' . $tblClasses .
+@@ -440,7 +445,7 @@ protected function doInitialize()
+         );
+         $this->stmtIniEntry = $this->dbal->prepare(
+             'SELECT' .
+-            ' ext_name_fk, name, ext_min, ext_max, php_min, php_max, deprecated' .
++            ' ext_name_fk, name, ext_min, ext_max, php_min, php_max, deprecated, lib_sqlite' .
+             ' FROM ' . $tblIniEntries .
+             ' WHERE ext_name_fk = :ext_name_fk AND name = :name COLLATE NOCASE'
+         );
+diff --git a/src/SqliteStorage.php b/src/SqliteStorage.php
+index 14681ac..77ad0bc 100644
+--- a/src/SqliteStorage.php
++++ b/src/SqliteStorage.php
+@@ -155,7 +155,7 @@ protected function doInitialize() : void
+             'SELECT i.name,' .
+             ' ext_min as "ext.min", ext_max as "ext.max",' .
+             ' php_min as "php.min", php_max as "php.max",' .
+-            ' deprecated' .
++            ' deprecated, lib_sqlite' .
+             ' FROM bartlett_compatinfo_inientries i,  bartlett_compatinfo_extensions e' .
+             ' WHERE i.ext_name_fk = e.id AND e.name = :name COLLATE NOCASE'
+         );
diff --git a/php-bartlett-php-compatinfo-db.spec b/php-bartlett-php-compatinfo-db.spec
index 74b8d0d..ba6a157 100644
--- a/php-bartlett-php-compatinfo-db.spec
+++ b/php-bartlett-php-compatinfo-db.spec
@@ -24,7 +24,7 @@
 
 Name:           php-%{c_vendor}-%{c_project}
 Version:        %{upstream_version}%{?upstream_prever:~%{upstream_prever}}
-%global specrel 1
+%global specrel 2
 Release:        %{?gh_date:1%{specrel}.%{?prever}%{!?prever:%{gh_date}git%{gh_short}}}%{!?gh_date:%{specrel}}%{?dist}
 Summary:        Reference Database to be used with php-compatinfo library
 
@@ -39,6 +39,10 @@ Patch0:         %{name}-2.0-rpm.patch
 # CURL_SSLVERSION constants have been backported
 Patch1:         %{name}-curltls.patch
 
+# upstream patches
+Patch2:         https://github.com/llaville/php-compatinfo-db/commit/4d9b98524d4a6ebc1541d9a354c1f2511efac6d0.patch
+Patch3:         https://github.com/llaville/php-compatinfo-db/commit/effa54cf9433bc4aff5d77b453e4351215aeec14.patch
+
 BuildArch:      noarch
 # Needed to build the database from sources
 BuildRequires:  php(language) >= 7.1
@@ -142,6 +146,8 @@ Conflicts:      php-bartlett-PHP-CompatInfo < 5
 
 %patch0 -p1 -b .rpm
 %patch1 -p0 -b .curltls
+%patch2 -p1 -b .up1
+%patch3 -p1 -b .up2
 
 cat << 'EOF' | tee src/autoload.php
 <?php
@@ -262,6 +268,11 @@ EOF
 
 
 %changelog
+* Tue Jun  4 2019 Remi Collet <remi@remirepo.net> - 2.4.0-2
+- add upstream patches for sqlite3 and imagick
+- open https://github.com/llaville/php-compatinfo-db/issues/30
+  test failure related to sqlite3.defensive
+
 * Mon May 20 2019 Remi Collet <remi@remirepo.net> - 2.4.0-1
 - update to 2.4.0
 - open https://github.com/llaville/php-compatinfo-db/issues/29
-- 
cgit