[PHP-CVS] com php-src: Add CURLOPT_READDATA which was removed by mistake: ext/curl/interface.c

2012-09-22 Thread Pierrick Charron
Commit:70713a27b69962126a8e75caf01c88db96a542e3
Author:Pierrick Charron pierr...@php.net Sat, 22 Sep 2012 
10:04:51 -0400
Parents:   8984de467269d9b3da67d182bfd65baf6ce4d9d9
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=70713a27b69962126a8e75caf01c88db96a542e3

Log:
Add CURLOPT_READDATA which was removed by mistake

I did a check and this is the only one which was removed by mistake.
No other constants are available in 5.4 branch and not in master

Changed paths:
  M  ext/curl/interface.c


Diff:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 523bc1c..d9abece 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -638,6 +638,7 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLOPT_QUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
+   REGISTER_CURL_CONSTANT(CURLOPT_READDATA);
REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_REFERER);
REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Merge branch 'PHP-5.4': ext/curl/multi.c

2012-09-22 Thread Pierrick Charron
Commit:6c135dff975f111ec5a84af93c1b98e9ae84fcd1
Author:Pierrick Charron pierr...@php.net Sat, 22 Sep 2012 
10:19:16 -0400
Parents:   70713a27b69962126a8e75caf01c88db96a542e3 
c8687ee63b0aa0cbe8da1e8d5c65a338eb69f83a
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=6c135dff975f111ec5a84af93c1b98e9ae84fcd1

Log:
Merge branch 'PHP-5.4'

* PHP-5.4:
  Avoid calling select if maxfd returned by curl_multi_fdset is -1
  Fixing NEWS file

Changed paths:
  MM  ext/curl/multi.c


Diff:



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Avoid calling select if maxfd returned by curl_multi_fdset is -1: ext/curl/multi.c

2012-09-22 Thread Pierrick Charron
Commit:2e8ab65270e7d1ebe1ef0dfe13836c29d72c7010
Author:Pierrick Charron pierr...@php.net Sat, 22 Sep 2012 
10:15:40 -0400
Parents:   46458c2c65b7eec1fbe07dedd97fb6990843f3d6
Branches:  PHP-5.3 PHP-5.4 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=2e8ab65270e7d1ebe1ef0dfe13836c29d72c7010

Log:
Avoid calling select if maxfd returned by curl_multi_fdset is -1

As per libcurl documentation :

When libcurl returns -1 in max_fd, it is because libcurl currently
does something that isn't possible for your application to monitor
with a socket and unfortunately you can then not know exactly when
the current action is completed using select().

Changed paths:
  M  ext/curl/multi.c


Diff:
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index 034aa65..53e97b8 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -191,6 +191,9 @@ PHP_FUNCTION(curl_multi_select)
FD_ZERO(exceptfds);
 
curl_multi_fdset(mh-multi, readfds, writefds, exceptfds, maxfd);
+   if (maxfd == -1) {
+   RETURN_LONG(-1);
+   }
RETURN_LONG(select(maxfd + 1, readfds, writefds, exceptfds, to));
 }
 /* }}} */


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Fixed bug #63132: Zend/tests/generators/nested_method_calls.phpt Zend/zend_generators.c Zend/zend_generators.h Zend/zend_ptr_stack.c Zend/zend_ptr_stack.h

2012-09-22 Thread Nikita Popov
Commit:a31fa55b44bcb342c00e9ab2f4a851d054897a39
Author:Nikita Popov ni...@php.net Sat, 22 Sep 2012 19:12:21 +0200
Parents:   6c135dff975f111ec5a84af93c1b98e9ae84fcd1
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=a31fa55b44bcb342c00e9ab2f4a851d054897a39

Log:
Fixed bug #63132

EG(arg_types_stack) is now also backed up when generators are used. This
allows the use of yield in nested method calls.

This commit adds two new functions to the zend_ptr_stack API:

zend_ptr_stack_push_from_memory
zend_ptr_stack_pop_into_memory

both taking the following arguments:

zend_ptr_stack *stack, int count, void **pointers

Bugs:
https://bugs.php.net/63132

