diff --git a/.gitignore b/.gitignore
index 671f4f1..cb0db0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+clog
*spec~
/memcache-3.0.6.tgz
/memcache-3.0.7.tgz
+/memcache-3.0.8.tgz
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 6c1c170..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,68 +0,0 @@
---------------------------------------------------------------------
- The PHP License, version 3.0
-Copyright (c) 1999 - 2006 The PHP Group. All rights reserved.
---------------------------------------------------------------------
-
-Redistribution and use in source and binary forms, with or without
-modification, is permitted provided that the following conditions
-are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- 3. The name "PHP" must not be used to endorse or promote products
- derived from this software without prior written permission. For
- written permission, please contact group@php.net.
-
- 4. Products derived from this software may not be called "PHP", nor
- may "PHP" appear in their name, without prior written permission
- from group@php.net. You may indicate that your software works in
- conjunction with PHP by saying "Foo for PHP" instead of calling
- it "PHP Foo" or "phpfoo"
-
- 5. The PHP Group may publish revised and/or new versions of the
- license from time to time. Each version will be given a
- distinguishing version number.
- Once covered code has been published under a particular version
- of the license, you may always continue to use it under the terms
- of that version. You may also choose to use such covered code
- under the terms of any subsequent version of the license
- published by the PHP Group. No one other than the PHP Group has
- the right to modify the terms applicable to covered code created
- under this License.
-
- 6. Redistributions of any form whatsoever must retain the following
- acknowledgment:
- "This product includes PHP, freely available from
- ".
-
-THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
-ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
-DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-
---------------------------------------------------------------------
-
-This software consists of voluntary contributions made by many
-individuals on behalf of the PHP Group.
-
-The PHP Group can be contacted via Email at group@php.net.
-
-For more information on the PHP Group and the PHP project,
-please see .
-
-This product includes the Zend Engine, freely available at
-.
diff --git a/connect.inc b/connect.inc
new file mode 100644
index 0000000..96d2875
--- /dev/null
+++ b/connect.inc
@@ -0,0 +1,97 @@
+ array(
+ 'crc32' => array('key1_abc', 'key2_abcde'),
+ 'fnv' => array('key1_a', 'key2_2534534'),
+ ),
+ 'standard' => array(
+ 'crc32' => array('load_test_key1', 'load_test_key2'),
+ 'fnv' => array('key1_ab', 'key2_a'),
+ ),
+ );
+
+$strat = strtolower(ini_get('memcache.hash_strategy'));
+$func = strtolower(ini_get('memcache.hash_function'));
+list ($balanceKey1, $balanceKey2) = $balanceKeys[$strat][$func];
+
+if (!isset($udpPort))
+ $udpPort = 0;
+if (!isset($udpPort2))
+ $udpPort2 = 0;
+
+$memcache = memcache_connect($host, $port);
+
+function test_connect1() {
+ global $host, $port, $udpPort;
+ $memcache = new MemcachePool();
+ $memcache->connect($host, $port, isset($udpPort) ? $udpPort : 0);
+ return $memcache;
+}
+
+function test_connect2() {
+ global $host2, $port2, $udpPort2;
+ $memcache = new MemcachePool();
+ $memcache->connect($host2, $port2, isset($udpPort2) ? $udpPort2 : 0);
+ return $memcache;
+}
+
+function test_connect_pool() {
+ global $host, $port, $udpPort, $host2, $port2, $udpPort2;
+ $memcache = new MemcachePool();
+ $memcache->addServer($host, $port, isset($udpPort) ? $udpPort : 0);
+ $memcache->addServer($host2, $port2, isset($udpPort2) ? $udpPort2 : 0);
+ return $memcache;
+}
+
+if (!$memcache) {
+ die('skip Connection to memcached failed');
+}
+
+?>
diff --git a/php-pecl-memcache-3.0.5-get-mem-corrupt.patch b/php-pecl-memcache-3.0.5-get-mem-corrupt.patch
deleted file mode 100644
index 0b7c66c..0000000
--- a/php-pecl-memcache-3.0.5-get-mem-corrupt.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From 6e09e8db8d36de6a5020f5d517f62a8c16af8222 Mon Sep 17 00:00:00 2001
-From: "Vojtech Vitek (V-Teq)"
-Date: Mon, 17 Oct 2011 16:17:51 +0200
-Subject: [PATCH] fix get/unserialize memory corruption
-
-Possible memory corruption (and segfault) after unserialising objects:
-obj = $obj;
-$memcache = new Memcache;
-$memcache->connect('127.0.0.1', 11211);
-$memcache->set('x', $obj, false, 300);
-$x = $memcache->get('x');
-$x = $memcache->get('x');
-$x = $memcache->get('x');
-$x = $memcache->get('x');
-$x = $memcache->get('x');
-
-Patch by Paul Clifford.
-
----
- memcache-3.0.5/memcache_pool.c | 15 +++++++--------
- 1 files changed, 7 insertions(+), 8 deletions(-)
-
-diff --git memcache-3.0.5/memcache_pool.c memcache-3.0.5/memcache_pool.c
-index 420a773..e89ebce 100644
---- memcache-3.0.5/memcache_pool.c
-+++ memcache-3.0.5/memcache_pool.c
-@@ -422,8 +422,8 @@ int mmc_unpack_value(
- char *data = NULL;
- unsigned long data_len;
-
-- zval value;
-- INIT_ZVAL(value);
-+ zval *object;
-+ ALLOC_INIT_ZVAL(object);
-
- if (flags & MMC_COMPRESSED) {
- if (mmc_uncompress(buffer->value.c, bytes, &data, &data_len) != MMC_OK) {
-@@ -439,7 +439,6 @@ int mmc_unpack_value(
- if (flags & MMC_SERIALIZED) {
- php_unserialize_data_t var_hash;
- const unsigned char *p = (unsigned char *)data;
-- zval *object = &value;
-
- char key_tmp[MMC_MAX_KEY_LEN + 1];
- mmc_request_value_handler value_handler;
-@@ -495,7 +494,7 @@ int mmc_unpack_value(
- long val;
- data[data_len] = '\0';
- val = strtol(data, NULL, 10);
-- ZVAL_LONG(&value, val);
-+ ZVAL_LONG(object, val);
- break;
- }
-
-@@ -503,17 +502,17 @@ int mmc_unpack_value(
- double val = 0;
- data[data_len] = '\0';
- sscanf(data, "%lg", &val);
-- ZVAL_DOUBLE(&value, val);
-+ ZVAL_DOUBLE(object, val);
- break;
- }
-
- case MMC_TYPE_BOOL:
-- ZVAL_BOOL(&value, data_len == 1 && data[0] == '1');
-+ ZVAL_BOOL(object, data_len == 1 && data[0] == '1');
- break;
-
- default:
- data[data_len] = '\0';
-- ZVAL_STRINGL(&value, data, data_len, 0);
-+ ZVAL_STRINGL(object, data, data_len, 0);
-
- if (!(flags & MMC_COMPRESSED)) {
- /* release buffer because it's now owned by the zval */
-@@ -522,7 +521,7 @@ int mmc_unpack_value(
- }
-
- /* delegate to value handler */
-- return request->value_handler(key, key_len, &value, flags, cas, request->value_handler_param TSRMLS_CC);
-+ return request->value_handler(key, key_len, object, flags, cas, request->value_handler_param TSRMLS_CC);
- }
- }
- /* }}}*/
---
-1.7.6.2
-
diff --git a/php-pecl-memcache-3.0.7-bug59602.patch b/php-pecl-memcache-3.0.7-bug59602.patch
deleted file mode 100644
index fd28fb3..0000000
--- a/php-pecl-memcache-3.0.7-bug59602.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- pecl/memcache/branches/NON_BLOCKING_IO/memcache.c 2012/10/31 08:49:59 328201
-+++ pecl/memcache/branches/NON_BLOCKING_IO/memcache.c 2012/10/31 12:27:09 328202
-@@ -1836,7 +1836,9 @@
- request = mmc_pool_request(pool, MMC_PROTO_TCP, mmc_stats_handler, stats, NULL, NULL TSRMLS_CC);
- pool->protocol->stats(request, type, slabid, limit);
-
-- mmc_pool_schedule(pool, pool->servers[i], request TSRMLS_CC);
-+ if (mmc_pool_schedule(pool, pool->servers[i], request TSRMLS_CC) == MMC_OK) {
-+ mmc_pool_run(pool TSRMLS_CC);
-+ }
- }
-
- /* execute all requests */
diff --git a/php-pecl-memcache.spec b/php-pecl-memcache.spec
index ffdad3b..abf6377 100644
--- a/php-pecl-memcache.spec
+++ b/php-pecl-memcache.spec
@@ -1,31 +1,32 @@
+%{!?php_inidir: %{expand: %%global php_inidir %{_sysconfdir}/php.d}}
+%{!?__php: %{expand: %%global __php %{_bindir}/php}}
%{!?__pecl: %{expand: %%global __pecl %{_bindir}/pecl}}
+%global with_zts 0%{?__ztsphp:1}
%global pecl_name memcache
+# Not ready, some failed UDP tests. Neded investigation.
+%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
Summary: Extension to work with the Memcached caching daemon
Name: php-pecl-memcache
-Version: 3.0.7
-Release: 7%{?dist}
+Version: 3.0.8
+Release: 1%{?dist}
License: PHP
Group: Development/Languages
URL: http://pecl.php.net/package/%{pecl_name}
Source: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
Source2: xml2changelog
-# https://bugs.php.net/63141
-Source3: LICENSE
-
-# https://bugs.php.net/63142
-# http://svn.php.net/viewvc?view=revision&revision=327754
-Patch1: %{name}-3.0.5-get-mem-corrupt.patch
-
-# https://bugs.php.net/59602
-# http://svn.php.net/viewvc?view=revision&revision=328202
-Patch2: %{name}-3.0.7-bug59602.patch
+# Missing in official archive
+# http://svn.php.net/viewvc/pecl/memcache/branches/NON_BLOCKING_IO/tests/connect.inc?view=co
+Source3: connect.inc
BuildRequires: php-devel
BuildRequires: php-pear
BuildRequires: zlib-devel
+%if %{with_tests}
+BuildRequires: memcached
+%endif
Requires(post): %{__pecl}
Requires(postun): %{__pecl}
@@ -57,8 +58,6 @@ Memcache can be used as a PHP session handler.
%setup -c -q
pushd %{pecl_name}-%{version}
-%patch1 -p1 -b .get-mem-corrupt.patch
-%patch2 -p4 -b .bug54602
# Chech version as upstream often forget to update this
extver=$(sed -n '/#define PHP_MEMCACHE_VERSION/{s/.* "//;s/".*$//;p}' php_memcache.h)
@@ -69,9 +68,7 @@ if test "x${extver}" != "x%{version}"; then
fi
popd
-%{_bindir}/php %{SOURCE2} package.xml | tee CHANGELOG | head -n 5
-
-cp -p %{SOURCE3} .
+%{__php} %{SOURCE2} package.xml | tee CHANGELOG | head -n 8
cat >%{pecl_name}.ini << 'EOF'
; ----- Enable %{pecl_name} extension module
@@ -115,12 +112,23 @@ extension=%{pecl_name}.so
;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
EOF
+%if %{with_zts}
+cp -r %{pecl_name}-%{version} %{pecl_name}-%{version}-zts
+%endif
+
%build
cd %{pecl_name}-%{version}
-phpize
-%configure
+%{_bindir}/phpize
+%configure --with-php-config=%{_bindir}/php-config
+make %{?_smp_mflags}
+
+%if %{with_zts}
+cd ../%{pecl_name}-%{version}-zts
+%{_bindir}/zts-phpize
+%configure --with-php-config=%{_bindir}/zts-php-config
make %{?_smp_mflags}
+%endif
%install
@@ -128,19 +136,59 @@ make -C %{pecl_name}-%{version} \
install INSTALL_ROOT=%{buildroot}
# Drop in the bit of configuration
-install -D -m 644 %{pecl_name}.ini %{buildroot}%{_sysconfdir}/php.d/%{pecl_name}.ini
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_inidir}/%{pecl_name}.ini
+
+%if %{with_zts}
+make -C %{pecl_name}-%{version}-zts \
+ install INSTALL_ROOT=%{buildroot}
+
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_ztsinidir}/%{pecl_name}.ini
+%endif
# Install XML package description
install -Dpm 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml
%check
-cd %{pecl_name}-%{version}
# simple module load test
-%{_bindir}/php --no-php-ini \
- --define extension_dir=%{buildroot}%{php_extdir} \
+%{__php} --no-php-ini \
+ --define extension_dir=%{pecl_name}-%{version}/modules \
+ --define extension=%{pecl_name}.so \
+ --modules | grep %{pecl_name}
+
+%if %{with_zts}
+%{__ztsphp} --no-php-ini \
+ --define extension_dir=%{pecl_name}-%{version}-zts/modules \
--define extension=%{pecl_name}.so \
--modules | grep %{pecl_name}
+%endif
+
+%if %{with_tests}
+cd %{pecl_name}-%{version}
+cp %{SOURCE3} tests
+sed -e "s:/var/run/memcached/memcached.sock:$PWD/memcached.sock:" \
+ -i tests/connect.inc
+
+# Launch the daemons
+memcached -p 11211 -U 11211 -d -P $PWD/memcached1.pid
+memcached -p 11212 -U 11212 -d -P $PWD/memcached2.pid
+memcached -s $PWD/memcached.sock -d -P $PWD/memcached3.pid
+
+# Run the test Suite
+ret=0
+TEST_PHP_EXECUTABLE=%{_bindir}/php \
+TEST_PHP_ARGS="-n -d extension_dir=$PWD/modules -d extension=%{pecl_name}.so" \
+NO_INTERACTION=1 \
+REPORT_EXIT_STATUS=1 \
+%{_bindir}/php -n run-tests.php || ret=1
+
+# Cleanup
+if [ -f memcached2.pid ]; then
+ kill $(cat memcached?.pid)
+fi
+
+exit $ret
+%endif
%post
@@ -154,14 +202,24 @@ fi
%files
-%doc CHANGELOG %{pecl_name}-%{version}/CREDITS %{pecl_name}-%{version}/README LICENSE
+%doc CHANGELOG %{pecl_name}-%{version}/{CREDITS,README,LICENSE}
%doc %{pecl_name}-%{version}/example.php %{pecl_name}-%{version}/memcache.php
-%config(noreplace) %{_sysconfdir}/php.d/%{pecl_name}.ini
-%{php_extdir}/%{pecl_name}.so
%{pecl_xmldir}/%{name}.xml
+%config(noreplace) %{php_inidir}/%{pecl_name}.ini
+%{php_extdir}/%{pecl_name}.so
+
+%if %{with_zts}
+%config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini
+%{php_ztsextdir}/%{pecl_name}.so
+%endif
+
%changelog
+* Mon Apr 08 2013 Remi Collet - 3.0.8-1
+- Update to 3.0.8
+- enable conditional ZTS extension build
+
* Fri Mar 22 2013 Remi Collet - 3.0.7-7
- rebuild for http://fedoraproject.org/wiki/Features/Php55
diff --git a/sources b/sources
index 1be676e..13725c2 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-5cc9f2ef11f5c931794ece1a148416df memcache-3.0.7.tgz
+24505e9b263d2c77f8ae5e9b4725e7d1 memcache-3.0.8.tgz