Merge branch 'master' of git.php.net:php-src

This commit is contained in:
Xinchen Hui 2013-11-04 14:47:34 +08:00
commit 2f555b8e60
35 changed files with 1772 additions and 1482 deletions

4
NEWS
View File

@ -1,6 +1,6 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 201?, PHP 5.6.0
?? ??? 20??, PHP 5.6.0
- Core:
. Improved IS_VAR operands fetching. (Laruence, Dmitry)
@ -63,6 +63,8 @@ PHP NEWS
- Standard:
. Implemented FR #65634 (HTTP wrapper is very slow with protocol_version
1.1). (Adam)
. Implemented Change crypt() behavior w/o salt RFC. (Yasuo)
https://wiki.php.net/rfc/crypt_function_salt
- XMLReader:
. Fixed bug #55285 (XMLReader::getAttribute/No/Ns methods inconsistency).

View File

@ -17,7 +17,7 @@ See https://wiki.php.net/rfc and https://wiki.php.net/rfc/voting for more
information on the process.
Bug fixes **do not** require an RFC, but require a bugtracker ticket. Always
open a ticket at http://bugs.php.net and reference the bug id using #NNNNNN.
open a ticket at https://bugs.php.net and reference the bug id using #NNNNNN.
Fix #55371: get_magic_quotes_gpc() throws deprecation warning
@ -28,3 +28,12 @@ open a ticket at http://bugs.php.net and reference the bug id using #NNNNNN.
We do not merge pull requests directly on github. All PRs will be
pulled and pushed through http://git.php.net.
Guidelines for contributors
===========================
- [CODING_STANDARDS](/CODING_STANDARDS)
- [README.GIT-RULES](/README.GIT-RULES)
- [README.MAILINGLIST_RULES](/README.MAILINGLIST_RULES)
- [README.RELEASE_PROCESS](/README.RELEASE_PROCESS)

View File

@ -68,6 +68,10 @@ PHP X.Y UPGRADE NOTES
CURLOPT_SAFE_UPLOAD is now turned on by default and uploads with @file
do not work unless it is explicitly set to false.
- Crypt:
crypt() will now raise an E_NOTICE error if the salt parameter is omitted.
See: https://wiki.php.net/rfc/crypt_function_salt
- XMLReader:
XMLReader::getAttributeNs and XMLReader::getAttributeNo now return NULL if
the attribute could not be found, just like XMLReader::getAttribute.

View File

@ -435,9 +435,7 @@ ZEND_FUNCTION(func_get_arg)
}
arg = *(p-(arg_count-requested_offset));
*return_value = *arg;
zval_copy_ctor(return_value);
INIT_PZVAL(return_value);
RETURN_ZVAL_FAST(arg);
}
/* }}} */
@ -461,12 +459,17 @@ ZEND_FUNCTION(func_get_args)
array_init_size(return_value, arg_count);
for (i=0; i<arg_count; i++) {
zval *element;
zval *element, *arg;
ALLOC_ZVAL(element);
*element = **((zval **) (p-(arg_count-i)));
zval_copy_ctor(element);
INIT_PZVAL(element);
arg = *((zval **) (p-(arg_count-i)));
if (!Z_ISREF_P(arg)) {
element = arg;
Z_ADDREF_P(element);
} else {
ALLOC_ZVAL(element);
INIT_PZVAL_COPY(element, arg);
zval_copy_ctor(element);
}
zend_hash_next_index_insert(return_value->value.ht, &element, sizeof(zval *), NULL);
}
}

View File

@ -79,7 +79,6 @@ static zend_always_inline void zend_pzval_unlock_func(zval *z, zend_free_op *sho
if (unref && Z_ISREF_P(z) && Z_REFCOUNT_P(z) == 1) {
Z_UNSET_ISREF_P(z);
}
GC_ZVAL_CHECK_POSSIBLE_ROOT(z);
}
}
@ -95,6 +94,7 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
#undef zval_ptr_dtor
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC TSRMLS_CC)
#define zval_ptr_dtor_nogc(pzv) i_zval_ptr_dtor_nogc(*(pzv) ZEND_FILE_LINE_CC TSRMLS_CC)
#define PZVAL_UNLOCK(z, f) zend_pzval_unlock_func(z, f, 1 TSRMLS_CC)
#define PZVAL_UNLOCK_EX(z, f, u) zend_pzval_unlock_func(z, f, u TSRMLS_CC)
@ -125,18 +125,18 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
if ((zend_uintptr_t)should_free.var & 1L) { \
zval_dtor((zval*)((zend_uintptr_t)should_free.var & ~1L)); \
} else { \
zval_ptr_dtor(&should_free.var); \
zval_ptr_dtor_nogc(&should_free.var); \
} \
}
#define FREE_OP_IF_VAR(should_free) \
if (should_free.var != NULL && (((zend_uintptr_t)should_free.var & 1L) == 0)) { \
zval_ptr_dtor(&should_free.var); \
zval_ptr_dtor_nogc(&should_free.var); \
}
#define FREE_OP_VAR_PTR(should_free) \
if (should_free.var) { \
zval_ptr_dtor(&should_free.var); \
zval_ptr_dtor_nogc(&should_free.var); \
}
#define TMP_FREE(z) (zval*)(((zend_uintptr_t)(z)) | 1L)