Changed paths:
  A  Zend/tests/generators/nested_method_calls.phpt
  M  Zend/zend_generators.c
  M  Zend/zend_generators.h
  M  Zend/zend_ptr_stack.c
  M  Zend/zend_ptr_stack.h


Diff:
diff --git a/Zend/tests/generators/nested_method_calls.phpt 
b/Zend/tests/generators/nested_method_calls.phpt
new file mode 100644
index 000..98aee2e
--- /dev/null
+++ b/Zend/tests/generators/nested_method_calls.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Yield can be used in nested method calls
+--FILE--
+?php
+
+class A {
+function foo() {
+echo Called A::foo\n;
+}
+}
+
+class B {
+function foo() {
+echo Called B::foo\n;
+}
+}
+
+function gen($obj) {
+$obj-foo($obj-foo(yield));
+}
+
+$g1 = gen(new A);
+$g1-current();
+
+$g2 = gen(new B);
+$g2-current();
+
+$g1-next();
+
+$g3 = clone $g2;
+unset($g2);
+$g3-next();
+
+?
+--EXPECT--
+Called A::foo
+Called A::foo
+Called B::foo
+Called B::foo
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 01b33a3..fba62dd 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -132,6 +132,21 @@ void zend_generator_close(zend_generator *generator, 
zend_bool finished_executio
efree(generator-backed_up_stack);
}
 
+   if (generator-backed_up_arg_types_stack) {
+   /* The arg types stack contains three elements per 
call: fbc, object
+* and called_scope. Here we traverse the stack from 
top to bottom
+* and dtor the object. */
+   int i = generator-backed_up_arg_types_stack_count / 3;
+   while (i--) {
+   zval *object = (zval *) 
generator-backed_up_arg_types_stack[3*i + 1];
+   if (object) {
+   zval_ptr_dtor(object);
+   }
+   }
+
+   efree(generator-backed_up_arg_types_stack);
+   } 
+
/* We have added an additional stack frame in 
prev_execute_data, so we
 * have to free it. It also contains the arguments passed to the
 * generator (for func_get_args) so those have to be freed too. 
*/
@@ -288,6 +303,25 @@ static void zend_generator_clone_storage(zend_generator 
*orig, zend_generator **
}
}
 
+   if (orig-backed_up_arg_types_stack) {
+   size_t stack_size = 
orig-backed_up_arg_types_stack_count * sizeof(void *);
+
+   clone-backed_up_arg_types_stack = emalloc(stack_size);
+   memcpy(clone-backed_up_arg_types_stack, 
orig-backed_up_arg_types_stack, stack_size);
+
+   /* We have to add refs to the objects in the arg types 
stack (the
+* object is always the second element of a three-pack. 
*/
+   {
+   int i, stack_frames = 
clone-backed_up_arg_types_stack_count / 3;
+   for (i = 0; i  stack_frames; i++) {
+   zval *object = (zval *) 
clone-backed_up_arg_types_stack[3*i + 1];
+   if (object) {
+   Z_ADDREF_P(object);
+   }
+   }
+   }
+   }
+
/* Update the send_target to use the temporary variable with 
the same
 * offset as the original generator, but in our temporary 
variable
 * memory segment. */
@@ -449,6 +483,7 @@ void zend_generator_resume(zend_generator *generator 
TSRMLS_DC) /* {{{ */
zval *original_This = EG(This);
zend_class_entry *original_scope = EG(scope);
zend_class_entry *original_called_scope = EG(called_scope);
+   int original_arg_types_stack_count = EG(arg_types_stack).top;
 
