Skip to content

Commit 4970926

Browse files
committed
Fixed bug #62763 (register_shutdown_function and extending class)
1 parent e1180b4 commit 4970926

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ PHP NEWS
33
?? ??? 2012, PHP 5.3.16
44

55
- Core:
6+
. Fixed bug #62763 (register_shutdown_function and extending class).
7+
(Laruence)
68
. Fixed bug #62744 (dangling pointers made by zend_disable_class). (Laruence)
79
. Fixed bug #62716 (munmap() is called with the incorrect length).
810

Zend/tests/bug62763.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #62763 (register_shutdown_function and extending class)
3+
--FILE--
4+
<?php
5+
class test1 {
6+
public function __construct() {
7+
register_shutdown_function(array($this, 'shutdown'));
8+
}
9+
public function shutdown() {
10+
exit(__METHOD__);
11+
}
12+
}
13+
14+
class test2 extends test1 {
15+
public function __destruct() {
16+
exit (__METHOD__);
17+
}
18+
}
19+
new test1;
20+
new test2;
21+
?>
22+
--EXPECT--
23+
test1::shutdowntest2::__destruct

ext/standard/basic_functions.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5108,8 +5108,11 @@ void php_free_shutdown_functions(TSRMLS_D) /* {{{ */
51085108
zend_hash_destroy(BG(user_shutdown_function_names));
51095109
FREE_HASHTABLE(BG(user_shutdown_function_names));
51105110
BG(user_shutdown_function_names) = NULL;
5111-
}
5112-
zend_end_try();
5111+
} zend_catch {
5112+
/* maybe shutdown method call exit, we just ignore it */
5113+
FREE_HASHTABLE(BG(user_shutdown_function_names));
5114+
BG(user_shutdown_function_names) = NULL;
5115+
} zend_end_try();
51135116
}
51145117
/* }}} */
51155118

0 commit comments

Comments
 (0)