View File

@ -87,6 +87,20 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC
}
}
static zend_always_inline void i_zval_ptr_dtor_nogc(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
if (!Z_DELREF_P(zval_ptr)) {
ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
zval_dtor(zval_ptr);
efree_rel(zval_ptr);
} else {
if (Z_REFCOUNT_P(zval_ptr) == 1) {
Z_UNSET_ISREF_P(zval_ptr);
}
}
}
static zend_always_inline int i_zend_is_true(zval *op)
{
int result;

View File

@ -4492,22 +4492,21 @@ ZEND_VM_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, VAR|UNUSED|CV, CONST|
{
USE_OPLINE
zend_free_op free_op1, free_op2;
zval **container;
zval *container;
zval **value = NULL;
int result = 0;
ulong hval;
zval *offset;
SAVE_OPLINE();
container = GET_OP1_OBJ_ZVAL_PTR_PTR_FAST(BP_VAR_IS);
container = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_IS);
offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) {
if (Z_TYPE_P(container) == IS_ARRAY && !prop_dim) {
HashTable *ht;
int isset = 0;
ht = Z_ARRVAL_PP(container);
ht = Z_ARRVAL_P(container);
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
@ -4526,9 +4525,7 @@ ZEND_VM_C_LABEL(num_index_prop):
if (OP2_TYPE == IS_CONST) {
hval = Z_HASH_P(offset);
} else {
if (!prop_dim) {
ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, ZEND_VM_C_GOTO(num_index_prop));
}
ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, ZEND_VM_C_GOTO(num_index_prop));
hval = str_hash(Z_STRVAL_P(offset), Z_STRLEN_P(offset));
}
if (zend_hash_quick_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, (void **) &value) == SUCCESS) {
@ -4559,20 +4556,20 @@ ZEND_VM_C_LABEL(num_index_prop):
}
}
FREE_OP2();
} else if (Z_TYPE_PP(container) == IS_OBJECT) {
} else if (Z_TYPE_P(container) == IS_OBJECT) {
if (IS_OP2_TMP_FREE()) {
MAKE_REAL_ZVAL_PTR(offset);
}
if (prop_dim) {
if (Z_OBJ_HT_P(*container)->has_property) {
result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (opline->extended_value & ZEND_ISEMPTY) != 0, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
if (Z_OBJ_HT_P(container)->has_property) {
result = Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY) != 0, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
} else {
zend_error(E_NOTICE, "Trying to check property of non-object");
result = 0;
}
} else {
if (Z_OBJ_HT_P(*container)->has_dimension) {
result = Z_OBJ_HT_P(*container)->has_dimension(*container, offset, (opline->extended_value & ZEND_ISEMPTY) != 0 TSRMLS_CC);
if (Z_OBJ_HT_P(container)->has_dimension) {
result = Z_OBJ_HT_P(container)->has_dimension(container, offset, (opline->extended_value & ZEND_ISEMPTY) != 0 TSRMLS_CC);
} else {
zend_error(E_NOTICE, "Trying to check element of non-array");
result = 0;
@ -4583,7 +4580,7 @@ ZEND_VM_C_LABEL(num_index_prop):
} else {
FREE_OP2();
}
} else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
} else if (Z_TYPE_P(container) == IS_STRING && !prop_dim) { /* string offsets */
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
@ -4601,11 +4598,11 @@ ZEND_VM_C_LABEL(num_index_prop):
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_PP(container)) {
if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) {
result = 1;
}
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] != '0') {
if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container) && Z_STRVAL_P(container)[offset->value.lval] != '0') {
result = 1;
}
}
@ -4622,7 +4619,7 @@ ZEND_VM_C_LABEL(num_index_prop):
Z_LVAL(EX_T(opline->result.var).tmp_var) = !result;
}
FREE_OP1_VAR_PTR_FAST();
FREE_OP1_IF_VAR();
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();

File diff suppressed because it is too large Load Diff

View File