/* Remember the current stack position so we can back up pushed 
args */
generator-original_stack_top = zend_vm_stack_top(TSRMLS_C);
@@ -461,6 +496,16 @@ void zend_generator_resume(zend_generator 

Re: [PHP-CVS] com php-src: Fixed bug #63132: Zend/tests/generators/nested_method_calls.phpt Zend/zend_generators.c Zend/zend_generators.h Zend/zend_ptr_stack.c Zend/zend_ptr_stack.h

2012-09-22 Thread Nikita Popov
Is the addition of those two ZEND_API functions okay? If not, I'll inline them.

Nikita

On Sat, Sep 22, 2012 at 7:15 PM, Nikita Popov ni...@php.net wrote:
 Commit:a31fa55b44bcb342c00e9ab2f4a851d054897a39
 Author:Nikita Popov ni...@php.net Sat, 22 Sep 2012 19:12:21 
 +0200
 Parents:   6c135dff975f111ec5a84af93c1b98e9ae84fcd1
 Branches:  master

 Link:   
 http://git.php.net/?p=php-src.git;a=commitdiff;h=a31fa55b44bcb342c00e9ab2f4a851d054897a39

 Log:
 Fixed bug #63132

 EG(arg_types_stack) is now also backed up when generators are used. This
 allows the use of yield in nested method calls.

 This commit adds two new functions to the zend_ptr_stack API:

 zend_ptr_stack_push_from_memory
 zend_ptr_stack_pop_into_memory

 both taking the following arguments:

 zend_ptr_stack *stack, int count, void **pointers

 Bugs:
 https://bugs.php.net/63132

 Changed paths:
   A  Zend/tests/generators/nested_method_calls.phpt
   M  Zend/zend_generators.c
   M  Zend/zend_generators.h
   M  Zend/zend_ptr_stack.c
   M  Zend/zend_ptr_stack.h


 Diff:
 diff --git a/Zend/tests/generators/nested_method_calls.phpt 
 b/Zend/tests/generators/nested_method_calls.phpt
 new file mode 100644
 index 000..98aee2e
 --- /dev/null
 +++ b/Zend/tests/generators/nested_method_calls.phpt
 @@ -0,0 +1,39 @@
 +--TEST--
 +Yield can be used in nested method calls
 +--FILE--
 +?php
 +
 +class A {
 +function foo() {
 +echo Called A::foo\n;
 +}
 +}
 +
 +class B {
 +function foo() {
 +echo Called B::foo\n;
 +}
 +}
 +
 +function gen($obj) {
 +$obj-foo($obj-foo(yield));
 +}
 +
 +$g1 = gen(new A);
 +$g1-current();
 +
 +$g2 = gen(new B);
 +$g2-current();
 +
 +$g1-next();
 +
 +$g3 = clone $g2;
 +unset($g2);
 +$g3-next();
 +
 +?
 +--EXPECT--
 +Called A::foo
 +Called A::foo
 +Called B::foo
 +Called B::foo
 diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
 index 01b33a3..fba62dd 100644
 --- a/Zend/zend_generators.c
 +++ b/Zend/zend_generators.c
 @@ -132,6 +132,21 @@ void zend_generator_close(zend_generator *generator, 
 zend_bool finished_executio
 efree(generator-backed_up_stack);
 }

 +   if (generator-backed_up_arg_types_stack) {
 +   /* The arg types stack contains three elements per 
 call: fbc, object
 +* and called_scope. Here we traverse the stack from 
 top to bottom
 +* and dtor the object. */
 +   int i = generator-backed_up_arg_types_stack_count / 
 3;
 +   while (i--) {
 +   zval *object = (zval *) 
 generator-backed_up_arg_types_stack[3*i + 1];
 +   if (object) {
 +   zval_ptr_dtor(object);
 +   }
 +   }
 +
 +   efree(generator-backed_up_arg_types_stack);
 +   }
 +
 /* We have added an additional stack frame in 
 prev_execute_data, so we
  * have to free it. It also contains the arguments passed to 
 the
  * generator (for func_get_args) so those have to be freed 
 too. */
 @@ -288,6 +303,25 @@ static void zend_generator_clone_storage(zend_generator 
 *orig, zend_generator **
 }
 }

 +   if (orig-backed_up_arg_types_stack) {
 +   size_t stack_size = 
 orig-backed_up_arg_types_stack_count * sizeof(void *);
 +
 +   clone-backed_up_arg_types_stack = 
 emalloc(stack_size);
 +   memcpy(clone-backed_up_arg_types_stack, 
 orig-backed_up_arg_types_stack, stack_size);
 +
 +   /* We have to add refs to the objects in the arg 
 types stack (the
 +* object is always the second element of a 
 three-pack. */
 +   {
 +   int i, stack_frames = 
 clone-backed_up_arg_types_stack_count / 3;
 +   for (i = 0; i  stack_frames; i++) {
 +   zval *object = (zval *) 
 clone-backed_up_arg_types_stack[3*i + 1];
 +   if (object) {
 +   Z_ADDREF_P(object);
 +   }
 +   }
 +   }
 +   }
 +
 /* Update the send_target to use the temporary variable with 
 the same
  * offset as the original generator, but in our temporary 
 variable
  * memory segment. */
 @@ -449,6 +483,7 @@ void zend_generator_resume(zend_generator *generator 
 TSRMLS_DC) /* {{{ */
 zval *original_This = EG(This);
 zend_class_entry *original_scope = EG(scope);
 zend_class_entry *original_called_scope = EG(called_scope);
 +   

