summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-pecl-uploadprogress.spec35
-rw-r--r--uploadprogress-php7.patch188
2 files changed, 217 insertions, 6 deletions
diff --git a/php-pecl-uploadprogress.spec b/php-pecl-uploadprogress.spec
index c5c0331..47c2fec 100644
--- a/php-pecl-uploadprogress.spec
+++ b/php-pecl-uploadprogress.spec
@@ -22,7 +22,7 @@
Summary: An extension to track progress of a file upload
Name: %{?scl_prefix}php-pecl-%{pecl_name}
Version: 1.0.3.1
-Release: 5%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}.1
+Release: 6%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}
License: PHP
Group: Development/Languages
URL: http://pecl.php.net/package/%{pecl_name}
@@ -31,12 +31,13 @@ Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
# http://svn.php.net/viewvc/pecl/uploadprogress/trunk/LICENSE?view=co
Source1: LICENSE
+# See https://github.com/Jan-E/uploadprogress
+Patch0: %{pecl_name}-php7.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: %{?scl_prefix}php-devel
BuildRequires: %{?scl_prefix}php-pear
-Requires(post): %{__pecl}
-Requires(postun): %{__pecl}
Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api}
Requires: %{?scl_prefix}php(api) = %{php_core_api}
%{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}}
@@ -60,6 +61,10 @@ Obsoletes: php55w-pecl-%{pecl_name} <= %{version}
Obsoletes: php56u-pecl-%{pecl_name} <= %{version}
Obsoletes: php56w-pecl-%{pecl_name} <= %{version}
%endif
+%if "%{php_version}" > "7.0"
+Obsoletes: php70u-pecl-%{pecl_name} <= %{version}
+Obsoletes: php70w-pecl-%{pecl_name} <= %{version}
+%endif
%endif
%if 0%{?fedora} < 20 && 0%{?rhel} < 7
@@ -78,12 +83,16 @@ unfortunately still have issues.
See %{pecl_docdir}/%{pecl_name}/examples
for a little example.
+Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection}.
+
%prep
%setup -q -c
mv %{pecl_name}-%{version} NTS
cd NTS
+%patch0 -p1 -b .php7
+
cp %{SOURCE1} LICENSE
# Sanity check, really often broken
@@ -153,12 +162,20 @@ do install -Dpm 644 NTS/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i
done
-%post
-%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
+# when pear installed alone, after us
+%triggerin -- %{?scl_prefix}php-pear
+if [ -x %{__pecl} ] ; then
+ %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
+fi
+# posttrans as pear can be installed after us
+%posttrans
+if [ -x %{__pecl} ] ; then
+ %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
+fi
%postun
-if [ $1 -eq 0 ] ; then
+if [ $1 -eq 0 -a -x %{__pecl} ] ; then
%{pecl_uninstall} %{pecl_name} >/dev/null || :
fi
@@ -185,8 +202,10 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
+%{?_licensedir:%license NTS/LICENSE}
%doc %{pecl_docdir}/%{pecl_name}
%{pecl_xmldir}/%{name}.xml
+
%config(noreplace) %{php_inidir}/%{ini_name}
%{php_extdir}/%{pecl_name}.so
@@ -197,6 +216,10 @@ rm -rf %{buildroot}
%changelog
+* Thu Apr 9 2015 Remi Collet <remi@fedoraproject.org> - 1.0.3.1-6
+- add fix for PHP 7
+- drop runtime dependency on pear, new scriptlets
+
* Wed Dec 24 2014 Remi Collet <remi@fedoraproject.org> - 1.0.3.1-5.1
- Fedora 21 SCL mass rebuild
diff --git a/uploadprogress-php7.patch b/uploadprogress-php7.patch
new file mode 100644
index 0000000..aebc544
--- /dev/null
+++ b/uploadprogress-php7.patch
@@ -0,0 +1,188 @@
+From 50d4a16be3fcf4ef8909f4a4785d1416c4de81fe Mon Sep 17 00:00:00 2001
+From: Jan-E <github@ehrhardt.nl>
+Date: Sun, 15 Mar 2015 21:50:48 +0100
+Subject: [PATCH] PHP 7 support
+
+---
+ uploadprogress.c | 28 +++++++++++++++++++++++++---
+ 1 file changed, 25 insertions(+), 3 deletions(-)
+
+diff --git a/uploadprogress.c b/uploadprogress.c
+index e66b724..864ebd7 100644
+--- a/uploadprogress.c
++++ b/uploadprogress.c
+@@ -71,7 +71,7 @@ PHPAPI extern int (*php_rfc1867_callback)(unsigned int , void *, void ** TSRMLS_
+ */
+ static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data, void **data TSRMLS_DC)
+ {
+- zval handler;
++ //zval handler;
+ char *callable = NULL;
+ uploadprogress_data * progress;
+ int read_bytes;
+@@ -301,7 +301,7 @@ PHP_FUNCTION(uploadprogress_get_info)
+ {
+ char * id;
+ int id_lg;
+- char method;
++ //char method;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_lg) == FAILURE) {
+ return;
+@@ -417,7 +417,11 @@ static void uploadprogress_file_php_get_info(char * id, zval * return_value)
+ v[index] = 0;
+ }
+ }
++#if defined(ZEND_ENGINE_3)
++ add_assoc_string( return_value, k, v );
++#else
+ add_assoc_string( return_value, k, v, 1 );
++#endif
+ }
+ fclose(F);
+ }
+@@ -432,10 +436,18 @@ static void uploadprogress_file_php_get_info(char * id, zval * return_value)
+ */
+ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long maxlen, zval *return_value)
+ {
++#if defined(ZEND_ENGINE_3) /* borrowed from phar/func_interceptors.c */
++ char *filename, *template, *data_identifier;
++ zend_string *contents;
++#else
+ char *filename, *template, *contents, *data_identifier;
++#endif
+ php_stream *stream;
+ int options = ENFORCE_SAFE_MODE;
+- int len, newlen;
++ int len;
++#if PHP_API_VERSION < 20100412
++ int newlen;
++#endif
+ TSRMLS_FETCH();
+
+ template = INI_STR("uploadprogress.file.contents_template");
+@@ -455,7 +467,13 @@ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long
+ }
+
+ /* uses mmap if possible */
++#if defined(ZEND_ENGINE_3)
++ contents = php_stream_copy_to_mem(stream, maxlen, 0);
++ len = contents->len;
++ if (contents && len > 0) {
++#else
+ if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
++#endif
+
+ #if PHP_API_VERSION < 20100412
+ if (PG(magic_quotes_runtime)) {
+@@ -463,7 +481,11 @@ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long
+ len = newlen;
+ }
+ #endif
++#if defined(ZEND_ENGINE_3)
++ RETVAL_STRINGL((char *)contents, len);
++#else
+ RETVAL_STRINGL(contents, len, 0);
++#endif
+ } else if (len == 0) {
+ RETVAL_EMPTY_STRING();
+ } else {
+From b8462d6631dc6ba4bfb6d0d23fa903efc9591e6f Mon Sep 17 00:00:00 2001
+From: Jan-E <github@ehrhardt.nl>
+Date: Sun, 15 Mar 2015 21:54:11 +0100
+Subject: [PATCH] Tabs 2 spaces
+
+---
+ uploadprogress.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/uploadprogress.c b/uploadprogress.c
+index 864ebd7..7b11ea9 100644
+--- a/uploadprogress.c
++++ b/uploadprogress.c
+@@ -436,9 +436,9 @@ static void uploadprogress_file_php_get_info(char * id, zval * return_value)
+ */
+ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long maxlen, zval *return_value)
+ {
+-#if defined(ZEND_ENGINE_3) /* borrowed from phar/func_interceptors.c */
++#if defined(ZEND_ENGINE_3)
+ char *filename, *template, *data_identifier;
+- zend_string *contents;
++ zend_string *contents;
+ #else
+ char *filename, *template, *contents, *data_identifier;
+ #endif
+@@ -468,9 +468,9 @@ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long
+
+ /* uses mmap if possible */
+ #if defined(ZEND_ENGINE_3)
+- contents = php_stream_copy_to_mem(stream, maxlen, 0);
+- len = contents->len;
+- if (contents && len > 0) {
++ contents = php_stream_copy_to_mem(stream, maxlen, 0);
++ len = contents->len;
++ if (contents && len > 0) {
+ #else
+ if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
+ #endif
+From ac54045b98863f647bdc0e5b1af2e841a68d3dcb Mon Sep 17 00:00:00 2001
+From: Jan-E <github@ehrhardt.nl>
+Date: Fri, 3 Apr 2015 02:10:58 +0200
+Subject: [PATCH] ENFORCE_SAFE_MODE is dropped
+
+---
+ uploadprogress.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/uploadprogress.c b/uploadprogress.c
+index 7b11ea9..f164434 100644
+--- a/uploadprogress.c
++++ b/uploadprogress.c
+@@ -157,8 +157,12 @@ static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data
+
+ if (get_contents) {
+ php_stream *stream;
++#if defined(ZEND_ENGINE_3)
++ int options = 0;
++#else
+ int options = ENFORCE_SAFE_MODE;
+-
++#endif
++
+ stream = php_stream_open_wrapper(progress->data_filename, "ab", options, NULL);
+ if (stream) {
+ php_stream_write(stream, e_data->data, e_data->length);
+@@ -443,7 +447,11 @@ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long
+ char *filename, *template, *contents, *data_identifier;
+ #endif
+ php_stream *stream;
++#if defined(ZEND_ENGINE_3)
++ int options = 0;
++#else
+ int options = ENFORCE_SAFE_MODE;
++#endif
+ int len;
+ #if PHP_API_VERSION < 20100412
+ int newlen;
+From 5f1e1fa97c8d32dacbed1fccd2e2f3bc2decd615 Mon Sep 17 00:00:00 2001
+From: Jan-E <github@ehrhardt.nl>
+Date: Thu, 9 Apr 2015 14:22:39 +0200
+Subject: [PATCH] avoid duplication and memory leak
+
+---
+ uploadprogress.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/uploadprogress.c b/uploadprogress.c
+index f164434..849257e 100644
+--- a/uploadprogress.c
++++ b/uploadprogress.c
+@@ -490,7 +490,7 @@ static void uploadprogress_file_php_get_contents(char *id, char *fieldname, long
+ }
+ #endif
+ #if defined(ZEND_ENGINE_3)
+- RETVAL_STRINGL((char *)contents, len);
++ RETVAL_STR(contents);
+ #else
+ RETVAL_STRINGL(contents, len, 0);
+ #endif