Commit 7ad1f708 authored by Ondrej Sury's avatar Ondrej Sury

Imported Upstream version 5.5.0~alpha5

parent 54098cf0
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
21 Feb 2013, PHP 5.5.0 Alpha 5
- Core:
. Implemented FR #64175 (Added HTTP codes as of RFC 6585). (Jonh Wendell)
. Fixed bug #64135 (Exceptions from set_error_handler are not always
propagated). (Laruence)
. Fixed bug #63830 (Segfault on undefined function call in nested generator).
(Nikita Popov)
. Fixed bug #60833 (self, parent, static behave inconsistently
case-sensitive). (Stas, mario at include-once dot org)
. Implemented FR #60524 (specify temp dir by php.ini). (ALeX Kazik).
. Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi)
. Added ARMv7/v8 versions of various Zend arithmetic functions that are
implemented using inline assembler (Ard Biesheuvel)
- CLI server:
. Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)
- cURL:
. Implemented FR #46439 - added CURLFile for safer file uploads.
(Stas)
- Intl:
. Cherry-picked UConverter wrapper, which had accidentaly been committed only
to master.
- mysqli
. Added mysqli_begin_transaction()/mysqli::begin_transaction(). Implemented all
options, per MySQL 5.6, which can be used with START TRANSACTION, COMMIT
and ROLLBACK through options to mysqli_commit()/mysqli_rollback() and their
respective OO counterparts. They work in libmysql and mysqlnd mode. (Andrey)
. Added mysqli_savepoint(), mysqli_release_savepoint(). (Andrey)
- mysqlnd
. Add new begin_transaction() call to the connection object. Implemented all
options, per MySQL 5.6, which can be used with START TRANSACTION, COMMIT
and ROLLBACK. (Andrey)
. Added mysqlnd_savepoint(), mysqlnd_release_savepoint(). (Andrey)
- Sockets:
. Added recvmsg() and sendmsg() wrappers. (Gustavo)
See https://wiki.php.net/rfc/sendrecvmsg
- Filter:
. Implemented FR #49180 - added MAC address validation. (Martin)
- SNMP:
. Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin)
24 Jan 2013, PHP 5.5.0 Alpha 4
- Core:
......
......@@ -64,9 +64,9 @@ Do not use abbreviations for alpha and beta.
``git push --tags origin HEAD``
8. run: ``./makedist 5.4.2RC2``, this will export the tree, create configure
and build two tarballs (one gz and one bz2).
and build three tarballs (gz,bz2 and xz).
9. Copy those two tarballs to www.php.net, in your homedir there should be a
9. Copy those three tarballs to www.php.net, in your homedir there should be a
directory "downloads/". Copy them into there, so that the system can generate
MD5 sums. If you do not have this directory, talk to Derick.
......
......@@ -24,6 +24,8 @@ PHP 5.5 UPGRADE NOTES
- Drop Windows XP and 2003 support. (Pierre)
- All internal case insensitivity handling for class, function and constant
names is done according to ASCII rules, current locale settings are ignored.
- self, parent & static keywords now are always case-insensitive (see bug
#60833).
- php_logo_guid(), php_egg_logo_guid(), php_real_logo_guid() and
zend_logo_guid() have been removed
- Removal of Logo GUIDs
......@@ -75,6 +77,8 @@ PHP 5.5 UPGRADE NOTES
for example. (https://wiki.php.net/rfc/empty_isset_exprs)
- Added generators.
(https://wiki.php.net/rfc/generators)
- ClassName::class syntax returning full class name for a class as
a string constant. (https://wiki.php.net/rfc/class_name_scalars)
========================================
2. Changes in SAPI modules
......@@ -149,6 +153,12 @@ PHP 5.5 UPGRADE NOTES
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.
- setcookie(), setrawcookie() and ext/session now send Max-Age headers alongside
Expires headers. (see https://wiki.php.net/rfc/cookie_max-age)
- curl_setopt now accepts new option CURLOPT_SAFE_UPLOAD and CURLFile object for
safer file uploads (see https://wiki.php.net/rfc/curl-file-upload)
- Functions in the socket extension now do not emit warnings when the errno is
EAGAIN, EWOULDBLOCK or EINPROGRESS.
========================================
5. New Functions
......@@ -161,6 +171,9 @@ PHP 5.5 UPGRADE NOTES
- password_needs_rehash()
- password_verify()
- cURL:
- curl_file_create
- Hash:
- hash_pbkdf2()
......@@ -246,6 +259,11 @@ PHP 5.5 UPGRADE NOTES
- IntlDateFormatter::getTimeZone()
- IntlDateFormatter::setTimeZone()
- Sockets:
- socket_sendmsg()
- socket_recvmsg()
- socket_cmsg_space()
- SPL:
- SplFixedArray::__wakeup()
......@@ -260,6 +278,10 @@ PHP 5.5 UPGRADE NOTES
- IntlBreakIterator
- IntlRuleBasedBreakIterator
- IntlCodePointBreakIterator
- UConverter
- cURL:
- CURLFile
========================================
7. Removed Extensions
......@@ -280,10 +302,16 @@ PHP 5.5 UPGRADE NOTES
- mysqli:
- Added MYSQLI_SERVER_PUBLIC_KEY constant to be used with mysqli_options()
- cURL:
- Added CURLOPT_SAFE_UPLOAD to be used with curl_setopt().
========================================
10. Changes to INI File Handling
========================================
- Core:
- Added sys_temp_dir INI directive, for specifying temp firectory.
- Intl:
- Added intl.use_exceptions INI directive, which controls what happens when
global errors are set together with intl.error_level.
......
......@@ -13,10 +13,8 @@ function eh()
set_error_handler("eh");
$a = $empty($b);
--EXPECTF--
Warning: Uncaught exception 'Exception' with message 'error!' in %sbug51394.php:4
Fatal error: Uncaught exception 'Exception' with message 'error!' in %sbug51394.php:%d
Stack trace:
#0 %sbug51394.php(9): eh(8, 'Undefined varia...', '%s', 9, Array)
#0 %sbug51394.php(%d): eh(8, 'Undefined varia%s', '%s', %d, Array)
#1 {main}
thrown in %sbug51394.php on line 4
Fatal error: Function name must be a string in %sbug51394.php on line 9
\ No newline at end of file
thrown in %sbug51394.php on line %d
--TEST--
Bug #60833 (self, parent, static behave inconsistently case-sensitive)
--FILE--
<?php
class A {
static $x = "A";
function testit() {
$this->v1 = new sELF;
$this->v2 = new SELF;
}
}
class B extends A {
static $x = "B";
function testit() {
PARENT::testit();
$this->v3 = new sELF;
$this->v4 = new PARENT;
$this->v4 = STATIC::$x;
}
}
$t = new B();
$t->testit();
var_dump($t);
?>
--EXPECTF--
object(B)#%d (4) {
["v1"]=>
object(A)#%d (0) {
}
["v2"]=>
object(A)#%d (0) {
}
["v3"]=>
object(B)#%d (0) {
}
["v4"]=>
string(1) "B"
}
......@@ -17,18 +17,16 @@ $undefined->foo();
--EXPECTF--
Error handler called (Undefined variable: undefined)
Warning: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in %sbug61767.php:13
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in %sbug61767.php:%d
Stack trace:
#0 %sbug61767.php(13): {closure}(8, 'Undefined varia...', '%s', 13, Array)
#0 %sbug61767.php(%d): {closure}(%s, 'Undefined varia...', '%s', %d, Array)
#1 {main}
thrown in %sbug61767.php on line 13
Fatal error: Call to a member function foo() on a non-object in %sbug61767.php on line 13
thrown in %sbug61767.php on line %d
Shutting down
Array
(
[type] => 1
[message] => Call to a member function foo() on a non-object
[message] => %a
[file] => %sbug61767.php
[line] => 13
[line] => %d
)
--TEST--
Bug #64135 (Exceptions from set_error_handler are not always propagated)
--FILE--
<?php
function exception_error_handler() {
throw new Exception();
}
set_error_handler("exception_error_handler");
try {
$undefined->undefined();
} catch(Exception $e) {
echo "Exception is thrown";
}
--EXPECT--
Exception is thrown
--TEST--
Exceptions before fatal error
--FILE--
<?php
function exception_error_handler($code, $msg) {
throw new Exception($msg);
}
set_error_handler("exception_error_handler");
try {
$foo->a();
} catch(Exception $e) {
var_dump($e->getMessage());
}
try {
new $foo();
} catch(Exception $e) {
var_dump($e->getMessage());
}
try {
throw $foo;
} catch(Exception $e) {
var_dump($e->getMessage());
}
try {
$foo();
} catch(Exception $e) {
var_dump($e->getMessage());
}
try {
$foo::b();
} catch(Exception $e) {
var_dump($e->getMessage());
}
try {
$b = clone $foo;
} catch(Exception $e) {
var_dump($e->getMessage());
}
class b {
}
try {
b::$foo();
} catch(Exception $e) {
var_dump($e->getMessage());
}
?>
--EXPECT--
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
--TEST--
Tests cloning a generator with properties
--FILE--
<?php
function gen() { yield; }
$g1 = gen();
$g1->prop = 'val';
$g2 = clone $g1;
unset($g1);
var_dump($g2->prop);
?>
--EXPECT--
string(3) "val"
--TEST--
finally is run on object dtor, not free
--FILE--
<?php
function gen() {
try {
yield;
} finally {
var_dump($_GET);
}
}
$gen = gen();
$gen->rewind();
set_error_handler(function() use($gen) {});
?>
--EXPECT--
array(0) {
}
--TEST--
Test nested calls with die() in a generator
--FILE--
<?php
function gen() {
die('Test');
yield; // force generator
}
function function_with_3_args() {
$gen = gen();
$gen->rewind();
}
function function_with_4_args() {
function_with_3_args(4, 5, 6);
}
function outerGen() {
function_with_4_args(0, 1, 2, 3);
yield; // force generator
}
$outerGen = outerGen();
$outerGen->rewind();
?>
--EXPECT--
Test
--TEST--
Bug #64070 (Inheritance with Traits failed with error)
--FILE--
<?php
trait first_trait
{
function first_function()
{
echo "From First Trait\n";
}
}
trait second_trait
{
use first_trait {
first_trait::first_function as second_function;
}
function first_function()
{
echo "From Second Trait\n";
}
}
class first_class
{
use second_trait;
}
$obj = new first_class();
$obj->first_function();
$obj->second_function();
?>
--EXPECT--
From Second Trait
From First Trait
......@@ -60,7 +60,7 @@ typedef struct _zend_fcall_info_cache {
zval *object_ptr;
} zend_fcall_info_cache;
#define ZEND_NS_NAME(ns, name) ns"\\"name
#define ZEND_NS_NAME(ns, name) ns "\\" name
#define ZEND_FN(name) zif_##name
#define ZEND_MN(name) zim_##name
......@@ -281,9 +281,9 @@ ZEND_API void zend_class_implements(zend_class_entry *class_entry TSRMLS_DC, int
ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_class_entry *ce TSRMLS_DC);
#define zend_register_class_alias(name, ce) \
zend_register_class_alias_ex(name, sizeof(name)-1, ce TSRMLS_DC)
zend_register_class_alias_ex(name, sizeof(name)-1, ce TSRMLS_CC)
#define zend_register_ns_class_alias(ns, name, ce) \
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce TSRMLS_DC)
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce TSRMLS_CC)
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC);
ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC);
......
......@@ -667,17 +667,19 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
#if defined(__GNUC__) && (defined(__native_client__) || defined(i386))
unsigned int n;
__asm__("bsrl %1,%0\n\t" : "=r" (n) : "rm" (_size));
__asm__("bsrl %1,%0\n\t" : "=r" (n) : "rm" (_size) : "cc");
return n;
#elif defined(__GNUC__) && defined(__x86_64__)
unsigned long n;
__asm__("bsrq %1,%0\n\t" : "=r" (n) : "rm" (_size));
__asm__("bsrq %1,%0\n\t" : "=r" (n) : "rm" (_size) : "cc");
return (unsigned int)n;
#elif defined(_MSC_VER) && defined(_M_IX86)
__asm {
bsr eax, _size
}
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
return (8 * SIZEOF_SIZE_T - 1) - __builtin_clzl(_size);
#else
unsigned int n = 0;
while (_size != 0) {
......@@ -693,17 +695,19 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
#if defined(__GNUC__) && (defined(__native_client__) || defined(i386))
unsigned int n;
__asm__("bsfl %1,%0\n\t" : "=r" (n) : "rm" (_size));
__asm__("bsfl %1,%0\n\t" : "=r" (n) : "rm" (_size) : "cc");
return n;
#elif defined(__GNUC__) && defined(__x86_64__)
unsigned long n;
__asm__("bsfq %1,%0\n\t" : "=r" (n) : "rm" (_size));
__asm__("bsfq %1,%0\n\t" : "=r" (n) : "rm" (_size) : "cc");
return (unsigned int)n;
#elif defined(_MSC_VER) && defined(_M_IX86)
__asm {
bsf eax, _size
}
}
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
return __builtin_ctzl(_size);
#else
static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
unsigned int n;
......@@ -2494,6 +2498,47 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
return res;
}
#elif defined(__GNUC__) && defined(__arm__)
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
{
size_t res;
unsigned long overflow;
__asm__ ("umlal %0,%1,%2,%3"
: "=r"(res), "=r"(overflow)
: "r"(nmemb),
"r"(size),
"0"(offset),
"1"(0));
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
return 0;
}
return res;
}
#elif defined(__GNUC__) && defined(__aarch64__)
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
{
size_t res;
unsigned long overflow;
__asm__ ("mul %0,%2,%3\n\tumulh %1,%2,%3\n\tadds %0,%0,%4\n\tadc %1,%1,%1"
: "=&r"(res), "=&r"(overflow)
: "r"(nmemb),
"r"(size),
"r"(offset));
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
return 0;
}
return res;
}
#elif SIZEOF_SIZE_T == 4 && defined(HAVE_ZEND_LONG64)
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
......
This diff is collapsed.
......@@ -27,6 +27,8 @@
ZEND_API zend_class_entry *zend_ce_generator;
static zend_object_handlers zend_generator_handlers;
static zend_object_value zend_generator_create(zend_class_entry *class_type TSRMLS_DC);
ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC) /* {{{ */
{
if (generator->value) {
......@@ -43,41 +45,6 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
zend_execute_data *execute_data = generator->execute_data;
zend_op_array *op_array = execute_data->op_array;
if (!finished_execution) {
if (op_array->has_finally_block) {
/* -1 required because we want the last run opcode, not the
* next to-be-run one. */
zend_uint op_num = execute_data->opline - op_array->opcodes - 1;
zend_uint finally_op_num = 0;
/* Find next finally block */
int i;
for (i = 0; i < op_array->last_try_catch; i++) {
zend_try_catch_element *try_catch = &op_array->try_catch_array[i];
if (op_num < try_catch->try_op) {
break;
}
if (op_num < try_catch->finally_op) {
finally_op_num = try_catch->finally_op;
}
}
/* If a finally block was found we jump directly to it and
* resume the generator. Furthermore we abort this close call
* because the generator will already be closed somewhere in
* the resume. */
if (finally_op_num) {
execute_data->opline = &op_array->opcodes[finally_op_num];
execute_data->fast_ret = NULL;
generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
zend_generator_resume(generator TSRMLS_CC);
return;
}
}
}
if (!execute_data->symbol_table) {
zend_free_compiled_variables(execute_data);
} else {
......@@ -127,10 +94,16 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
/* Clear any backed up stack arguments */
if (generator->stack != EG(argument_stack)) {
void **stack_frame = zend_vm_stack_frame_base(execute_data);
while (generator->stack->top != stack_frame) {
zval_ptr_dtor((zval**)stack_frame);
stack_frame++;
void **ptr = generator->stack->top - 1;
void **end = zend_vm_stack_frame_base(execute_data);
/* If the top stack element is the argument count, skip it */
if (execute_data->function_state.arguments) {
ptr--;
}
for (; ptr >= end; --ptr) {
zval_ptr_dtor((zval**) ptr);
}
}
......@@ -175,6 +148,45 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
}
/* }}} */
static void zend_generator_dtor_storage(zend_generator *generator, zend_object_handle handle TSRMLS_DC) /* {{{ */
{
zend_execute_data *ex = generator->execute_data;
zend_uint op_num, finally_op_num;
int i;
if (!ex || !ex->op_array->has_finally_block) {
return;
}
/* -1 required because we want the last run opcode, not the
* next to-be-run one. */
op_num = ex->opline - ex->op_array->opcodes - 1;
/* Find next finally block */
finally_op_num = 0;
for (i = 0; i < ex->op_array->last_try_catch; i++) {
zend_try_catch_element *try_catch = &ex->op_array->try_catch_array[i];
if (op_num < try_catch->try_op) {
break;
}
if (op_num < try_catch->finally_op) {
finally_op_num = try_catch->finally_op;
}
}
/* If a finally block was found we jump directly to it and
* resume the generator. */
if (finally_op_num) {
ex->opline = &ex->op_array->opcodes[finally_op_num];
ex->fast_ret = NULL;
generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
zend_generator_resume(generator TSRMLS_CC);
}
}
/* }}} */
static void zend_generator_free_storage(zend_generator *generator TSRMLS_DC) /* {{{ */
{
zend_generator_close(generator, 0 TSRMLS_CC);
......@@ -184,10 +196,19 @@ static void zend_generator_free_storage(zend_generator *generator TSRMLS_DC) /*
}
/* }}} */
static void zend_generator_clone_storage(zend_generator *orig, zend_generator **clone_ptr TSRMLS_DC) /* {{{ */
static zend_object_value zend_generator_clone(zval *object TSRMLS_DC) /* {{{ */
{
zend_generator *clone = emalloc(sizeof(zend_generator));
memcpy(clone, orig, sizeof(zend_generator));
zend_generator *orig = zend_object_store_get_object(object TSRMLS_CC);
zend_object_value clone_val = zend_generator_create(Z_OBJCE_P(object) TSRMLS_CC);
zend_generator *clone = zend_object_store_get_object_by_handle(clone_val.handle TSRMLS_CC);
zend_objects_clone_members(
&clone->std, clone_val, &orig->std, Z_OBJ_HANDLE_P(object) TSRMLS_CC
);
clone->execute_data = orig->execute_data;
clone->largest_used_integer_key = orig->largest_used_integer_key;
clone->flags = orig->flags;
if (orig->execute_data) {
/* Create a few shorter aliases to the old execution data */
......@@ -331,14 +352,16 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
/* The value and key are known not to be references, so simply add refs */
if (orig->value) {
clone->value = orig->value;
Z_ADDREF_P(orig->value);
}
if (orig->key) {
clone->key = orig->key;
Z_ADDREF_P(orig->key);