[PHP-CVS] svn: /SVNROOT/ global_avail

2012-09-22 Thread David Soria Parra
dsp  Sat, 22 Sep 2012 18:01:26 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=327746

Log:
move stomp to git

Changed paths:
U   SVNROOT/global_avail

Modified: SVNROOT/global_avail
===
--- SVNROOT/global_avail2012-09-22 14:36:55 UTC (rev 327745)
+++ SVNROOT/global_avail2012-09-22 18:01:26 UTC (rev 327746)
@@ -328,7 +328,7 @@
 avail|devour|pecl/geoip
 avail|iekpo,fyb3roptik|pecl/solr,phpdoc
 avail|ruslany,ksingla,donraman,jennylaw,ericsten|pecl/wincache,phpdoc
-avail|pierrick|pecl/stomp,phpdoc,php-src.git/branches/LEMON
+avail|pierrick|pecl/tools/stomp.git,phpdoc,php-src.git/branches/LEMON
 avail|cyberspice|pecl/dio,pecl/framegrab,phpdoc,pecl/dbus
 avail|crodas|pecl/textcat,phpdoc
 avail|dmendolia,patrickallaert,dragoonis|pecl/apm,phpdoc

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] com php-src: Return previous error handler when resetting the error handler: Zend/tests/bug60738.phpt Zend/tests/bug60738_variation.phpt Zend/zend_builtin_functions.c

2012-09-22 Thread Nikita Popov
Commit:f28c128b207ae2c6ea4d8f6c2e66f5b709210a23
Author:Nikita Popov ni...@php.net Sat, 24 Mar 2012 13:10:51 +0100
Parents:   c815dd74bc42c8f36ba35b910f45e85a645d7e3d
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=f28c128b207ae2c6ea4d8f6c2e66f5b709210a23

Log:
Return previous error handler when resetting the error handler

set_error_handler(null) and set_exception_handler(null) now return the
previous error/exception handler instead of just returning bool(true).
This is consistent with the behavior of these functions with non-null
values.

Changed paths:
  M  Zend/tests/bug60738.phpt
  A  Zend/tests/bug60738_variation.phpt
  M  Zend/zend_builtin_functions.c


Diff:
diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt
index e0c9793..e408071 100644
--- a/Zend/tests/bug60738.phpt
+++ b/Zend/tests/bug60738.phpt
@@ -3,15 +3,20 @@ Bug #60738 Allow 'set_error_handler' to handle NULL
 --FILE--
 ?php
 
-set_error_handler(function() { echo 'Intercepted error!', \n; });
+var_dump(set_error_handler(
+function() { echo 'Intercepted error!', \n; }
+));
 
 trigger_error('Error!');
 
-set_error_handler(null);
+var_dump(set_error_handler(null));
 
 trigger_error('Error!');
 ?
 --EXPECTF--
+NULL
 Intercepted error!
+object(Closure)#1 (0) {
+}
 
 Notice: Error! in %s on line %d