@ -218,7 +218,7 @@ $op2_is_tmp_free = array(
$op1_free_op = array(
"ANY" => "FREE_OP(free_op1)",
"TMP" => "zval_dtor(free_op1.var)",
"VAR" => "zval_ptr_dtor(&free_op1.var)",
"VAR" => "zval_ptr_dtor_nogc(&free_op1.var)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
@ -227,7 +227,7 @@ $op1_free_op = array(
$op2_free_op = array(
"ANY" => "FREE_OP(free_op2)",
"TMP" => "zval_dtor(free_op2.var)",
"VAR" => "zval_ptr_dtor(&free_op2.var)",
"VAR" => "zval_ptr_dtor_nogc(&free_op2.var)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
@ -236,7 +236,7 @@ $op2_free_op = array(
$op1_free_op_if_var = array(
"ANY" => "FREE_OP_IF_VAR(free_op1)",
"TMP" => "",
"VAR" => "zval_ptr_dtor(&free_op1.var)",
"VAR" => "zval_ptr_dtor_nogc(&free_op1.var)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
@ -245,33 +245,33 @@ $op1_free_op_if_var = array(
$op2_free_op_if_var = array(
"ANY" => "FREE_OP_IF_VAR(free_op2)",
"TMP" => "",
"VAR" => "zval_ptr_dtor(&free_op2.var)",
"VAR" => "zval_ptr_dtor_nogc(&free_op2.var)",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op1_free_op_var_ptr = array(
"ANY" => "if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}",
"ANY" => "if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);}",
"TMP" => "",
"VAR" => "if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}",
"VAR" => "if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);}",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op1_free_op_var_ptr_fast = $op1_free_op_var_ptr;
$op1_free_op_var_ptr_fast["VAR"] = "zval_ptr_dtor(&free_op1.var)";
$op1_free_op_var_ptr_fast["VAR"] = "zval_ptr_dtor_nogc(&free_op1.var)";
$op2_free_op_var_ptr = array(
"ANY" => "if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}",
"ANY" => "if (free_op2.var) {zval_ptr_dtor_nogc(&free_op2.var);}",
"TMP" => "",
"VAR" => "if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}",
"VAR" => "if (free_op2.var) {zval_ptr_dtor_nogc(&free_op2.var);}",
"CONST" => "",
"UNUSED" => "",
"CV" => "",
);
$op2_free_op_var_ptr_fast = $op2_free_op_var_ptr;
$op2_free_op_var_ptr_fast["VAR"] = "zval_ptr_dtor(&free_op2.var)";
$op2_free_op_var_ptr_fast["VAR"] = "zval_ptr_dtor_nogc(&free_op2.var)";
$list = array(); // list of opcode handlers and helpers in original order
$opcodes = array(); // opcode handlers by code

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,10 @@
#include "php_ini.h"
#include "php_gmp.h"
#include "ext/standard/info.h"
#include "ext/standard/php_var.h"
#include "ext/standard/php_smart_str_public.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#if HAVE_GMP
@ -564,12 +567,17 @@ static int gmp_cast_object(zval *readobj, zval *writeobj, int type TSRMLS_DC) /*
}
/* }}} */
static HashTable *gmp_get_properties(zval *obj TSRMLS_DC) /* {{{ */
static HashTable *gmp_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
{
HashTable *ht = zend_std_get_properties(obj TSRMLS_CC);
HashTable *ht, *props = zend_std_get_properties(obj TSRMLS_CC);
mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(obj);
zval *zv;
*is_temp = 1;
ALLOC_HASHTABLE(ht);
ZEND_INIT_SYMTABLE_EX(ht, zend_hash_num_elements(props) + 1, 0);
zend_hash_copy(ht, props, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
MAKE_STD_ZVAL(zv);
gmp_strval(zv, gmpnum, 10);
zend_hash_update(ht, "num", sizeof("num"), &zv, sizeof(zval *), NULL);
@ -678,36 +686,96 @@ static int gmp_compare(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
}
/* }}} */
PHP_METHOD(GMP, __wakeup) /* {{{ */
PHP_METHOD(GMP, serialize) /* {{{ */
{
HashTable *props;
zval **num_zv;
mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(getThis());
smart_str buf = {0};
php_serialize_data_t var_hash;
zval zv, *zv_ptr = &zv;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
props = zend_std_get_properties(getThis() TSRMLS_CC);
if (zend_hash_find(props, "num", sizeof("num"), (void **) &num_zv) == SUCCESS
&& Z_TYPE_PP(num_zv) == IS_STRING && Z_STRLEN_PP(num_zv) > 0
) {
mpz_ptr gmpnumber = GET_GMP_FROM_ZVAL(getThis());
if (convert_to_gmp(gmpnumber, *num_zv, 10 TSRMLS_CC) == SUCCESS) {
return;
}
}
PHP_VAR_SERIALIZE_INIT(var_hash);
zend_throw_exception(
NULL, "Invalid serialization data", 0 TSRMLS_CC
);
INIT_PZVAL(zv_ptr);
gmp_strval(zv_ptr, gmpnum, 10);
php_var_serialize(&buf, &zv_ptr, &var_hash TSRMLS_CC);
zval_dtor(zv_ptr);
Z_ARRVAL_P(zv_ptr) = zend_std_get_properties(getThis() TSRMLS_CC);
Z_TYPE_P(zv_ptr) = IS_ARRAY;
php_var_serialize(&buf, &zv_ptr, &var_hash TSRMLS_CC);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
if (buf.c) {
RETURN_STRINGL(buf.c, buf.len, 0);
}
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(arginfo_wakeup, 0, 0, 0)
PHP_METHOD(GMP, unserialize) /* {{{ */
{
mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(getThis());
char *str;
int str_len;
php_unserialize_data_t var_hash;
const unsigned char *p, *max;
zval zv, *zv_ptr = &zv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
return;
}
PHP_VAR_UNSERIALIZE_INIT(var_hash);
p = (unsigned char *) str;
max = (unsigned char *) str + str_len;
INIT_ZVAL(zv);
if (!php_var_unserialize(&zv_ptr, &p, max, &var_hash TSRMLS_CC)
|| Z_TYPE_P(zv_ptr) != IS_STRING
|| convert_to_gmp(gmpnum, zv_ptr, 10 TSRMLS_CC) == FAILURE
) {
zend_throw_exception(NULL, "Could not unserialize number", 0 TSRMLS_CC);
goto exit;
}
zval_dtor(&zv);
INIT_ZVAL(zv);
if (!php_var_unserialize(&zv_ptr, &p, max, &var_hash TSRMLS_CC)
|| Z_TYPE_P(zv_ptr) != IS_ARRAY
) {
zend_throw_exception(NULL, "Could not unserialize properties", 0 TSRMLS_CC);
goto exit;
}
if (zend_hash_num_elements(Z_ARRVAL_P(zv_ptr)) != 0) {
zend_hash_copy(
zend_std_get_properties(getThis() TSRMLS_CC), Z_ARRVAL_P(zv_ptr),
(copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)
);
}
exit:
zval_dtor(&zv);
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(arginfo_serialize, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
const zend_function_entry gmp_methods[] = {
PHP_ME(GMP, __wakeup, arginfo_wakeup, ZEND_ACC_PUBLIC)
PHP_ME(GMP, serialize, arginfo_serialize, ZEND_ACC_PUBLIC)
PHP_ME(GMP, unserialize, arginfo_unserialize, ZEND_ACC_PUBLIC)
PHP_FE_END
};
@ -724,13 +792,14 @@ static ZEND_GINIT_FUNCTION(gmp)
ZEND_MINIT_FUNCTION(gmp)
{
zend_class_entry tmp_ce;
INIT_CLASS_ENTRY(tmp_ce, "GMP", gmp_methods); /* No methods on the class for now */
INIT_CLASS_ENTRY(tmp_ce, "GMP", gmp_methods);
gmp_ce = zend_register_internal_class(&tmp_ce TSRMLS_CC);
zend_class_implements(gmp_ce TSRMLS_CC, 1, zend_ce_serializable);
gmp_ce->create_object = gmp_create_object;
memcpy(&gmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
gmp_object_handlers.cast_object = gmp_cast_object;
gmp_object_handlers.get_properties = gmp_get_properties;
gmp_object_handlers.get_debug_info = gmp_get_debug_info;
gmp_object_handlers.clone_obj = gmp_clone_obj;
gmp_object_handlers.do_operation = gmp_do_operation;
gmp_object_handlers.compare = gmp_compare;
@ -1363,7 +1432,7 @@ ZEND_FUNCTION(gmp_powm)
zval *base_arg, *exp_arg, *mod_arg;
mpz_ptr gmpnum_base, gmpnum_exp, gmpnum_mod, gmpnum_result;
int use_ui = 0;
gmp_temp_t temp_base = {0}, temp_exp = {0}, temp_mod;
gmp_temp_t temp_base, temp_exp, temp_mod;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &base_arg, &exp_arg, &mod_arg) == FAILURE){
return;

View File

@ -0,0 +1,15 @@
--TEST--
Bug #65997: Leak when using gc_collect_cycles with new GMP implementation
--SKIPIF--
<?php if (!extension_loaded("gmp")) print "skip"; ?>
--FILE--
<?php
gc_enable();
$gmp = gmp_init('10');
gc_collect_cycles();
?>
===DONE===
--EXPECT--
===DONE===

View File

@ -9,14 +9,34 @@ var_dump($n = gmp_init(42));
var_dump($s = serialize($n));
var_dump(unserialize($s));
$n = gmp_init(13);
$n->foo = "bar";
var_dump(unserialize(serialize($n)));
try {
unserialize('C:3:"GMP":0:{}');
} catch (Exception $e) { var_dump($e->getMessage()); }
try {
unserialize('C:3:"GMP":8:{s:2:"42"}');
} catch (Exception $e) { var_dump($e->getMessage()); }
?>
--EXPECTF--
object(GMP)#%d (1) {
["num"]=>
string(2) "42"
}
string(33) "O:3:"GMP":1:{s:3:"num";s:2:"42";}"
string(30) "C:3:"GMP":15:{s:2:"42";a:0:{}}"
object(GMP)#%d (1) {
["num"]=>
string(2) "42"
}
object(GMP)#%d (2) {
["foo"]=>
string(3) "bar"
["num"]=>
string(2) "13"
}
string(28) "Could not unserialize number"
string(32) "Could not unserialize properties"

View File

@ -232,7 +232,7 @@ typedef struct odbc_connection {
} odbc_connection;
typedef struct odbc_result_value {
char name[32];
char name[256];
char *value;
SQLLEN vallen;
SQLLEN coltype;

View File

@ -80,8 +80,8 @@ opcache.max_accelerated_files (default "2000")
The maximum number of keys (scripts) in the OPcache hash table.
The number is actually the first one in the following set of prime
numbers that is bigger than the one supplied: { 223, 463, 983, 1979, 3907,
7963, 16229, 32531, 65407, 130987 }. Only numbers between 200 and 100000
are allowed.
7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 }. Only numbers
between 200 and 1000000 are allowed.
opcache.max_wasted_percentage (default "5")
The maximum percentage of "wasted" memory until a restart is scheduled.

View File

@ -34,7 +34,7 @@
#define STRING_NOT_NULL(s) (NULL == (s)?"":s)
#define MIN_ACCEL_FILES 200
#define MAX_ACCEL_FILES 100000
#define MAX_ACCEL_FILES 1000000
#define TOKENTOSTR(X) #X
static void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS) = NULL;

View File

@ -127,6 +127,9 @@ PHP_MINIT_FUNCTION(array) /* {{{ */
REGISTER_LONG_CONSTANT("COUNT_NORMAL", COUNT_NORMAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("COUNT_RECURSIVE", COUNT_RECURSIVE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_BOTH", ARRAY_FILTER_USE_BOTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_KEY", ARRAY_FILTER_USE_KEY, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
/* }}} */
@ -2223,13 +2226,14 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
case HASH_KEY_IS_STRING:
if (recursive && zend_hash_find(dest, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) {
HashTable *thash = Z_TYPE_PP(dest_entry) == IS_ARRAY ? Z_ARRVAL_PP(dest_entry) : NULL;
zval *src_zval;
zval *tmp = NULL;
if ((thash && thash->nApplyCount > 1) || (*src_entry == *dest_entry && Z_ISREF_PP(dest_entry) && (Z_REFCOUNT_PP(dest_entry) % 2))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
return 0;
}
SEPARATE_ZVAL(dest_entry);
SEPARATE_ZVAL(src_entry);
if (Z_TYPE_PP(dest_entry) == IS_NULL) {
convert_to_array_ex(dest_entry);
@ -2237,23 +2241,34 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
} else {
convert_to_array_ex(dest_entry);
}
if (Z_TYPE_PP(src_entry) == IS_NULL) {
convert_to_array_ex(src_entry);
add_next_index_null(*src_entry);
if (Z_TYPE_PP(src_entry) == IS_OBJECT) {
ALLOC_ZVAL(src_zval);
INIT_PZVAL_COPY(src_zval, *src_entry);
zval_copy_ctor(src_zval);
convert_to_array(src_zval);
tmp = src_zval;
} else {
convert_to_array_ex(src_entry);
src_zval = *src_entry;
}
if (thash) {
thash->nApplyCount++;
}
if (!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_PP(src_entry), recursive TSRMLS_CC)) {
if (Z_TYPE_P(src_zval) == IS_ARRAY) {
if (thash) {
thash->nApplyCount++;
}
if (!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_P(src_zval), recursive TSRMLS_CC)) {
if (thash) {
thash->nApplyCount--;
}
return 0;
}
if (thash) {
thash->nApplyCount--;
}
return 0;
} else {
Z_ADDREF_PP(src_entry);
zend_hash_next_index_insert(Z_ARRVAL_PP(dest_entry), &src_zval, sizeof(zval *), NULL);
}
if (thash) {
thash->nApplyCount--;
if (tmp) {
zval_ptr_dtor(&tmp);
}
} else {
Z_ADDREF_PP(src_entry);
@ -2357,7 +2372,6 @@ static void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETERS, int
array_init_size(return_value, init_size);
for (i = 0; i < argc; i++) {
SEPARATE_ZVAL(args[i]);
if (!replace) {
php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(args[i]), recursive TSRMLS_CC);
} else if (recursive && i > 0) { /* First array will be copied directly instead */
@ -4194,9 +4208,11 @@ PHP_FUNCTION(array_filter)
{
zval *array;
zval **operand;
zval **args[1];
zval **args[2];
zval *retval = NULL;
zval *key = NULL;
zend_bool have_callback = 0;
long use_type = 0;
char *string_key;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
@ -4204,7 +4220,7 @@ PHP_FUNCTION(array_filter)
ulong num_key;
HashPosition pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|f", &array, &fci, &fci_cache) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|fl", &array, &fci, &fci_cache, &use_type) == FAILURE) {
return;
}
@ -4217,23 +4233,54 @@ PHP_FUNCTION(array_filter)
have_callback = 1;
fci.no_separation = 0;
fci.retval_ptr_ptr = &retval;
fci.param_count = 1;
if (use_type == ARRAY_FILTER_USE_BOTH) {
fci.param_count = 2;
args[1] = &key;
} else {
fci.param_count = 1;
if (use_type == ARRAY_FILTER_USE_KEY) {
args[0] = &key;
}
}
}
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(array), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_P(array), (void **)&operand, &pos) == SUCCESS;
zend_hash_move_forward_ex(Z_ARRVAL_P(array), &pos)
) {
int key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &string_key, &string_key_len, &num_key, 0, &pos);
if (have_callback) {
args[0] = operand;
if (use_type) {
MAKE_STD_ZVAL(key);
/* Set up the key */
switch (key_type) {
case HASH_KEY_IS_LONG:
Z_TYPE_P(key) = IS_LONG;
Z_LVAL_P(key) = num_key;
break;
case HASH_KEY_IS_STRING:
ZVAL_STRINGL(key, string_key, string_key_len - 1, 1);
break;
}
}
if (use_type != ARRAY_FILTER_USE_KEY) {
args[0] = operand;
}
fci.params = args;
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && retval) {
if (!zend_is_true(retval)) {
zval_ptr_dtor(&retval);
int retval_true = zend_is_true(retval);
zval_ptr_dtor(&retval);
if (use_type) {
zval_ptr_dtor(&key);
}
if (!retval_true) {
continue;
} else {
zval_ptr_dtor(&retval);
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the filter callback");
@ -4244,7 +4291,7 @@ PHP_FUNCTION(array_filter)
}
zval_add_ref(operand);
switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &string_key, &string_key_len, &num_key, 0, &pos)) {
switch (key_type) {
case HASH_KEY_IS_STRING:
zend_hash_update(Z_ARRVAL_P(return_value), string_key, string_key_len, operand, sizeof(zval *), NULL);
break;

View File

@ -596,6 +596,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_filter, 0, 0, 1)
ZEND_ARG_INFO(0, arg) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_INFO(0, callback)
ZEND_ARG_INFO(0, use_keys)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_map, 0, 0, 2)

View File

@ -272,6 +272,8 @@ PHP_FUNCTION(crypt)
if (salt_in) {
memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len));
} else {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash.");
}
/* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */

View File

@ -117,6 +117,9 @@ PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC);
#define PHP_SORT_NATURAL 6
#define PHP_SORT_FLAG_CASE 8
#define ARRAY_FILTER_USE_BOTH 1
#define ARRAY_FILTER_USE_KEY 2
ZEND_BEGIN_MODULE_GLOBALS(array)
int *multisort_flags[2];
int (*compare_func)(zval *result, zval *op1, zval *op2 TSRMLS_DC);

View File

@ -28,7 +28,7 @@ $extra_arg = 10;
// with one more than the expected number of arguments
echo "-- Testing array_filter() function with more than expected no. of arguments --";
var_dump( array_filter($input, "odd", $extra_arg) );
var_dump( array_filter($input, "odd", $extra_arg, $extra_arg) );
// with incorrect callback function
echo "-- Testing array_filter() function with incorrect callback --";
@ -42,7 +42,7 @@ echo "Done"
Warning: array_filter() expects at least 1 parameter, 0 given in %s on line %d
NULL
-- Testing array_filter() function with more than expected no. of arguments --
Warning: array_filter() expects at most 2 parameters, 3 given in %s on line %d
Warning: array_filter() expects at most 3 parameters, 4 given in %s on line %d
NULL
-- Testing array_filter() function with incorrect callback --
Warning: array_filter() expects parameter 2 to be a valid callback, function 'even' not found or invalid function name in %s on line %d

View File

@ -0,0 +1,103 @@
--TEST--
Test array_filter() function : usage variations - using the array keys inside 'callback'
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback [, bool $use_type = ARRAY_FILTER_USE_VALUE]])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* Using array keys as an argument to the 'callback'
*/
echo "*** Testing array_filter() : usage variations - using array keys in 'callback' ***\n";
$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null);
$small = array(123);
function dump($value, $key)
{
echo "$key = $value\n";
}
var_dump( array_filter($input, 'dump', true) );
echo "*** Testing array_filter() : usage variations - 'callback' filters based on key value ***\n";
function dump2($value, $key)
{
return $key > 4;
}
var_dump( array_filter($input, 'dump2', true) );
echo "*** Testing array_filter() : usage variations - 'callback' expecting second argument ***\n";
var_dump( array_filter($small, 'dump', false) );
echo "*** Testing array_filter() with various use types ***\n";
$mixed = array(1 => 'a', 2 => 'b', 'a' => 1, 'b' => 2);
var_dump(array_filter($mixed, 'is_numeric', ARRAY_FILTER_USE_KEY));
var_dump(array_filter($mixed, 'is_numeric', 0));
var_dump(array_filter($mixed, 'is_numeric', ARRAY_FILTER_USE_BOTH));
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - using array keys in 'callback' ***
0 = 0
1 = 1
2 = -1
3 = 10
4 = 100
5 = 1000
6 = Hello
7 =
array(0) {
}
*** Testing array_filter() : usage variations - 'callback' filters based on key value ***
array(3) {
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
}
*** Testing array_filter() : usage variations - 'callback' expecting second argument ***
Warning: Missing argument 2 for dump() in %s on line %d
Notice: Undefined variable: key in %s on line %d
= 123
array(0) {
}
*** Testing array_filter() with various use types ***
array(2) {
[1]=>
string(1) "a"
[2]=>
string(1) "b"
}
array(2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
array(0) {
}
Done

View File

@ -784,15 +784,15 @@ string(20) "array (
Iteration 13
array (
0 => 10.5,
1 => 5.6,
1 => 5.5999999999999996,
)
array (
0 => 10.5,
1 => 5.6,
1 => 5.5999999999999996,
)
string(34) "array (
string(49) "array (
0 => 10.5,
1 => 5.6,
1 => 5.5999999999999996,
)"

View File

@ -96,9 +96,9 @@ string(1) "0"
-- Iteration: -0.1 --
-0.1
-0.1
string(4) "-0.1"
-0.10000000000000001
-0.10000000000000001
string(20) "-0.10000000000000001"
-- Iteration: 10.0000000000000000005 --
@ -120,9 +120,9 @@ string(6) "100000"
-- Iteration: 1e-5 --
1.0E-5
1.0E-5
string(6) "1.0E-5"
1.0000000000000001E-5
1.0000000000000001E-5
string(21) "1.0000000000000001E-5"
-- Iteration: 1e+5 --
@ -144,9 +144,9 @@ string(6) "100000"
-- Iteration: 1E-5 --
1.0E-5
1.0E-5
string(6) "1.0E-5"
1.0000000000000001E-5
1.0000000000000001E-5
string(21) "1.0000000000000001E-5"
-- Iteration: .5e+7 --
@ -156,20 +156,20 @@ string(7) "5000000"
-- Iteration: .6e-19 --
6.0E-20
6.0E-20
string(7) "6.0E-20"
6.0000000000000006E-20
6.0000000000000006E-20
string(22) "6.0000000000000006E-20"
-- Iteration: .05E+44 --
5.0E+42
5.0E+42
string(7) "5.0E+42"
5.0000000000000001E+42
5.0000000000000001E+42
string(22) "5.0000000000000001E+42"
-- Iteration: .0034E-30 --
3.4E-33
3.4E-33
string(7) "3.4E-33"
3.4000000000000001E-33
3.4000000000000001E-33
string(22) "3.4000000000000001E-33"
===DONE===

View File

@ -233,15 +233,15 @@ string(20) "array (
--Iteration: array(10.5, 5.6) --
array (
0 => 10.5,
1 => 5.6,
1 => 5.5999999999999996,
)
array (
0 => 10.5,
1 => 5.6,
1 => 5.5999999999999996,
)
string(34) "array (
string(49) "array (
0 => 10.5,
1 => 5.6,
1 => 5.5999999999999996,
)"
@ -274,4 +274,4 @@ string(41) "array (
1 => 'test',
)"
===DONE===
===DONE===

View File

@ -34,6 +34,8 @@ STD
EXT
MD5
BLO
Notice: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash. in %s on line %d
string(%d) "%s"
Warning: crypt() expects at least 1 parameter, 0 given in %s on line %d

View File

@ -436,7 +436,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
smart_str_append_long(buf, Z_LVAL_PP(struc));
break;
case IS_DOUBLE:
tmp_len = spprintf(&tmp_str, 0,"%.*H", (int) EG(precision), Z_DVAL_PP(struc));
tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_PP(struc));
smart_str_appendl(buf, tmp_str, tmp_len);
efree(tmp_str);
break;

27
ext/zip/LICENSE_libzip Normal file
View File

@ -0,0 +1,27 @@
Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
The authors can be contacted at <libzip@nih.at>
Redistribution and use in source and binary forms, with or without
modification, are 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 names of the authors may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
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 AUTHORS 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.

View File

@ -524,8 +524,11 @@ static int sapi_fcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
uint read_bytes = 0;
int tmp_read_bytes;
fcgi_request *request = (fcgi_request*) SG(server_context);
size_t remaining = SG(request_info).content_length - SG(read_post_bytes);
count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes));
if (remaining < count_bytes) {
count_bytes = remaining;
}
while (read_bytes < count_bytes) {
tmp_read_bytes = fcgi_read(request, buffer + read_bytes, count_bytes - read_bytes);
if (tmp_read_bytes <= 0) {

View File

@ -498,8 +498,11 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
{
uint read_bytes = 0;
int tmp_read_bytes;
size_t remaining = SG(request_info).content_length - SG(read_post_bytes);
count_bytes = MIN(count_bytes, (uint) SG(request_info).content_length - SG(read_post_bytes));
if (remaining < count_bytes) {
count_bytes = remaining;
}
while (read_bytes < count_bytes) {
fcgi_request *request = (fcgi_request*) SG(server_context);
if (request_body_fd == -1) {

View File

@ -487,6 +487,7 @@ int fpm_socket_unix_test_connect(struct sockaddr_un *sock, size_t socklen) /* {{
}
if (connect(fd, (struct sockaddr *)sock, socklen) == -1) {
close(fd);
return -1;
}

View File

@ -19,7 +19,7 @@
#if (__FreeBSD__) || (__OpenBSD__)
#define FPM_BACKLOG_DEFAULT -1
#else
#define FPM_BACKLOG_DEFAULT 128
#define FPM_BACKLOG_DEFAULT 65535
#endif
enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);

View File

@ -159,8 +159,8 @@ group = @php_fpm_group@
listen = 127.0.0.1:9000
; Set listen(2) backlog.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 128
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 65535
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many

View File

@ -36,22 +36,22 @@ test(1.7e-1000);
===DONE===
<?php exit(0); ?>
--EXPECTF--
1.7E+300
1.7000000000000001E+300
float(1.7E+300)
1.7E+300
1.7E+300
------
1.7E-300
1.7000000000000001E-300
float(1.7E-300)
1.7E-300
1.7E-300
------
1.7E+79
1.7000000000000002E+79
float(1.7E+79)
1.7E+79
1.7E+79
------
1.7E-79
1.6999999999999999E-79
float(1.7E-79)
1.7E-79
1.7E-79
@ -71,7 +71,7 @@ float(1.7E+81)
1.7E+81
1.7E+81
------
1.7E-81
1.6999999999999999E-81
float(1.7E-81)
1.7E-81
1.7E-81
@ -81,7 +81,7 @@ float(I%s)
I%s
I%s
------
1.69998107421E-319
1.6999810742105611E-319
float(1.69998107421E-319)
1.69998107421E-319
1.69998107421E-319
@ -91,7 +91,7 @@ float(I%s)
I%s
I%s
------
1.70007988734E-320
1.7000798873397294E-320
float(1.70007988734E-320)
1.70007988734E-320
1.70007988734E-320
@ -101,7 +101,7 @@ float(I%s)
I%s
I%s
------
1.69958582169E-321
1.6995858216938881E-321
float(1.69958582169E-321)
1.69958582169E-321
1.69958582169E-321

View File

@ -1,12 +1,11 @@
bz2-1.0.6
cclient-2007f
freetype-2.4.10
icu-50.1.2
icu-51.2
jpeglib-9
libcurl-7.30.0
libiconv-1.14
libmcrypt-2.5.8
libmpir-2.5.1
libmpir-2.6.0
libpng-1.5.14
libpq-9.2.2