diff --git a/Zend/tests/bug60738_variation.phpt 
b/Zend/tests/bug60738_variation.phpt
new file mode 100644
index 000..d7cf00e
--- /dev/null
+++ b/Zend/tests/bug60738_variation.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #60738 Allow 'set_error_handler' to handle NULL
+--FILE--
+?php
+
+var_dump(set_exception_handler(
+function() { echo 'Intercepted exception!', \n; }
+));
+
+var_dump(set_exception_handler(null));
+
+throw new Exception('Exception!');
+?
+--EXPECTF--
+NULL
+object(Closure)#1 (0) {
+}
+
+Fatal error: Uncaught exception 'Exception' with message 'Exception!' in %s:%d
+Stack trace:
+#0 {main}
+  thrown in %s on line %d
+
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 204c7d3..fdfe3db 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1543,7 +1543,7 @@ ZEND_FUNCTION(set_error_handler)
if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler 
*/
FREE_ZVAL(EG(user_error_handler));
EG(user_error_handler) = NULL;
-   RETURN_TRUE;
+   return;
}
 
EG(user_error_handler_error_reporting) = (int)error_type;
@@ -1614,7 +1614,7 @@ ZEND_FUNCTION(set_exception_handler)
if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined 
handler */
FREE_ZVAL(EG(user_exception_handler));
EG(user_exception_handler) = NULL;
-   RETURN_TRUE;
+   return;
}
 
MAKE_COPY_ZVAL(exception_handler, EG(user_exception_handler))


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Revert error/exception handler changes: Zend/tests/bug60738.phpt Zend/zend_builtin_functions.c

2012-09-22 Thread Nikita Popov
Commit:4954aba2edbc4e29b8b18837298016b435ff7968
Author:Nikita Popov ni...@php.net Sat, 22 Sep 2012 21:41:51 +0200
Parents:   a31fa55b44bcb342c00e9ab2f4a851d054897a39
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=4954aba2edbc4e29b8b18837298016b435ff7968

Log:
Revert error/exception handler changes

This reverts the following two commits:

 * 6ba2e662e447f369c6e7686e8b39dde033fd5334
 * d8f8e98d8e0493adf1fae622595bd3435bdbf835

Laruence already did some partial changes to set_error_handler and
set_exception_handler. I'm reverting those modifications to apply the full
set of changes. (The modifications changed the code structure in a way that
would lead to more duplication with the new behavior.)

Changed paths:
  D  Zend/tests/bug60738.phpt
  M  Zend/zend_builtin_functions.c


Diff:
diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt
deleted file mode 100644
index e0c9793..000
--- a/Zend/tests/bug60738.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-Bug #60738 Allow 'set_error_handler' to handle NULL
---FILE--
-?php
-
-set_error_handler(function() { echo 'Intercepted error!', \n; });
-
-trigger_error('Error!');
-
-set_error_handler(null);
-
-trigger_error('Error!');
-?
---EXPECTF--
-Intercepted error!
-
-Notice: Error! in %s on line %d
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index f8d4674..eab98ed 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1512,6 +1512,7 @@ ZEND_FUNCTION(trigger_error)
 ZEND_FUNCTION(set_error_handler)
 {
zval *error_handler;
+   zend_bool had_orig_error_handler=0;
char *error_handler_name = NULL;
long error_type = E_ALL;
 
@@ -1519,41 +1520,38 @@ ZEND_FUNCTION(set_error_handler)
return;
}
 
-   if (IS_NULL != Z_TYPE_P(error_handler)) {
-   zend_bool had_orig_error_handler = 0;
-   if (!zend_is_callable(error_handler, 0, error_handler_name 
TSRMLS_CC)) {
-   zend_error(E_WARNING, %s() expects the argument (%s) 
to be a valid callback,
-   get_active_function_name(TSRMLS_C), 
error_handler_name?error_handler_name:unknown);
-   efree(error_handler_name);
-   return;
-   }
+   if (!zend_is_callable(error_handler, 0, error_handler_name TSRMLS_CC)) 
{
+   zend_error(E_WARNING, %s() expects the argument (%s) to be a 
valid callback,
+  get_active_function_name(TSRMLS_C), 
error_handler_name?error_handler_name:unknown);
efree(error_handler_name);
+   return;
+   }
+   efree(error_handler_name);
 
-   if (EG(user_error_handler)) {
-   had_orig_error_handler = 1;
-   *return_value = *EG(user_error_handler);
-   zval_copy_ctor(return_value);
-   INIT_PZVAL(return_value);
-   
zend_stack_push(EG(user_error_handlers_error_reporting), 
EG(user_error_handler_error_reporting), 
sizeof(EG(user_error_handler_error_reporting)));
-   zend_ptr_stack_push(EG(user_error_handlers), 
EG(user_error_handler));
-   }
-
-   ALLOC_ZVAL(EG(user_error_handler));
-   EG(user_error_handler_error_reporting) = (int)error_type;
-   MAKE_COPY_ZVAL(error_handler, EG(user_error_handler));
-
-   if (!had_orig_error_handler) {
-   RETURN_NULL();
-   }
-   } else { /* unset user-defined handler */
-   if (EG(user_error_handler)) {
-   
zend_stack_push(EG(user_error_handlers_error_reporting), 
EG(user_error_handler_error_reporting), 
sizeof(EG(user_error_handler_error_reporting)));
-   zend_ptr_stack_push(EG(user_error_handlers), 
EG(user_error_handler));
-   }
+   if (EG(user_error_handler)) {
+   had_orig_error_handler = 1;
+   *return_value = *EG(user_error_handler);
+   zval_copy_ctor(return_value);
+   INIT_PZVAL(return_value);
+   zend_stack_push(EG(user_error_handlers_error_reporting), 
EG(user_error_handler_error_reporting), 
sizeof(EG(user_error_handler_error_reporting)));
+   zend_ptr_stack_push(EG(user_error_handlers), 
EG(user_error_handler));
+   }
+   ALLOC_ZVAL(EG(user_error_handler));
 
+   if (!zend_is_true(error_handler)) { /* unset user-defined handler */
+   FREE_ZVAL(EG(user_error_handler));
EG(user_error_handler) = NULL;
RETURN_TRUE;
}
+
+   EG(user_error_handler_error_reporting) = (int)error_type;
+   *EG(user_error_handler) = *error_handler;
+   zval_copy_ctor(EG(user_error_handler));
+   INIT_PZVAL(EG(user_error_handler));
+
+   if (!had_orig_error_handler) {
+

[PHP-CVS] com php-src: Simplify set_error_handler/set_exception_handler code: Zend/zend_builtin_functions.c

2012-09-22 Thread Nikita Popov
Commit:5c7dd7811ef34c8cbe8bdad333678809f649d383
Author:Nikita Popov ni...@php.net Sat, 24 Mar 2012 13:48:11 +0100
Parents:   f28c128b207ae2c6ea4d8f6c2e66f5b709210a23
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=5c7dd7811ef34c8cbe8bdad333678809f649d383

Log:
Simplify set_error_handler/set_exception_handler code

Changed paths:
  M  Zend/zend_builtin_functions.c


Diff:
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index fdfe3db..698ef72 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1512,7 +1512,6 @@ ZEND_FUNCTION(trigger_error)
 ZEND_FUNCTION(set_error_handler)
 {
zval *error_handler;
-   zend_bool had_orig_error_handler=0;
char *error_handler_name = NULL;
long error_type = E_ALL;
 
@@ -1531,29 +1530,20 @@ ZEND_FUNCTION(set_error_handler)
}
 
if (EG(user_error_handler)) {
-   had_orig_error_handler = 1;
-   *return_value = *EG(user_error_handler);
-   zval_copy_ctor(return_value);
-   INIT_PZVAL(return_value);
+   RETVAL_ZVAL(EG(user_error_handler), 1, 0);
+
zend_stack_push(EG(user_error_handlers_error_reporting), 
EG(user_error_handler_error_reporting), 
sizeof(EG(user_error_handler_error_reporting)));
zend_ptr_stack_push(EG(user_error_handlers), 
EG(user_error_handler));
}
-   ALLOC_ZVAL(EG(user_error_handler));
 
if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler 
*/
-   FREE_ZVAL(EG(user_error_handler));
EG(user_error_handler) = NULL;
return;
}
 
+   ALLOC_ZVAL(EG(user_error_handler));
+   MAKE_COPY_ZVAL(error_handler, EG(user_error_handler));
EG(user_error_handler_error_reporting) = (int)error_type;
-   *EG(user_error_handler) = *error_handler;
-   zval_copy_ctor(EG(user_error_handler));
-   INIT_PZVAL(EG(user_error_handler));
-
-   if (!had_orig_error_handler) {
-   RETURN_NULL();
-   }
 }
 /* }}} */
 
@@ -1587,7 +1577,6 @@ ZEND_FUNCTION(set_exception_handler)
 {
zval *exception_handler;
char *exception_handler_name = NULL;
-   zend_bool had_orig_exception_handler=0;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z, 
exception_handler) == FAILURE) {
return;
@@ -1604,24 +1593,18 @@ ZEND_FUNCTION(set_exception_handler)
}
 
if (EG(user_exception_handler)) {
-   had_orig_exception_handler = 1;
-   *return_value = *EG(user_exception_handler);
-   zval_copy_ctor(return_value);
+   RETVAL_ZVAL(EG(user_exception_handler), 1, 0);
+
zend_ptr_stack_push(EG(user_exception_handlers), 
EG(user_exception_handler));
}
-   ALLOC_ZVAL(EG(user_exception_handler));
 
if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined 
handler */
-   FREE_ZVAL(EG(user_exception_handler));
EG(user_exception_handler) = NULL;
return;
}
 
+   ALLOC_ZVAL(EG(user_exception_handler));
MAKE_COPY_ZVAL(exception_handler, EG(user_exception_handler))
-
-   if (!had_orig_exception_handler) {
-   RETURN_NULL();
-   }
 }
 /* }}} */


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Add NEWS/UPGRADING for previous change: NEWS UPGRADING

2012-09-22 Thread Nikita Popov
Commit:5de79f9f0717d147b02033e270bea20561707db8
Author:Nikita Popov ni...@php.net Sat, 22 Sep 2012 21:54:59 +0200
Parents:   5c7dd7811ef34c8cbe8bdad333678809f649d383
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=5de79f9f0717d147b02033e270bea20561707db8

Log:
Add NEWS/UPGRADING for previous change

Changed paths:
  M  NEWS
  M  UPGRADING


Diff:
diff --git a/NEWS b/NEWS
index d54cc1c..00a2dd6 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,8 @@ PHP   
 NEWS
 (srgoogleguy, Gustavo)
   . Implemented FR #60738 (Allow 'set_error_handler' to handle NULL).
 (Laruence, Nikita Popov)
+  . Return previous handler when passing NULL to set_error_handler and
+set_exception_handler. (Nikita Popov)
   . Added optional second argument for assert() to specify custom message. 
Patch
 by Lonny Kapelushnik (lo...@lonnylot.com). (Lars)
 
diff --git a/UPGRADING b/UPGRADING
index 59dfbb4..bc5773c 100755
--- a/UPGRADING
+++ b/UPGRADING
@@ -107,6 +107,10 @@ PHP X.Y UPGRADE NOTES
   but that predated the existence of E_DEPRECATED.
 - php_logo_guid(), php_egg_logo_guid(), php_real_logo_guid() and 
   zend_logo_guid() have been removed
+- set_error_handler(NULL) can now be used to reset the error handler.
+  Furthermore both set_error_handler(NULL) and set_exception_handler(NULL) will
+  now return the previously defined error/exception handler. Previously
+  bool(true) was returned.
 
 
 5. New Functions


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Allow resetting the error handler: Zend/tests/bug60738.phpt Zend/zend_builtin_functions.c

2012-09-22 Thread Nikita Popov
Commit:c815dd74bc42c8f36ba35b910f45e85a645d7e3d
Author:Nikita Popov ni...@php.net Sat, 24 Mar 2012 12:52:15 +0100
Parents:   4954aba2edbc4e29b8b18837298016b435ff7968
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=c815dd74bc42c8f36ba35b910f45e85a645d7e3d

Log:
Allow resetting the error handler

This allows the error handler to be reset using set_error_handler(null).
As the code suggests this behavior was already previously intended, but
the callback check was done too strictly.

Changed paths:
  A  Zend/tests/bug60738.phpt
  M  Zend/zend_builtin_functions.c


Diff:
diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt
new file mode 100644
index 000..e0c9793
--- /dev/null
+++ b/Zend/tests/bug60738.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #60738 Allow 'set_error_handler' to handle NULL
+--FILE--
+?php
+
+set_error_handler(function() { echo 'Intercepted error!', \n; });
+
+trigger_error('Error!');
+
+set_error_handler(null);
+
+trigger_error('Error!');
+?
+--EXPECTF--
+Intercepted error!
+
+Notice: Error! in %s on line %d
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index eab98ed..204c7d3 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1520,13 +1520,15 @@ ZEND_FUNCTION(set_error_handler)
return;
}
 
-   if (!zend_is_callable(error_handler, 0, error_handler_name TSRMLS_CC)) 
{
-   zend_error(E_WARNING, %s() expects the argument (%s) to be a 
valid callback,
-  get_active_function_name(TSRMLS_C), 
error_handler_name?error_handler_name:unknown);
+   if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */
+   if (!zend_is_callable(error_handler, 0, error_handler_name 
TSRMLS_CC)) {
+   zend_error(E_WARNING, %s() expects the argument (%s) 
to be a valid callback,
+  get_active_function_name(TSRMLS_C), 
error_handler_name?error_handler_name:unknown);
+   efree(error_handler_name);
+   return;
+   }
efree(error_handler_name);
-   return;
}
-   efree(error_handler_name);
 
if (EG(user_error_handler)) {
had_orig_error_handler = 1;
@@ -1538,7 +1540,7 @@ ZEND_FUNCTION(set_error_handler)
}
ALLOC_ZVAL(EG(user_error_handler));
 
-   if (!zend_is_true(error_handler)) { /* unset user-defined handler */
+   if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler 
*/
FREE_ZVAL(EG(user_error_handler));
EG(user_error_handler) = NULL;
RETURN_TRUE;


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Add NEWS/UPGRADING for previous change: NEWS UPGRADING

2012-09-22 Thread Nikita Popov
For the backstory to those changes (and why the commit history is
rather messy) see

https://bugs.php.net/bug.php?id=60738
https://github.com/php/php-src/pull/18
https://github.com/php/php-src/pull/20
http://markmail.org/message/b4upwtayvoo3j7se

Nikita

On Sat, Sep 22, 2012 at 9:54 PM, Nikita Popov ni...@php.net wrote:
 Commit:5de79f9f0717d147b02033e270bea20561707db8
 Author:Nikita Popov ni...@php.net Sat, 22 Sep 2012 21:54:59 
 +0200
 Parents:   5c7dd7811ef34c8cbe8bdad333678809f649d383
 Branches:  master

 Link:   
 http://git.php.net/?p=php-src.git;a=commitdiff;h=5de79f9f0717d147b02033e270bea20561707db8

 Log:
 Add NEWS/UPGRADING for previous change

 Changed paths:
   M  NEWS
   M  UPGRADING


 Diff:
 diff --git a/NEWS b/NEWS
 index d54cc1c..00a2dd6 100644
 --- a/NEWS
 +++ b/NEWS
 @@ -26,6 +26,8 @@ PHP 
NEWS
  (srgoogleguy, Gustavo)
. Implemented FR #60738 (Allow 'set_error_handler' to handle NULL).
  (Laruence, Nikita Popov)
 +  . Return previous handler when passing NULL to set_error_handler and
 +set_exception_handler. (Nikita Popov)
. Added optional second argument for assert() to specify custom message. 
 Patch
  by Lonny Kapelushnik (lo...@lonnylot.com). (Lars)

 diff --git a/UPGRADING b/UPGRADING
 index 59dfbb4..bc5773c 100755
 --- a/UPGRADING
 +++ b/UPGRADING
 @@ -107,6 +107,10 @@ PHP X.Y UPGRADE NOTES
but that predated the existence of E_DEPRECATED.
  - php_logo_guid(), php_egg_logo_guid(), php_real_logo_guid() and
zend_logo_guid() have been removed
 +- set_error_handler(NULL) can now be used to reset the error handler.
 +  Furthermore both set_error_handler(NULL) and set_exception_handler(NULL) 
 will
 +  now return the previously defined error/exception handler. Previously
 +  bool(true) was returned.

  
  5. New Functions


 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php