diff options
113 files changed, 1487 insertions, 275 deletions
@@ -1,11 +1,61 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -17 Jan 2013, PHP 5.4.11 +21 Feb 2012, PHP 5.4.12 + +- Core: + . Fixed bug #64099 (Wrong TSRM usage in zend_Register_class alias). (Johannes) + . Fixed bug #64011 (get_html_translation_table() output incomplete with + HTML_ENTITIES and ISO-8859-1). (Gustavo) + . Fixed bug #63982 (isset() inconsistently produces a fatal error on + protected property). (Stas) + . Fixed bug #63943 (Bad warning text from strpos() on empty needle). + (Laruence) + . Fixed bug #63899 (Use after scope error in zend_compile). (Laruence) + . Fixed bug #63893 (Poor efficiency of strtr() using array with keys of very + different length). (Gustavo) + . Fixed bug #63882 (zend_std_compare_objects crash on recursion). (Dmitry) + . Fixed bug #63462 (Magic methods called twice for unset protected + properties). (Stas) + . Fixed bug #62524 (fopen follows redirects for non-3xx statuses). + (Wes Mason) + . Support BITMAPV5HEADER in getimagesize(). (AsamK, Lars) + +- Date: + . Fixed bug #63699 (Performance improvements for various ext/date functions). + (Lars, original patch by njaguar at gmail dot com) + . Fixed bug #55397: Comparsion of incomplete DateTime causes SIGSEGV. + (Derick) + +- FPM: + . Fixed bug #63999 (php with fpm fails to build on Solaris 10 or 11). (Adam) + +- Litespeed: + . Fixed bug #63228 (-Werror=format-security error in lsapi code). (George) + +- SOAP + . Added check that soap.wsdl_cache_dir conforms to open_basedir + (CVE-2013-1635). (Dmitry) + . Disabled external entities loading (CVE-2013-1643). (Dmitry) + +- sqlite3: + . Fixed bug #63921 (sqlite3::bindvalue and relative PHP functions aren't + using sqlite3_*_int64 API). (srgoogleguy, Lars) + +- PDO_OCI + . Fixed bug #57702 (Multi-row BLOB fetches). (hswong3i, Laruence) + . Fixed bug #52958 (Segfault in PDO_OCI on cleanup after running a long + testsuite). (hswong3i, Lars) + +- PDO_sqlite: + . Fixed bug #63916 (PDO::PARAM_INT casts to 32bit int internally even + on 64bit builds in pdo_sqlite). (srgoogleguy, Lars) + +17 Jan 2012, PHP 5.4.11 - Core: . Fixed bug #63762 (Sigsegv when Exception::$trace is changed by user). (Johannes) - . Fixed bug #43177 (Errors in eval()'ed code produce status code 500). + . Fixed bug #43177 (Errors in eval()'ed code produce status code 500). (Todd Ruth, Stas). - Filter: diff --git a/Zend/tests/bug30998.phpt b/Zend/tests/bug30998.phpt index d0ace9fa1..032da3d3b 100644 --- a/Zend/tests/bug30998.phpt +++ b/Zend/tests/bug30998.phpt @@ -15,7 +15,7 @@ $f = fopen("/tmp/blah", "r"); ?> ===DONE=== --EXPECTF-- -fopen(/tmp/blah): failed to open stream: No such file or directory (2) in %s:%d +fopen(/tmp/blah): failed to open stream: %s (2) in %s:%d -Warning: fopen(/tmp/blah): failed to open stream: No such file or directory in %s on line %d +Warning: fopen(/tmp/blah): failed to open stream: %s in %s on line %d ===DONE=== diff --git a/Zend/tests/bug60909_1.phpt b/Zend/tests/bug60909_1.phpt index 5150dfc02..cfe428928 100644 --- a/Zend/tests/bug60909_1.phpt +++ b/Zend/tests/bug60909_1.phpt @@ -10,7 +10,7 @@ set_error_handler(function($errno, $errstr, $errfile, $errline){ require 'notfound.php'; --EXPECTF-- -error(require(notfound.php): failed to open stream: No such file or directory) +error(require(notfound.php): failed to open stream: %s) Warning: Uncaught exception 'Exception' with message 'Foo' in %sbug60909_1.php:5 Stack trace: #0 %sbug60909_1.php(8): {closure}(2, 'require(notfoun...', '%s', 8, Array) diff --git a/Zend/tests/bug63462.phpt b/Zend/tests/bug63462.phpt new file mode 100644 index 000000000..e936a6fa6 --- /dev/null +++ b/Zend/tests/bug63462.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test script to verify that magic methods should be called only once when accessing an unset property. +--CREDITS-- +Marco Pivetta <ocramius@gmail.com> +--FILE-- +<?php +class Test { + public $publicProperty; + protected $protectedProperty; + private $privateProperty; + + public function __construct() { + unset( + $this->publicProperty, + $this->protectedProperty, + $this->privateProperty + ); + } + + function __get($name) { + echo '__get ' . $name . "\n"; + return $this->$name; + } + + function __set($name, $value) { + echo '__set ' . $name . "\n"; + $this->$name = $value; + } + + function __isset($name) { + echo '__isset ' . $name . "\n"; + return isset($this->$name); + } +} + +$test = new Test(); + +$test->nonExisting; +$test->publicProperty; +$test->protectedProperty; +$test->privateProperty; +isset($test->nonExisting); +isset($test->publicProperty); +isset($test->protectedProperty); +isset($test->privateProperty); +$test->nonExisting = 'value'; +$test->publicProperty = 'value'; +$test->protectedProperty = 'value'; +$test->privateProperty = 'value'; + +?> + +--EXPECTF-- +__get nonExisting + +Notice: Undefined property: Test::$nonExisting in %s on line %d +__get publicProperty + +Notice: Undefined property: Test::$publicProperty in %s on line %d +__get protectedProperty + +Notice: Undefined property: Test::$protectedProperty in %s on line %d +__get privateProperty + +Notice: Undefined property: Test::$privateProperty in %s on line %d +__isset nonExisting +__isset publicProperty +__isset protectedProperty +__isset privateProperty +__set nonExisting +__set publicProperty +__set protectedProperty +__set privateProperty + diff --git a/Zend/tests/bug63882.phpt b/Zend/tests/bug63882.phpt new file mode 100644 index 000000000..0cc1babd4 --- /dev/null +++ b/Zend/tests/bug63882.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #63882 (zend_std_compare_objects crash on recursion) +--FILE-- +<?php +class Test { public $x = 5; } + +$testobj1 = new Test; +$testobj2 = new Test; +$testobj1->x = $testobj1; +$testobj2->x = $testobj2; + +var_dump($testobj1 == $testobj2); +?> +--EXPECTF-- +Fatal error: Nesting level too deep - recursive dependency? in %sbug63882.php on line 9 diff --git a/Zend/tests/bug63982.phpt b/Zend/tests/bug63982.phpt new file mode 100644 index 000000000..31294f33e --- /dev/null +++ b/Zend/tests/bug63982.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #63982 (isset() inconsistently produces a fatal error on protected property) +--FILE-- +<?php +class Test { + protected $protectedProperty; +} + +$test = new Test(); + +var_dump(isset($test->protectedProperty)); +var_dump(isset($test->protectedProperty->foo)); +--EXPECTF-- +bool(false) +bool(false) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 4a3985e0f..ccbdf2c10 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -279,9 +279,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); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 32ee86afd..8f4f9c47b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4795,10 +4795,11 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name /* Prefix class name with name of current namespace */ znode tmp; + tmp.op_type = IS_CONST; tmp.u.constant = *CG(current_namespace); zval_copy_ctor(&tmp.u.constant); zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC); - class_name = &tmp; + *class_name = tmp; efree(lcname); lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant)); } @@ -4931,7 +4932,7 @@ void zend_do_end_class_declaration(const znode *class_token, const znode *parent } if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) - && ((parent_token->op_type != IS_UNUSED) || (ce->num_interfaces > 0))) { + && (parent_token || (ce->num_interfaces > 0))) { zend_verify_abstract_class(ce TSRMLS_CC); if (ce->num_interfaces && !(ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS)) { do_verify_abstract_class(TSRMLS_C); diff --git a/Zend/zend_language_parser.c b/Zend/zend_language_parser.c index 17af37976..295da98ca 100644 --- a/Zend/zend_language_parser.c +++ b/Zend/zend_language_parser.c @@ -3934,7 +3934,7 @@ yyreduce: case 102: - { zend_do_end_class_declaration(&(yyvsp[(1) - (8)]), &(yyvsp[(2) - (8)]) TSRMLS_CC); } + { zend_do_end_class_declaration(&(yyvsp[(1) - (8)]), &(yyvsp[(3) - (8)]) TSRMLS_CC); } break; case 103: @@ -3944,7 +3944,7 @@ yyreduce: case 104: - { zend_do_end_class_declaration(&(yyvsp[(1) - (7)]), &(yyvsp[(2) - (7)]) TSRMLS_CC); } + { zend_do_end_class_declaration(&(yyvsp[(1) - (7)]), NULL TSRMLS_CC); } break; case 105: diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index b37822903..1f5d73296 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -375,13 +375,13 @@ unticked_class_declaration_statement: implements_list '{' class_statement_list - '}' { zend_do_end_class_declaration(&$1, &$2 TSRMLS_CC); } + '}' { zend_do_end_class_declaration(&$1, &$3 TSRMLS_CC); } | interface_entry T_STRING { zend_do_begin_class_declaration(&$1, &$2, NULL TSRMLS_CC); } interface_extends_list '{' class_statement_list - '}' { zend_do_end_class_declaration(&$1, &$2 TSRMLS_CC); } + '}' { zend_do_end_class_declaration(&$1, NULL TSRMLS_CC); } ; diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a76dfb38a..cc45d35ec 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -35,6 +35,17 @@ #define Z_OBJ_P(zval_p) \ ((zend_object*)(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].bucket.obj.object)) +#define Z_OBJ_PROTECT_RECURSION(zval_p) \ + do { \ + if (EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].apply_count++ >= 3) { \ + zend_error(E_ERROR, "Nesting level too deep - recursive dependency?"); \ + } \ + } while (0) + + +#define Z_OBJ_UNPROTECT_RECURSION(zval_p) \ + EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zval_p)].apply_count-- + /* __X accessors explanation: @@ -382,6 +393,16 @@ static int zend_get_property_guard(zend_object *zobj, zend_property_info *proper info.name = Z_STRVAL_P(member); info.name_length = Z_STRLEN_P(member); info.h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1); + } else if(property_info->name[0] == '\0'){ + const char *class_name = NULL, *prop_name = NULL; + zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name); + if(class_name) { + /* use unmangled name for protected properties */ + info.name = prop_name; + info.name_length = strlen(prop_name); + info.h = zend_get_hash_value(info.name, info.name_length+1); + property_info = &info; + } } if (!zobj->guards) { ALLOC_HASHTABLE(zobj->guards); @@ -424,7 +445,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, const zend_li #endif /* make zend_get_property_info silent if we have getter - we may want to use it */ - property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__get != NULL), key TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, member, silent || (zobj->ce->__get != NULL), key TSRMLS_CC); if (UNEXPECTED(!property_info) || ((EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && @@ -1319,28 +1340,43 @@ static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ } if (!zobj1->properties && !zobj2->properties) { int i; + + Z_OBJ_PROTECT_RECURSION(o1); + Z_OBJ_PROTECT_RECURSION(o2); for (i = 0; i < zobj1->ce->default_properties_count; i++) { if (zobj1->properties_table[i]) { if (zobj2->properties_table[i]) { zval result; if (compare_function(&result, zobj1->properties_table[i], zobj2->properties_table[i] TSRMLS_CC)==FAILURE) { + Z_OBJ_UNPROTECT_RECURSION(o1); + Z_OBJ_UNPROTECT_RECURSION(o2); return 1; } if (Z_LVAL(result) != 0) { + Z_OBJ_UNPROTECT_RECURSION(o1); + Z_OBJ_UNPROTECT_RECURSION(o2); return Z_LVAL(result); } } else { + Z_OBJ_UNPROTECT_RECURSION(o1); + Z_OBJ_UNPROTECT_RECURSION(o2); return 1; } } else { if (zobj2->properties_table[i]) { + Z_OBJ_UNPROTECT_RECURSION(o1); + Z_OBJ_UNPROTECT_RECURSION(o2); return 1; } else { + Z_OBJ_UNPROTECT_RECURSION(o1); + Z_OBJ_UNPROTECT_RECURSION(o2); return 0; } } } + Z_OBJ_UNPROTECT_RECURSION(o1); + Z_OBJ_UNPROTECT_RECURSION(o2); return 0; } else { if (!zobj1->properties) { diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 4f3561e3d..1fe5d0c19 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -117,6 +117,7 @@ ZEND_API zend_object_handle zend_objects_store_put(void *object, zend_objects_st obj = &EG(objects_store).object_buckets[handle].bucket.obj; EG(objects_store).object_buckets[handle].destructor_called = 0; EG(objects_store).object_buckets[handle].valid = 1; + EG(objects_store).object_buckets[handle].apply_count = 0; obj->refcount = 1; GC_OBJ_INIT(obj); diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index c973b7a20..a6ea9b8c0 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -31,6 +31,7 @@ typedef void (*zend_objects_store_clone_t)(void *object, void **object_clone TSR typedef struct _zend_object_store_bucket { zend_bool destructor_called; zend_bool valid; + zend_uchar apply_count; union _store_bucket { struct _store_object { void *object; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index b7fa90707..e5cdd1d1f 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -974,27 +974,15 @@ ZEND_VM_HANDLER(40, ZEND_ECHO, CONST|TMP|VAR|CV, ANY) { USE_OPLINE zend_free_op free_op1; - zval z_copy; zval *z; SAVE_OPLINE(); z = GET_OP1_ZVAL_PTR(BP_VAR_R); - if (OP1_TYPE != IS_CONST && - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && - Z_OBJ_HT_P(z)->get_method != NULL) { - if (OP1_TYPE == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (OP1_TYPE == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); FREE_OP1(); CHECK_EXCEPTION(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 2680d8524..97e5a8e93 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2024,27 +2024,15 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - zval z_copy; zval *z; SAVE_OPLINE(); z = opline->op1.zv; - if (IS_CONST != IS_CONST && - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && - Z_OBJ_HT_P(z)->get_method != NULL) { - if (IS_CONST == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_CONST == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6443,27 +6431,15 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op1; - zval z_copy; zval *z; SAVE_OPLINE(); z = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - if (IS_TMP_VAR != IS_CONST && - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && - Z_OBJ_HT_P(z)->get_method != NULL) { - if (IS_TMP_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_TMP_VAR == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10761,27 +10737,15 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op1; - zval z_copy; zval *z; SAVE_OPLINE(); z = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - if (IS_VAR != IS_CONST && - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && - Z_OBJ_HT_P(z)->get_method != NULL) { - if (IS_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_VAR == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -26741,27 +26705,15 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - zval z_copy; zval *z; SAVE_OPLINE(); z = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - if (IS_CV != IS_CONST && - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && - Z_OBJ_HT_P(z)->get_method != NULL) { - if (IS_CV == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_CV == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -3636,7 +3636,7 @@ ac_config_headers="$ac_config_headers main/php_config.h" PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=11 +PHP_RELEASE_VERSION=12 PHP_EXTRA_VERSION="" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr $PHP_MAJOR_VERSION \* 10000 + $PHP_MINOR_VERSION \* 100 + $PHP_RELEASE_VERSION` diff --git a/configure.in b/configure.in index a4730c80f..a7c992e7b 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=11 +PHP_RELEASE_VERSION=12 PHP_EXTRA_VERSION="" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/ext/date/php_date.c b/ext/date/php_date.c index ac119a35d..fd6453f5d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -495,9 +495,11 @@ int php_date_global_timezone_db_enabled; /* on 90'35; common sunrise declaration (sun body disappeared) */ #define DATE_SUNRISE_ZENITH "90.583333" +static PHP_INI_MH(OnUpdate_date_timezone); + /* {{{ INI Settings */ PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("date.timezone", "", PHP_INI_ALL, OnUpdateString, default_timezone, zend_date_globals, date_globals) + STD_PHP_INI_ENTRY("date.timezone", "", PHP_INI_ALL, OnUpdate_date_timezone, default_timezone, zend_date_globals, date_globals) PHP_INI_ENTRY("date.default_latitude", DATE_DEFAULT_LATITUDE, PHP_INI_ALL, NULL) PHP_INI_ENTRY("date.default_longitude", DATE_DEFAULT_LONGITUDE, PHP_INI_ALL, NULL) PHP_INI_ENTRY("date.sunset_zenith", DATE_SUNSET_ZENITH, PHP_INI_ALL, NULL) @@ -599,6 +601,7 @@ static PHP_GINIT_FUNCTION(date) date_globals->default_timezone = NULL; date_globals->timezone = NULL; date_globals->tzcache = NULL; + date_globals->timezone_valid = 0; } /* }}} */ @@ -844,25 +847,54 @@ timelib_tzinfo *php_date_parse_tzfile_wrapper(char *formal_tzname, const timelib } /* }}} */ +/* Callback to check the date.timezone only when changed increases performance */ +/* {{{ static PHP_INI_MH(OnUpdate_date_timezone) */ +static PHP_INI_MH(OnUpdate_date_timezone) +{ + if (OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + DATEG(timezone_valid) = 0; + if (stage == PHP_INI_STAGE_RUNTIME) { + if (!timelib_timezone_id_is_valid(DATEG(default_timezone), DATE_TIMEZONEDB)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, DATE_TZ_ERRMSG); + } else { + DATEG(timezone_valid) = 1; + } + } + + return SUCCESS; +} +/* }}} */ + /* {{{ Helper functions */ static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC) { /* Checking configure timezone */ - if (DATEG(timezone) && (strlen(DATEG(timezone)) > 0)) { + if (DATEG(timezone) && (strlen(DATEG(timezone))) > 0) { return DATEG(timezone); } /* Check config setting for default timezone */ if (!DATEG(default_timezone)) { /* Special case: ext/date wasn't initialized yet */ zval ztz; - - if (SUCCESS == zend_get_configuration_directive("date.timezone", sizeof("date.timezone"), &ztz) && - Z_TYPE(ztz) == IS_STRING && - Z_STRLEN(ztz) > 0 && - timelib_timezone_id_is_valid(Z_STRVAL(ztz), tzdb)) { + + if (SUCCESS == zend_get_configuration_directive("date.timezone", sizeof("date.timezone"), &ztz) + && Z_TYPE(ztz) == IS_STRING && Z_STRLEN(ztz) > 0 && timelib_timezone_id_is_valid(Z_STRVAL(ztz), tzdb)) { return Z_STRVAL(ztz); } - } else if (*DATEG(default_timezone) && timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) { + } else if (*DATEG(default_timezone)) { + if (DATEG(timezone_valid) == 1) { + return DATEG(default_timezone); + } + + if (!timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid date.timezone value '%s', we selected the timezone 'UTC' for now.", DATEG(default_timezone)); + return "UTC"; + } + + DATEG(timezone_valid) = 1; return DATEG(default_timezone); } /* Fallback to UTC */ @@ -2013,7 +2045,11 @@ static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC) instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) { php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC); php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC); - + + if (!o1->time || !o2->time) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime object"); + return 1; + } if (!o1->time->sse_uptodate) { timelib_update_ts(o1->time, o1->time->tz_info); } diff --git a/ext/date/php_date.h b/ext/date/php_date.h index c9c165050..f0b662b5d 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -150,10 +150,11 @@ struct _php_period_obj { }; ZEND_BEGIN_MODULE_GLOBALS(date) - char *default_timezone; - char *timezone; - HashTable *tzcache; + char *default_timezone; + char *timezone; + HashTable *tzcache; timelib_error_container *last_errors; + int timezone_valid; ZEND_END_MODULE_GLOBALS(date) #ifdef ZTS diff --git a/ext/date/tests/bug55397.phpt b/ext/date/tests/bug55397.phpt new file mode 100644 index 000000000..efc09b504 --- /dev/null +++ b/ext/date/tests/bug55397.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #55397 (comparsion of incomplete DateTime causes SIGSEGV) +--INI-- +--FILE-- +<?php +date_default_timezone_set('Europe/Prague'); +var_dump(unserialize('O:8:"DateTime":0:{}') == new DateTime); +?> +--EXPECTF-- +Warning: %s: Trying to compare an incomplete DateTime object in %s on line %d +bool(false) diff --git a/ext/date/tests/date_default_timezone_get-4.phpt b/ext/date/tests/date_default_timezone_get-4.phpt new file mode 100644 index 000000000..6d1982bc1 --- /dev/null +++ b/ext/date/tests/date_default_timezone_get-4.phpt @@ -0,0 +1,11 @@ +--TEST-- +date_default_timezone_get() function [4] +--INI-- +date.timezone=Incorrect/Zone +--FILE-- +<?php + echo date_default_timezone_get(), "\n"; +?> +--EXPECTF-- +Warning: date_default_timezone_get(): Invalid date.timezone value 'Incorrect/Zone', we selected the timezone 'UTC' for now. in %sdate_default_timezone_get-4.php on line %d +UTC diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 1a7d72fea..a4c1b874f 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -838,6 +838,9 @@ PHP_MINIT_FUNCTION(mysqli) REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_CS | CONST_PERSISTENT); #endif +#if MYSQL_VERSION_ID >= 50611 || defined(MYSQLI_USE_MYSQLND) + REGISTER_LONG_CONSTANT("MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS", MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT); +#endif #ifdef MYSQLI_USE_MYSQLND mysqlnd_reverse_api_register_api(&mysqli_reverse_api TSRMLS_CC); diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 277322f1c..2cda0aa90 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1672,6 +1672,9 @@ static int mysqli_options_get_option_zval_type(int option) #ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT); #endif /* MySQL 5.1.1., mysqlnd @ PHP 5.3.3 */ +#if MYSQL_VERSION_ID >= 50611 || defined(MYSQLI_USE_MYSQLND) + case MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS: +#endif return IS_LONG; #ifdef MYSQL_SHARED_MEMORY_BASE_NAME diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index 613dddfc8..8bdc849f7 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -176,6 +176,10 @@ require_once('skipifconnectfailure.inc'); } } + if (($IS_MYSQLND && version_compare(PHP_VERSION, ' 5.4.12-dev', '>=')) || (!$IS_MYSQLND && ($version > 50610))) { + /* could be that MySQL/libmysql 5.6.9 had the flag already but it was no stable release */ + $expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; + } $unexpected_constants = array(); diff --git a/ext/mysqli/tests/mysqli_expire_password.phpt b/ext/mysqli/tests/mysqli_expire_password.phpt new file mode 100644 index 000000000..ce89a2167 --- /dev/null +++ b/ext/mysqli/tests/mysqli_expire_password.phpt @@ -0,0 +1,145 @@ +--TEST-- +MySQL 5.6 EXPIRE PASSWORD protocol change +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifemb.inc'); +require_once('connect.inc'); + +if ($IS_MYSQLND && !version_compare(PHP_VERSION, '5.4.12-dev', ">=")) { + die("SKIP Available in mysqlnd as of PHP 5.4.12-dev"); +} + +if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket)); +} + +if ($link->server_version < 50610) + die(sprintf("SKIP Needs MySQL 5.6.10 or newer, found MySQL %s\n", $link->server_info)); + +if (!$IS_MYSQLND && (mysqli_get_client_version() < 50610)) { + die(sprintf("SKIP Needs libmysql 5.6.10 or newer, found %s\n", mysqli_get_client_version())); +} + +mysqli_query($link, 'DROP USER expiretest'); +mysqli_query($link, 'DROP USER expiretest@localhost'); + +if (!mysqli_query($link, 'CREATE USER expiretest@"%"') || + !mysqli_query($link, 'CREATE USER expiretest@"localhost"')) { + printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link)); + mysqli_close($link); + die("skip CREATE USER failed"); +} + +if (!mysqli_query($link, 'ALTER USER expiretest@"%" PASSWORD EXPIRE') || + !mysqli_query($link, 'ALTER USER expiretest@"localhost" PASSWORD EXPIRE')) { + printf("skip Cannot modify second DB user [%d] %s", mysqli_errno($link), mysqli_error($link)); + mysqli_close($link); + die("skip ALTER USER failed"); +} + +if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query("CREATE TABLE test (id INT)") || !$link->query("INSERT INTO test(id) VALUES (1)")) + die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error)); + + + +if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%%'", $db)) || + !mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'localhost'", $db))) { + printf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)); + mysqli_close($link); + die("skip GRANT failed"); +} +?> +--FILE-- +<?php + require_once('connect.inc'); + require_once('table.inc'); + + /* default */ + if (!$link = my_mysqli_connect($host, 'expiretest', "", $db, $port, $socket)) { + printf("[001] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + printf("[002] Connect should fail, [%d] %s\n", $link->errno, $link->error); + } + + /* explicitly requesting default */ + $link = mysqli_init(); + $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 0); + if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { + printf("[003] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + printf("[004] Connect should fail, [%d] %s\n", $link->errno, $link->error); + } + + /* allow connect */ + $link = mysqli_init(); + $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1); + if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { + printf("[005] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + printf("[006] Connect allowed, query fail, [%d] %s\n", $link->errno, $link->error); + $link->close(); + } + + /* allow connect, fix pw */ + $link = mysqli_init(); + $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1); + if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { + printf("[007] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SET PASSWORD=PASSWORD('expiretest')"); + printf("[008] Connect allowed, pw set, [%d] %s\n", $link->errno, $link->error); + if ($res = $link->query("SELECT id FROM test WHERE id = 1")) + var_dump($res->fetch_assoc()); + $link->close(); + } + + + /* check login */ + if (!$link = my_mysqli_connect($host, 'expiretest', "expiretest", $db, $port, $socket)) { + printf("[001] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + if ($res = $link->query("SELECT id FROM test WHERE id = 1")) + var_dump($res->fetch_assoc()); + $link->close(); + } + + + + print "done!"; +?> +--CLEAN-- +<?php + require_once("clean_table.inc"); + mysqli_query($link, 'DROP USER expiretest'); + mysqli_query($link, 'DROP USER expiretest@localhost'); +?> +--EXPECTF-- + +Warning: mysqli_real_connect(): (HY000/1820): %s in %s on line %d +[001] Cannot connect [1820] %s + +Warning: mysqli_real_connect(): (HY000/1820): %s in %s on line %d +[003] Cannot connect [1820] %s +[006] Connect allowed, query fail, [1820] %s +[008] Connect allowed, pw set, [0%A +array(1) { + ["id"]=> + string(1) "1" +} +array(1) { + ["id"]=> + string(1) "1" +} +done! diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 900f8207b..0b81ac99f 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -774,6 +774,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, /* we allow load data local infile by default */ mysql_flags |= MYSQLND_CAPABILITIES; + mysql_flags |= conn->options->flags; /* use the flags from set_client_option() */ + if (db) { mysql_flags |= CLIENT_CONNECT_WITH_DB; } @@ -2284,7 +2286,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c break; #endif case MYSQL_OPT_LOCAL_INFILE: - if (!value || (*(unsigned int*) value) ? 1 : 0) { + if (value && (*(unsigned int*) value) ? 1 : 0) { conn->options->flags |= CLIENT_LOCAL_FILES; } else { conn->options->flags &= ~CLIENT_LOCAL_FILES; @@ -2368,6 +2370,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c DBG_INF_FMT("auth_protocol=%s", conn->options->auth_protocol); break; } + case MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS: + if (value && (*(unsigned int*) value) ? 1 : 0) { + conn->options->flags |= CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS; + } else { + conn->options->flags &= ~CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS; + } + break; #ifdef WHEN_SUPPORTED_BY_MYSQLI case MYSQL_SHARED_MEMORY_BASE_NAME: case MYSQL_OPT_USE_RESULT: diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h index b0b3b15c6..e707c415d 100644 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index 5883d6631..380a0fbaa 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_alloc.h b/ext/mysqlnd/mysqlnd_alloc.h index 673d4f6da..6bd4385e6 100644 --- a/ext/mysqlnd/mysqlnd_alloc.h +++ b/ext/mysqlnd/mysqlnd_alloc.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index 10c932a96..918697a5f 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c index b78efff65..b9d788728 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_block_alloc.h b/ext/mysqlnd/mysqlnd_block_alloc.h index e2cf60ffb..39ccbdc6b 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.h +++ b/ext/mysqlnd/mysqlnd_block_alloc.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_bt.c b/ext/mysqlnd/mysqlnd_bt.c index 937518405..3aeb8f2bb 100644 --- a/ext/mysqlnd/mysqlnd_bt.c +++ b/ext/mysqlnd/mysqlnd_bt.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c index 25b987707..a36bb11e9 100644 --- a/ext/mysqlnd/mysqlnd_charset.c +++ b/ext/mysqlnd/mysqlnd_charset.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_charset.h b/ext/mysqlnd/mysqlnd_charset.h index 418d5dd9b..09d0eb417 100644 --- a/ext/mysqlnd/mysqlnd_charset.h +++ b/ext/mysqlnd/mysqlnd_charset.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index 044a7d680..fb8a36024 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h index d805178e2..f98c163e7 100644 --- a/ext/mysqlnd/mysqlnd_debug.h +++ b/ext/mysqlnd/mysqlnd_debug.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c index 1ac9bae87..e209a71b4 100644 --- a/ext/mysqlnd/mysqlnd_driver.c +++ b/ext/mysqlnd/mysqlnd_driver.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index b0fe88648..92f6cb3e2 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -95,7 +95,9 @@ #define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */ #define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */ #define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */ - +#define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */ +#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) /* Enable authentication response packet to be larger than 255 bytes. */ +#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) /* Don't close the connection for a connection with expired password. */ #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) #define MYSQLND_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | \ @@ -164,6 +166,9 @@ typedef enum mysqlnd_option MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, + MYSQL_SERVER_PUBLIC_KEY, + MYSQL_ENABLE_CLEARTEXT_PLUGIN, + MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, #if MYSQLND_UNICODE MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE = 200, #endif diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.c b/ext/mysqlnd/mysqlnd_ext_plugin.c index 02cd9a891..21be3fd37 100644 --- a/ext/mysqlnd/mysqlnd_ext_plugin.c +++ b/ext/mysqlnd/mysqlnd_ext_plugin.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.h b/ext/mysqlnd/mysqlnd_ext_plugin.h index f980f1347..ef9d085a9 100644 --- a/ext/mysqlnd/mysqlnd_ext_plugin.h +++ b/ext/mysqlnd/mysqlnd_ext_plugin.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_libmysql_compat.h b/ext/mysqlnd/mysqlnd_libmysql_compat.h index c95539b08..c967fb3a9 100644 --- a/ext/mysqlnd/mysqlnd_libmysql_compat.h +++ b/ext/mysqlnd/mysqlnd_libmysql_compat.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c index 82ee63458..40de45b06 100644 --- a/ext/mysqlnd/mysqlnd_loaddata.c +++ b/ext/mysqlnd/mysqlnd_loaddata.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 800f57733..21241b3ef 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_net.h b/ext/mysqlnd/mysqlnd_net.h index 29280ee40..568a0e18b 100644 --- a/ext/mysqlnd/mysqlnd_net.h +++ b/ext/mysqlnd/mysqlnd_net.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_plugin.c b/ext/mysqlnd/mysqlnd_plugin.c index 2dbb57d1c..f32fe4afd 100644 --- a/ext/mysqlnd/mysqlnd_plugin.c +++ b/ext/mysqlnd/mysqlnd_plugin.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h index addce670d..190ed697b 100644 --- a/ext/mysqlnd/mysqlnd_priv.h +++ b/ext/mysqlnd/mysqlnd_priv.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 1b48ba1d7..99bd02159 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index ce0736fdf..5ead1b0bc 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 8ae2665ba..2e289062a 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_result.h b/ext/mysqlnd/mysqlnd_result.h index f5ee79174..f821b916e 100644 --- a/ext/mysqlnd/mysqlnd_result.h +++ b/ext/mysqlnd/mysqlnd_result.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c index 9469ceaf1..1d22e6cc0 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.c +++ b/ext/mysqlnd/mysqlnd_result_meta.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_result_meta.h b/ext/mysqlnd/mysqlnd_result_meta.h index e81e0db83..8fa998970 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.h +++ b/ext/mysqlnd/mysqlnd_result_meta.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_reverse_api.c b/ext/mysqlnd/mysqlnd_reverse_api.c index 0b77b5a94..daa43ec51 100644 --- a/ext/mysqlnd/mysqlnd_reverse_api.c +++ b/ext/mysqlnd/mysqlnd_reverse_api.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_reverse_api.h b/ext/mysqlnd/mysqlnd_reverse_api.h index 005df5a1a..dd23555b9 100644 --- a/ext/mysqlnd/mysqlnd_reverse_api.h +++ b/ext/mysqlnd/mysqlnd_reverse_api.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c index bb00a9192..271cb2971 100644 --- a/ext/mysqlnd/mysqlnd_statistics.c +++ b/ext/mysqlnd/mysqlnd_statistics.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h index 7a1a1cec2..d1fd03b00 100644 --- a/ext/mysqlnd/mysqlnd_statistics.h +++ b/ext/mysqlnd/mysqlnd_statistics.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 43eba40a2..5c07a3c3c 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index face502cd..d0ab9fe73 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h index 96322d706..253784c36 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.h +++ b/ext/mysqlnd/mysqlnd_wireprotocol.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index 20fcc5e7a..002135566 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqlnd/php_mysqlnd.h b/ext/mysqlnd/php_mysqlnd.h index c8a749df6..14ad234e1 100644 --- a/ext/mysqlnd/php_mysqlnd.h +++ b/ext/mysqlnd/php_mysqlnd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c index a0377ddb1..5497bebc6 100644 --- a/ext/pdo_oci/oci_driver.c +++ b/ext/pdo_oci/oci_driver.c @@ -227,8 +227,10 @@ static int oci_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */ H->server = NULL; } - OCIHandleFree(H->err, OCI_HTYPE_ERROR); - H->err = NULL; + if (H->err) { + OCIHandleFree(H->err, OCI_HTYPE_ERROR); + H->err = NULL; + } if (H->charset && H->env) { OCIHandleFree(H->env, OCI_HTYPE_ENV); diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c index 2a93a66a8..dcb955780 100644 --- a/ext/pdo_oci/oci_statement.c +++ b/ext/pdo_oci/oci_statement.c @@ -99,7 +99,7 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ switch (S->cols[i].dtype) { case SQLT_BLOB: case SQLT_CLOB: - /* do nothing */ + OCIDescriptorFree(S->cols[i].data, OCI_DTYPE_LOB); break; default: efree(S->cols[i].data); @@ -654,7 +654,6 @@ static int oci_blob_close(php_stream *stream, int close_handle TSRMLS_DC) if (close_handle) { OCILobClose(self->S->H->svc, self->S->err, self->lob); - OCIDescriptorFree(self->lob, OCI_DTYPE_LOB); efree(self); } diff --git a/ext/pdo_oci/tests/bug57702.phpt b/ext/pdo_oci/tests/bug57702.phpt new file mode 100644 index 000000000..9281f6d0f --- /dev/null +++ b/ext/pdo_oci/tests/bug57702.phpt @@ -0,0 +1,165 @@ +--TEST-- +PDO OCI Bug #57702 (Multi-row BLOB fetches) +--SKIPIF-- +<?php +if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded'); +require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc'); +PDOTest::skip(); +?> +--FILE-- +<?php + +require('ext/pdo/tests/pdo_test.inc'); +$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt'); + +// Note the PDO test setup sets PDO::ATTR_STRINGIFY_FETCHES to true +// (and sets PDO::ATTR_CASE to PDO::CASE_LOWER) + +$query = "begin execute immediate 'drop table mytable'; exception when others then if sqlcode <> -942 then raise; end if; end;"; +$stmt = $db->prepare($query); +$stmt->execute(); + +$query = "create table bug57702 (id number, data1 blob, data2 blob)"; +$stmt = $db->prepare($query); +$stmt->execute(); + +function do_insert($db, $id, $data1, $data2) +{ + $db->beginTransaction(); + $stmt = $db->prepare("insert into bug57702 (id, data1, data2) values (:id, empty_blob(), empty_blob()) returning data1, data2 into :blob1, :blob2"); + $stmt->bindParam(':id', $id); + $stmt->bindParam(':blob1', $blob1, PDO::PARAM_LOB); + $stmt->bindParam(':blob2', $blob2, PDO::PARAM_LOB); + $blob1 = null; + $blob2 = null; + $stmt->execute(); + + fwrite($blob1, $data1); + fclose($blob1); + fwrite($blob2, $data2); + fclose($blob2); + $db->commit(); +} + +do_insert($db, 1, "row 1 col 1", "row 1 col 2"); +do_insert($db, 2, "row 2 col 1", "row 2 col 2"); + +//////////////////// + +echo "First Query\n"; + +// Fetch it back +$stmt = $db->prepare('select data1, data2 from bug57702 order by id'); +$stmt->execute(); +$row = $stmt->fetch(PDO::FETCH_ASSOC); +var_dump($row['data1']); +var_dump($row['data2']); +$row = $stmt->fetch(PDO::FETCH_ASSOC); +var_dump($row['data1']); +var_dump($row['data2']); + +//////////////////// + +echo "\nSecond Query\n"; + +foreach($db->query("select data1 as d1, data2 as d2 from bug57702 order by id") as $row) { + var_dump($row['d1']); + var_dump($row['d2']); +} + +//////////////////// + +echo "\nThird Query\n"; + +$stmt = $db->prepare('select data1 as d3_1, data2 as d3_2 from bug57702 order by id'); + +$rs = $stmt->execute(); +$stmt->bindColumn('d3_1' , $clob1, PDO::PARAM_LOB); +$stmt->bindColumn('d3_2' , $clob2, PDO::PARAM_LOB); + +while ($stmt->fetch(PDO::FETCH_BOUND)) { + var_dump($clob1); + var_dump($clob2); +} +print "done\n"; + +//////////////////// + +echo "\nFourth Query\n"; + +$a = array(); +$i = 0; +foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; + $i++; +} + +for ($i = 0; $i < count($a); $i++) { + var_dump($a[$i][0]); + var_dump($a[$i][1]); +} + +//////////////////// + +echo "\nFifth Query\n"; + +$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Let's use streams + +// Since each column only has one lob descriptor, the last row is +// shown twice because the lob descriptor for each column is reused in +// the stream + +$a = array(); +$i = 0; +foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; + $i++; +} + +for ($i = 0; $i < count($a); $i++) { + var_dump(stream_get_contents($a[$i][0])); + var_dump(stream_get_contents($a[$i][1])); +} + +// Cleanup +$query = "drop table bug57702"; +$stmt = $db->prepare($query); +$stmt->execute(); + +print "done\n"; + +?> +--EXPECTF-- +First Query +string(11) "row 1 col 1" +string(11) "row 1 col 2" +string(11) "row 2 col 1" +string(11) "row 2 col 2" + +Second Query +string(11) "row 1 col 1" +string(11) "row 1 col 2" +string(11) "row 2 col 1" +string(11) "row 2 col 2" + +Third Query +string(11) "row 1 col 1" +string(11) "row 1 col 2" +string(11) "row 2 col 1" +string(11) "row 2 col 2" +done + +Fourth Query +string(11) "row 1 col 1" +string(11) "row 1 col 2" +string(11) "row 2 col 1" +string(11) "row 2 col 2" + +Fifth Query +string(11) "row 2 col 1" +string(11) "row 2 col 2" +string(11) "row 2 col 1" +string(11) "row 2 col 2" +done diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index d5b4df1fd..e970ad3e0 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -112,9 +112,15 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d } } else { convert_to_long(param->parameter); +#if LONG_MAX > 2147483647 + if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { + return 1; + } +#else if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { return 1; } +#endif } pdo_sqlite_error_stmt(stmt); return 0; diff --git a/ext/pdo_sqlite/tests/bug_63916-2.phpt b/ext/pdo_sqlite/tests/bug_63916-2.phpt new file mode 100644 index 000000000..bc9bfc9c9 --- /dev/null +++ b/ext/pdo_sqlite/tests/bug_63916-2.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63916 PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite +--SKIPIF-- +<?php +if (!extension_loaded('pdo_sqlite')) die('skip'); +if (PHP_INT_SIZE > 4) die('skip'); +?> +--FILE-- +<?php +$num = PHP_INT_MAX; // 32 bits +$conn = new PDO('sqlite::memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, PDO::PARAM_INT); +$stmt->bindValue(':num', $num, PDO::PARAM_INT); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchAll(PDO::FETCH_COLUMN); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(2147483647) +string(10) "2147483647" diff --git a/ext/pdo_sqlite/tests/bug_63916.phpt b/ext/pdo_sqlite/tests/bug_63916.phpt new file mode 100644 index 000000000..582413db4 --- /dev/null +++ b/ext/pdo_sqlite/tests/bug_63916.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63916 PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite +--SKIPIF-- +<?php +if (!extension_loaded('pdo_sqlite')) die('skip'); +if (PHP_INT_SIZE < 8) die('skip'); +?> +--FILE-- +<?php +$num = 100004313234244; // exceeds 32 bits +$conn = new PDO('sqlite::memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, PDO::PARAM_INT); +$stmt->bindValue(':num', $num, PDO::PARAM_INT); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchAll(PDO::FETCH_COLUMN); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(100004313234244) +string(15) "100004313234244" diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index a1c5b09ab..277d058ea 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar:// stream wrapper support | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h index c5fe18b2f..9b07c9d79 100644 --- a/ext/phar/dirstream.h +++ b/ext/phar/dirstream.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index 55f254885..65193726d 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/func_interceptors.h b/ext/phar/func_interceptors.h index 3afba3153..59d6bf629 100644 --- a/ext/phar/func_interceptors.h +++ b/ext/phar/func_interceptors.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/phar.c b/ext/phar/phar.c index cc7eac717..c5042cc34 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 38342e3f7..daa85f1b7 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 561ba7bf2..a6dd2c814 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c index 7ca339d26..8275c9c99 100644 --- a/ext/phar/phar_path_check.c +++ b/ext/phar/phar_path_check.c @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2007-2012 The PHP Group | + | Copyright (c) 2007-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/phar_path_check.re b/ext/phar/phar_path_check.re index 6141da098..e43b3f846 100644 --- a/ext/phar/phar_path_check.re +++ b/ext/phar/phar_path_check.re @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2007-2012 The PHP Group | + | Copyright (c) 2007-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/pharzip.h b/ext/phar/pharzip.h index 4937e57b7..9c088d3a0 100644 --- a/ext/phar/pharzip.h +++ b/ext/phar/pharzip.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h index e34d51cd9..a6d7bff41 100644 --- a/ext/phar/php_phar.h +++ b/ext/phar/php_phar.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/stream.c b/ext/phar/stream.c index bf0913d68..612a9765e 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar:// stream wrapper support | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/stream.h b/ext/phar/stream.h index 6fdc20e35..b22b67ab0 100644 --- a/ext/phar/stream.h +++ b/ext/phar/stream.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2012 The PHP Group | + | Copyright (c) 2006-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/stub.h b/ext/phar/stub.h index 3bb12c0ca..daafa391c 100644 --- a/ext/phar/stub.h +++ b/ext/phar/stub.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar php single-file executable PHP extension generated stub | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 43d1ede23..f17033543 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | TAR archive support for Phar | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/tar.h b/ext/phar/tar.h index ed9934647..8bfc3817a 100644 --- a/ext/phar/tar.h +++ b/ext/phar/tar.h @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | TAR archive support for Phar | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/util.c b/ext/phar/util.c index f674bca4f..05c90cd45 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -3,7 +3,7 @@ | phar php single-file executable PHP extension | | utility functions | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 337262255..33732fbd6 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | ZIP archive support for Phar | +----------------------------------------------------------------------+ - | Copyright (c) 2007-2012 The PHP Group | + | Copyright (c) 2007-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index cf7fead6b..737a335e3 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -92,6 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC) PG(allow_url_fopen) = old_allow_url_fopen; if (ctxt) { ctxt->keepBlanks = 0; + ctxt->options &= ~XML_PARSE_DTDLOAD; ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace; ctxt->sax->comment = soap_Comment; ctxt->sax->warning = NULL; @@ -133,6 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) */ ctxt = xmlCreateMemoryParserCtxt(buf, buf_size); if (ctxt) { + ctxt->options &= ~XML_PARSE_DTDLOAD; ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace; ctxt->sax->comment = soap_Comment; ctxt->sax->warning = NULL; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 13f163ab3..7df84e5b2 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -479,10 +479,40 @@ ZEND_INI_MH(OnUpdateCacheMode) return SUCCESS; } +static PHP_INI_MH(OnUpdateCacheDir) +{ + /* Only do the open_basedir check at runtime */ + if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) { + char *p; + + if (memchr(new_value, '\0', new_value_length) != NULL) { + return FAILURE; + } + + /* we do not use zend_memrchr() since path can contain ; itself */ + if ((p = strchr(new_value, ';'))) { + char *p2; + p++; + if ((p2 = strchr(p, ';'))) { + p = p2 + 1; + } + } else { + p = new_value; + } + + if (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) { + return FAILURE; + } + } + + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + return SUCCESS; +} + PHP_INI_BEGIN() STD_PHP_INI_ENTRY("soap.wsdl_cache_enabled", "1", PHP_INI_ALL, OnUpdateBool, cache_enabled, zend_soap_globals, soap_globals) -STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateString, +STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateCacheDir, cache_dir, zend_soap_globals, soap_globals) STD_PHP_INI_ENTRY("soap.wsdl_cache_ttl", "86400", PHP_INI_ALL, OnUpdateLong, cache_ttl, zend_soap_globals, soap_globals) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 61d6324d5..f43a3709e 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1874,6 +1874,10 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(readobj TSRMLS_CC); if (type == IS_STRING) { + if (Z_OBJCE_P(readobj)->__tostring) { + return std_object_handlers.cast_object(readobj, writeobj, type TSRMLS_CC); + } + switch (intern->type) { case SPL_FS_INFO: case SPL_FS_FILE: diff --git a/ext/spl/tests/bug64023.phpt b/ext/spl/tests/bug64023.phpt new file mode 100644 index 000000000..2c177f951 --- /dev/null +++ b/ext/spl/tests/bug64023.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #64023: Overloading __toString() in SplFileInfo has no effect +--FILE-- +<?php +class A extends \SplFileInfo +{ + public function __toString() {return ' -expected- ';} +} + +$a = new A('/'); + +// Works +echo $a, $a->__toString(), $a->__toString() . '', "\n"; + +// Does not work - outputs parent::__toString() +echo $a . '', "\n"; + +--EXPECT-- + -expected- -expected- -expected- + -expected- diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 881e3c370..df449d738 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -730,7 +730,11 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s switch (sqlite3_value_type(argv[i])) { case SQLITE_INTEGER: +#if LONG_MAX > 2147483647 + ZVAL_LONG(*zargs[i + is_agg], sqlite3_value_int64(argv[i])); +#else ZVAL_LONG(*zargs[i + is_agg], sqlite3_value_int(argv[i])); +#endif break; case SQLITE_FLOAT: @@ -774,7 +778,11 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s if (retval) { switch (Z_TYPE_P(retval)) { case IS_LONG: +#if LONG_MAX > 2147483647 + sqlite3_result_int64(context, Z_LVAL_P(retval)); +#else sqlite3_result_int(context, Z_LVAL_P(retval)); +#endif break; case IS_NULL: @@ -1493,7 +1501,11 @@ PHP_METHOD(sqlite3stmt, execute) switch (param->type) { case SQLITE_INTEGER: convert_to_long(param->parameter); +#if LONG_MAX > 2147483647 + sqlite3_bind_int64(stmt_obj->stmt, param->param_number, Z_LVAL_P(param->parameter)); +#else sqlite3_bind_int(stmt_obj->stmt, param->param_number, Z_LVAL_P(param->parameter)); +#endif break; case SQLITE_FLOAT: diff --git a/ext/sqlite3/tests/bug63921-32bit.phpt b/ext/sqlite3/tests/bug63921-32bit.phpt new file mode 100644 index 000000000..8c1c6b941 --- /dev/null +++ b/ext/sqlite3/tests/bug63921-32bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API +--SKIPIF-- +<?php +if (!extension_loaded('sqlite3')) die('skip'); +if (PHP_INT_SIZE > 4) die('skip'); // skip for 64bit builds - there is another test for that +?> +--FILE-- +<?php +$num = PHP_INT_MAX; // 32 bits +$conn = new sqlite3(':memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->bindValue(':num', $num, SQLITE3_INTEGER); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchArray(); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(2147483647) +string(10) "2147483647" diff --git a/ext/sqlite3/tests/bug63921-64bit.phpt b/ext/sqlite3/tests/bug63921-64bit.phpt new file mode 100644 index 000000000..8e821fd2d --- /dev/null +++ b/ext/sqlite3/tests/bug63921-64bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API +--SKIPIF-- +<?php +if (!extension_loaded('sqlite3')) die('skip'); +if (PHP_INT_SIZE < 8) die('skip'); // skip for 32bit builds - there is another test for that +?> +--FILE-- +<?php +$num = 100004313234244; // notice this exceeds 32 bits +$conn = new sqlite3(':memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->bindValue(':num', $num, SQLITE3_INTEGER); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchArray(); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(100004313234244) +string(15) "100004313234244" diff --git a/ext/standard/html.c b/ext/standard/html.c index 79a6737ca..414fa65c9 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1628,8 +1628,8 @@ PHP_FUNCTION(get_html_translation_table) unsigned i, j, k, max_i, max_j, max_k; /* no mapping to unicode required */ - if (CHARSET_SINGLE_BYTE(charset)) { - max_i = 1; max_j = 1; max_k = 64; + if (CHARSET_SINGLE_BYTE(charset)) { /* ISO-8859-1 */ + max_i = 1; max_j = 4; max_k = 64; } else { max_i = 0x1E; max_j = 64; max_k = 64; } diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 85a61167a..870f904e9 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -113,6 +113,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0); int follow_location = 1; php_stream_filter *transfer_encoding = NULL; + int response_code; tmp_line[0] = '\0'; @@ -657,7 +658,6 @@ finish: if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) { zval *http_response; - int response_code; if (tmp_line_len > 9) { response_code = atoi(tmp_line + 9); @@ -731,7 +731,9 @@ finish: http_header_line[http_header_line_length] = '\0'; if (!strncasecmp(http_header_line, "Location: ", 10)) { - if (context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) { + /* we only care about Location for 300, 301, 302, 303 and 307 */ + /* see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 */ + if ((response_code >= 300 && response_code < 304 || 307 == response_code) && context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) { SEPARATE_ZVAL(tmpzval); convert_to_long_ex(tmpzval); follow_location = Z_LVAL_PP(tmpzval); diff --git a/ext/standard/image.c b/ext/standard/image.c index ebf894aa5..4984e4064 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -159,7 +159,7 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream TSRMLS_DC) result->width = (((unsigned int)dim[ 5]) << 8) + ((unsigned int) dim[ 4]); result->height = (((unsigned int)dim[ 7]) << 8) + ((unsigned int) dim[ 6]); result->bits = ((unsigned int)dim[11]); - } else if (size > 12 && (size <= 64 || size == 108)) { + } else if (size > 12 && (size <= 64 || size == 108 || size == 124)) { result = (struct gfxinfo *) ecalloc (1, sizeof(struct gfxinfo)); result->width = (((unsigned int)dim[ 7]) << 24) + (((unsigned int)dim[ 6]) << 16) + (((unsigned int)dim[ 5]) << 8) + ((unsigned int) dim[ 4]); result->height = (((unsigned int)dim[11]) << 24) + (((unsigned int)dim[10]) << 16) + (((unsigned int)dim[ 9]) << 8) + ((unsigned int) dim[ 8]); diff --git a/ext/standard/string.c b/ext/standard/string.c index cf973300b..42bf19817 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -23,6 +23,11 @@ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ #include <stdio.h> +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +#else +# include <stdint.h> +#endif #include "php.h" #include "php_rand.h" #include "php_string.h" @@ -57,6 +62,7 @@ #include "php_globals.h" #include "basic_functions.h" #include "php_smart_str.h" +#include <Zend/zend_exceptions.h> #ifdef ZTS #include "TSRM.h" #endif @@ -132,7 +138,7 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t * size_t i, j; result = (unsigned char *) safe_emalloc(oldlen, 2 * sizeof(char), 1); - + for (i = j = 0; i < oldlen; i++) { result[j++] = hexconvtab[old[i] >> 4]; result[j++] = hexconvtab[old[i] & 15]; @@ -1811,7 +1817,7 @@ PHP_FUNCTION(strpos) if (Z_TYPE_P(needle) == IS_STRING) { if (!Z_STRLEN_P(needle)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle"); RETURN_FALSE; } @@ -2772,112 +2778,383 @@ PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trl } /* }}} */ -/* {{{ php_strtr_array - */ -static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *hash) +/* {{{ Definitions for php_strtr_array */ +typedef size_t STRLEN; /* STRLEN should be unsigned */ +typedef uint16_t HASH; +typedef struct { + HASH table_mask; + STRLEN entries[1]; +} SHIFT_TAB; +typedef struct { + HASH table_mask; + int entries[1]; +} HASH_TAB; +typedef struct { + const char *s; + STRLEN l; +} STR; +typedef struct _pat_and_repl { + STR pat; + STR repl; +} PATNREPL; + +#define S(a) ((a)->s) +#define L(a) ((a)->l) + +#define SHIFT_TAB_BITS 13 +#define HASH_TAB_BITS 10 /* should be less than sizeof(HASH) * 8 */ +#define SHIFT_TAB_SIZE (1U << SHIFT_TAB_BITS) +#define HASH_TAB_SIZE (1U << HASH_TAB_BITS) + +typedef struct { + int B; /* size of suffixes */ + int Bp; /* size of prefixes */ + STRLEN m; /* minimum pattern length */ + int patnum; /* number of patterns */ + SHIFT_TAB *shift; /* table mapping hash to allowed shift */ + HASH_TAB *hash; /* table mapping hash to int (pair of pointers) */ + HASH *prefix; /* array of hashes of prefixes by pattern suffix hash order */ + PATNREPL *patterns; /* array of prefixes by pattern suffix hash order */ +} PPRES; +/* }}} */ + +/* {{{ php_strtr_hash */ +static inline HASH php_strtr_hash(const char *str, int len) { - zval **entry; - char *string_key; - uint string_key_len; - zval **trans; - zval ctmp; - ulong num_key; - int minlen = 128*1024; - int maxlen = 0, pos, len, found; - char *key; - HashPosition hpos; - smart_str result = {0}; - HashTable tmp_hash; - - zend_hash_init(&tmp_hash, zend_hash_num_elements(hash), NULL, NULL, 0); - zend_hash_internal_pointer_reset_ex(hash, &hpos); - while (zend_hash_get_current_data_ex(hash, (void **)&entry, &hpos) == SUCCESS) { - switch (zend_hash_get_current_key_ex(hash, &string_key, &string_key_len, &num_key, 0, &hpos)) { - case HASH_KEY_IS_STRING: - len = string_key_len-1; - if (len < 1) { - zend_hash_destroy(&tmp_hash); - RETURN_FALSE; - } - zend_hash_add(&tmp_hash, string_key, string_key_len, entry, sizeof(zval*), NULL); - if (len > maxlen) { - maxlen = len; - } - if (len < minlen) { - minlen = len; - } - break; + HASH res = 0; + int i; + for (i = 0; i < len; i++) { + res = res * 33 + (unsigned char)str[i]; + } - case HASH_KEY_IS_LONG: - Z_TYPE(ctmp) = IS_LONG; - Z_LVAL(ctmp) = num_key; + return res; +} +/* }}} */ +/* {{{ php_strtr_populate_shift */ +static inline void php_strtr_populate_shift(PATNREPL *patterns, int patnum, int B, STRLEN m, SHIFT_TAB *shift) +{ + int i; + STRLEN j, + max_shift; + + max_shift = m - B + 1; + for (i = 0; i < SHIFT_TAB_SIZE; i++) { + shift->entries[i] = max_shift; + } + for (i = 0; i < patnum; i++) { + for (j = 0; j < m - B + 1; j++) { + HASH h = php_strtr_hash(&S(&patterns[i].pat)[j], B) & shift->table_mask; + assert((long long) m - (long long) j - B >= 0); + shift->entries[h] = MIN(shift->entries[h], m - j - B); + } + } +} +/* }}} */ +/* {{{ php_strtr_compare_hash_suffix */ +static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx_g) +{ + const PPRES *res = ctx_g; + const PATNREPL *pnr_a = a, + *pnr_b = b; + HASH hash_a = php_strtr_hash(&S(&pnr_a->pat)[res->m - res->B], res->B) + & res->hash->table_mask, + hash_b = php_strtr_hash(&S(&pnr_b->pat)[res->m - res->B], res->B) + & res->hash->table_mask; + /* TODO: don't recalculate the hashes all the time */ + if (hash_a > hash_b) { + return 1; + } else if (hash_a < hash_b) { + return -1; + } else { + /* longer patterns must be sorted first */ + if (L(&pnr_a->pat) > L(&pnr_b->pat)) { + return -1; + } else if (L(&pnr_a->pat) < L(&pnr_b->pat)) { + return 1; + } else { + return 0; + } + } +} +/* }}} */ +/* {{{ Sorting (no zend_qsort_r in this PHP version) */ +#define HS_LEFT(i) ((i) * 2 + 1) +#define HS_RIGHT(i) ((i) * 2 + 2) +#define HS_PARENT(i) (((i) - 1) / 2); +#define HS_OFF(data, i) ((void *)(&((data)->arr)[i])) +#define HS_CMP_CALL(data, i1, i2) \ + (php_strtr_compare_hash_suffix(HS_OFF((data), (i1)), HS_OFF((data), (i2)), (data)->res)) +struct hs_data { + PATNREPL *arr; + size_t nel; + size_t heapel; + PPRES *res; +}; +static inline void php_strtr_swap(PATNREPL *a, PATNREPL *b) +{ + PATNREPL tmp = *a; + *a = *b; + *b = tmp; +} +static inline void php_strtr_fix_heap(struct hs_data *data, size_t i) +{ + size_t li = HS_LEFT(i), + ri = HS_RIGHT(i), + largei; + if (li < data->heapel && HS_CMP_CALL(data, li, i) > 0) { + largei = li; + } else { + largei = i; + } + if (ri < data->heapel && HS_CMP_CALL(data, ri, largei) > 0) { + largei = ri; + } + if (largei != i) { + php_strtr_swap(HS_OFF(data, i), HS_OFF(data, largei)); + php_strtr_fix_heap(data, largei); + } +} +static inline void php_strtr_build_heap(struct hs_data *data) +{ + size_t i; + for (i = data->nel / 2; i > 0; i--) { + php_strtr_fix_heap(data, i - 1); + } +} +static inline void php_strtr_heapsort(PATNREPL *arr, size_t nel, PPRES *res) +{ + struct hs_data data = { arr, nel, nel, res }; + size_t i; + php_strtr_build_heap(&data); + for (i = nel; i > 1; i--) { + php_strtr_swap(arr, HS_OFF(&data, i - 1)); + data.heapel--; + php_strtr_fix_heap(&data, 0); + } +} +/* }}} */ +/* {{{ php_strtr_free_strp */ +static void php_strtr_free_strp(void *strp) +{ + STR_FREE(*(char**)strp); +} +/* }}} */ +/* {{{ php_strtr_array_prepare_repls */ +static PATNREPL *php_strtr_array_prepare_repls(int slen, HashTable *pats, zend_llist **allocs, int *outsize) +{ + PATNREPL *patterns; + HashPosition hpos; + zval **entry; + int num_pats = zend_hash_num_elements(pats), + i; + + patterns = safe_emalloc(num_pats, sizeof(*patterns), 0); + *allocs = emalloc(sizeof **allocs); + zend_llist_init(*allocs, sizeof(void*), &php_strtr_free_strp, 0); + + for (i = 0, zend_hash_internal_pointer_reset_ex(pats, &hpos); + zend_hash_get_current_data_ex(pats, (void **)&entry, &hpos) == SUCCESS; + zend_hash_move_forward_ex(pats, &hpos)) { + char *string_key; + uint string_key_len; + ulong num_key; + zval *tzv = NULL; + + switch (zend_hash_get_current_key_ex(pats, &string_key, &string_key_len, &num_key, 0, &hpos)) { + case HASH_KEY_IS_LONG: + string_key_len = 1 + zend_spprintf(&string_key, 0, "%ld", (long)num_key); + zend_llist_add_element(*allocs, &string_key); + /* break missing intentionally */ + + case HASH_KEY_IS_STRING: + string_key_len--; /* exclude final '\0' */ + if (string_key_len == 0) { /* empty string given as pattern */ + efree(patterns); + zend_llist_destroy(*allocs); + efree(*allocs); + *allocs = NULL; + return NULL; + } + if (string_key_len > slen) { /* this pattern can never match */ + continue; + } - convert_to_string(&ctmp); - len = Z_STRLEN(ctmp); - zend_hash_add(&tmp_hash, Z_STRVAL(ctmp), len+1, entry, sizeof(zval*), NULL); - zval_dtor(&ctmp); + if (Z_TYPE_PP(entry) != IS_STRING) { + tzv = *entry; + zval_addref_p(tzv); + SEPARATE_ZVAL(&tzv); + convert_to_string(tzv); + entry = &tzv; + zend_llist_add_element(*allocs, &Z_STRVAL_PP(entry)); + } - if (len > maxlen) { - maxlen = len; - } - if (len < minlen) { - minlen = len; - } - break; + S(&patterns[i].pat) = string_key; + L(&patterns[i].pat) = string_key_len; + S(&patterns[i].repl) = Z_STRVAL_PP(entry); + L(&patterns[i].repl) = Z_STRLEN_PP(entry); + i++; + + if (tzv) { + efree(tzv); + } } - zend_hash_move_forward_ex(hash, &hpos); } - key = emalloc(maxlen+1); - pos = 0; + *outsize = i; + return patterns; +} +/* }}} */ + +/* {{{ PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, int B, int Bp) */ +static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, int B, int Bp) +{ + int i; + PPRES *res = emalloc(sizeof *res); - while (pos < slen) { - if ((pos + maxlen) > slen) { - maxlen = slen - pos; + res->m = (STRLEN)-1; + for (i = 0; i < patnum; i++) { + if (L(&patterns[i].pat) < res->m) { + res->m = L(&patterns[i].pat); } + } + assert(res->m > 0); + res->B = B = MIN(B, res->m); + res->Bp = Bp = MIN(Bp, res->m); - found = 0; - memcpy(key, str+pos, maxlen); - - for (len = maxlen; len >= minlen; len--) { - key[len] = 0; + res->shift = safe_emalloc(SHIFT_TAB_SIZE, sizeof(*res->shift->entries), sizeof(*res->shift)); + res->shift->table_mask = SHIFT_TAB_SIZE - 1; + php_strtr_populate_shift(patterns, patnum, B, res->m, res->shift); - if (zend_hash_find(&tmp_hash, key, len+1, (void**)&trans) == SUCCESS) { - char *tval; - int tlen; - zval tmp; + res->hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res->hash->entries), sizeof(*res->hash)); + res->hash->table_mask = HASH_TAB_SIZE - 1; - if (Z_TYPE_PP(trans) != IS_STRING) { - tmp = **trans; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - tval = Z_STRVAL(tmp); - tlen = Z_STRLEN(tmp); - } else { - tval = Z_STRVAL_PP(trans); - tlen = Z_STRLEN_PP(trans); - } + res->patterns = safe_emalloc(patnum, sizeof(*res->patterns), 0); + memcpy(res->patterns, patterns, sizeof(*patterns) * patnum); + php_strtr_heapsort(res->patterns, patnum, res); - smart_str_appendl(&result, tval, tlen); - pos += len; - found = 1; + res->prefix = safe_emalloc(patnum, sizeof(*res->prefix), 0); + for (i = 0; i < patnum; i++) { + res->prefix[i] = php_strtr_hash(S(&res->patterns[i].pat), Bp); + } - if (Z_TYPE_PP(trans) != IS_STRING) { - zval_dtor(&tmp); - } - break; + /* Initialize the rest of ->hash */ + for (i = 0; i < HASH_TAB_SIZE; i++) { + res->hash->entries[i] = -1; + } + { + HASH last_h = -1; /* assumes not all bits are used in res->hash */ + /* res->patterns is already ordered by hash. + * Make res->hash->entries[h] de index of the first pattern in + * res->patterns that has hash h */ + for (i = 0; i < patnum; i++) { + HASH h = php_strtr_hash(&S(&res->patterns[i].pat)[res->m - res->B], res->B) + & res->hash->table_mask; + if (h != last_h) { + res->hash->entries[h] = i; + last_h = h; } } + } + res->hash->entries[HASH_TAB_SIZE] = patnum; /* OK, we effectively allocated SIZE+1 */ + for (i = HASH_TAB_SIZE - 1; i >= 0; i--) { + if (res->hash->entries[i] == -1) { + res->hash->entries[i] = res->hash->entries[i + 1]; + } + } + + res->patnum = patnum; - if (! found) { - smart_str_appendc(&result, str[pos++]); + return res; +} +/* }}} */ +/* {{{ php_strtr_array_destroy_ppres(PPRES *d) */ +static void php_strtr_array_destroy_ppres(PPRES *d) +{ + efree(d->shift); + efree(d->hash); + efree(d->prefix); + efree(d->patterns); + efree(d); +} +/* }}} */ + +/* {{{ php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) */ +static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) +{ + STRLEN pos = 0, + nextwpos = 0, + lastpos = L(text) - d->m; + smart_str result = {0}; + + while (pos <= lastpos) { + HASH h = php_strtr_hash(&S(text)[pos + d->m - d->B], d->B) & d->shift->table_mask; + STRLEN shift = d->shift->entries[h]; + + if (shift > 0) { + pos += shift; + } else { + HASH h2 = h & d->hash->table_mask, + prefix_h = php_strtr_hash(&S(text)[pos], d->Bp); + + int offset_start = d->hash->entries[h2], + offset_end = d->hash->entries[h2 + 1], /* exclusive */ + i = 0; + + for (i = offset_start; i < offset_end; i++) { + PATNREPL *pnr; + if (d->prefix[i] != prefix_h) + continue; + + pnr = &d->patterns[i]; + if (L(&pnr->pat) > L(text) - pos || + memcmp(S(&pnr->pat), &S(text)[pos], L(&pnr->pat)) != 0) + continue; + + smart_str_appendl(&result, &S(text)[nextwpos], pos - nextwpos); + smart_str_appendl(&result, S(&pnr->repl), L(&pnr->repl)); + pos += L(&pnr->pat); + nextwpos = pos; + goto end_outer_loop; + } + + pos++; +end_outer_loop: ; } } - efree(key); - zend_hash_destroy(&tmp_hash); - smart_str_0(&result); - RETVAL_STRINGL(result.c, result.len, 0); + smart_str_appendl(&result, &S(text)[nextwpos], L(text) - nextwpos); + + if (result.c != NULL) { + smart_str_0(&result); + RETVAL_STRINGL(result.c, result.len, 0); + } else { + RETURN_EMPTY_STRING(); + } +} +/* }}} */ + +/* {{{ php_strtr_array */ +static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *pats) +{ + PPRES *data; + STR text; + PATNREPL *patterns; + int patterns_len; + zend_llist *allocs; + + S(&text) = str; + L(&text) = slen; + + patterns = php_strtr_array_prepare_repls(slen, pats, &allocs, &patterns_len); + if (patterns == NULL) { + RETURN_FALSE; + } + data = php_strtr_array_prepare(&text, patterns, patterns_len, 2, 2); + efree(patterns); + php_strtr_array_do_repl(&text, data, return_value); + php_strtr_array_destroy_ppres(data); + zend_llist_destroy(allocs); + efree(allocs); } /* }}} */ diff --git a/ext/standard/tests/image/getimagesize.phpt b/ext/standard/tests/image/getimagesize.phpt index ab79c9c76..6cd8275e0 100644 --- a/ext/standard/tests/image/getimagesize.phpt +++ b/ext/standard/tests/image/getimagesize.phpt @@ -23,7 +23,22 @@ GetImageSize() var_dump($result); ?> --EXPECT-- -array(11) { +array(12) { + ["test1bpix.bmp"]=> + array(6) { + [0]=> + int(500) + [1]=> + int(345) + [2]=> + int(6) + [3]=> + string(24) "width="500" height="345"" + ["bits"]=> + int(32) + ["mime"]=> + string(14) "image/x-ms-bmp" + } ["test1pix.bmp"]=> array(6) { [0]=> diff --git a/ext/standard/tests/image/image_type_to_mime_type.phpt b/ext/standard/tests/image/image_type_to_mime_type.phpt index 5d94a6fe5..d83ab8d14 100644 --- a/ext/standard/tests/image/image_type_to_mime_type.phpt +++ b/ext/standard/tests/image/image_type_to_mime_type.phpt @@ -1,8 +1,8 @@ --TEST-- image_type_to_mime_type() --SKIPIF-- -<?php - if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); +<?php + if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); require_once('skipif_imagetype.inc'); ?> --FILE-- @@ -25,7 +25,9 @@ image_type_to_mime_type() var_dump($result); ?> --EXPECT-- -array(11) { +array(12) { + ["test1bpix.bmp"]=> + string(14) "image/x-ms-bmp" ["test1pix.bmp"]=> string(14) "image/x-ms-bmp" ["test1pix.jp2"]=> @@ -48,4 +50,4 @@ array(11) { string(29) "application/x-shockwave-flash" ["test4pix.tif"]=> string(10) "image/tiff" -}
\ No newline at end of file +} diff --git a/ext/standard/tests/image/test1bpix.bmp b/ext/standard/tests/image/test1bpix.bmp Binary files differnew file mode 100644 index 000000000..5522e503d --- /dev/null +++ b/ext/standard/tests/image/test1bpix.bmp diff --git a/ext/standard/tests/strings/bug63943.phpt b/ext/standard/tests/strings/bug63943.phpt new file mode 100644 index 000000000..6018879b2 --- /dev/null +++ b/ext/standard/tests/strings/bug63943.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #63943 (Bad warning text from strpos() on empty needle) +--FILE-- +<?php +strpos("lllllll", ''); +?> +--EXPECTF-- +Warning: strpos(): Empty needle in %sbug63943.php on line %d diff --git a/ext/standard/tests/strings/get_html_translation_table_basic10.phpt b/ext/standard/tests/strings/get_html_translation_table_basic10.phpt new file mode 100644 index 000000000..a5a356885 --- /dev/null +++ b/ext/standard/tests/strings/get_html_translation_table_basic10.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test get_html_translation_table() function: htmlentities/HTML 4/ISO-8859-1 (bug #64011) +--FILE-- +<?php + +function so($a,$b) { return ord($a) - ord($b); } + +$table = HTML_ENTITIES; +$tt = get_html_translation_table($table, ENT_COMPAT, "ISO-8859-1"); +uksort( $tt, 'so' ); +var_dump( count($tt) ); +print_r( $tt ); +echo "Done\n"; + +?> +--EXPECT-- +int(100) +Array +( + ["] => " + [&] => & + [<] => < + [>] => > + [ ] => + [¡] => ¡ + [¢] => ¢ + [£] => £ + [¤] => ¤ + [¥] => ¥ + [¦] => ¦ + [§] => § + [¨] => ¨ + [©] => © + [ª] => ª + [«] => « + [¬] => ¬ + [] => ­ + [®] => ® + [¯] => ¯ + [°] => ° + [±] => ± + [²] => ² + [³] => ³ + [´] => ´ + [µ] => µ + [¶] => ¶ + [·] => · + [¸] => ¸ + [¹] => ¹ + [º] => º + [»] => » + [¼] => ¼ + [½] => ½ + [¾] => ¾ + [¿] => ¿ + [À] => À + [Á] => Á + [Â] => Â + [Ã] => Ã + [Ä] => Ä + [Å] => Å + [Æ] => Æ + [Ç] => Ç + [È] => È + [É] => É + [Ê] => Ê + [Ë] => Ë + [Ì] => Ì + [Í] => Í + [Î] => Î + [Ï] => Ï + [Ð] => Ð + [Ñ] => Ñ + [Ò] => Ò + [Ó] => Ó + [Ô] => Ô + [Õ] => Õ + [Ö] => Ö + [×] => × + [Ø] => Ø + [Ù] => Ù + [Ú] => Ú + [Û] => Û + [Ü] => Ü + [Ý] => Ý + [Þ] => Þ + [ß] => ß + [à] => à + [á] => á + [â] => â + [ã] => ã + [ä] => ä + [å] => å + [æ] => æ + [ç] => ç + [è] => è + [é] => é + [ê] => ê + [ë] => ë + [ì] => ì + [í] => í + [î] => î + [ï] => ï + [ð] => ð + [ñ] => ñ + [ò] => ò + [ó] => ó + [ô] => ô + [õ] => õ + [ö] => ö + [÷] => ÷ + [ø] => ø + [ù] => ù + [ú] => ú + [û] => û + [ü] => ü + [ý] => ý + [þ] => þ + [ÿ] => ÿ +) +Done diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt Binary files differindex 706ddfdcb..9b44584ee 100644 --- a/ext/standard/tests/strings/strpos.phpt +++ b/ext/standard/tests/strings/strpos.phpt diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index 960e8092a..7591ca73e 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Nov 9 19:37:48 2011 */ +/* Generated by re2c 0.13.5 on Mon Jan 21 11:34:03 2013 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index e54449a78..204995783 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -678,10 +678,13 @@ object ":" uiv ":" ["] { do { /* Try to find class directly */ + BG(serialize_lock) = 1; if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { + BG(serialize_lock) = 0; ce = *pce; break; } + BG(serialize_lock) = 0; /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { @@ -696,7 +699,9 @@ object ":" uiv ":" ["] { args[0] = &arg_func_name; MAKE_STD_ZVAL(arg_func_name); ZVAL_STRING(arg_func_name, class_name, 1); + BG(serialize_lock) = 1; if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { + BG(serialize_lock) = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; @@ -704,6 +709,7 @@ object ":" uiv ":" ["] { zval_ptr_dtor(&arg_func_name); break; } + BG(serialize_lock) = 0; if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } diff --git a/main/php_version.h b/main/php_version.h index cf6f24084..98eb67245 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 11 +#define PHP_RELEASE_VERSION 12 #define PHP_EXTRA_VERSION "" -#define PHP_VERSION "5.4.11" -#define PHP_VERSION_ID 50411 +#define PHP_VERSION "5.4.12" +#define PHP_VERSION_ID 50412 diff --git a/main/spprintf.c b/main/spprintf.c index bb401ab13..596e1ef45 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -211,7 +211,7 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap) double fp_num; wide_int i_num = (wide_int) 0; - u_wide_int ui_num; + u_wide_int ui_num = (u_wide_int) 0; char num_buf[NUM_BUF_SIZE]; char char_buf[2]; /* for printing %% and %<unknown> */ @@ -560,7 +560,7 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap) s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); FIX_PRECISION(adjust_precision, precision, s, s_len); - if (alternate_form && i_num != 0) { + if (alternate_form && ui_num != 0) { *--s = *fmt; /* 'x' or 'X' */ *--s = '0'; s_len += 2; diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h index 4b3875577..d88b30c47 100644 --- a/main/streams/php_stream_plain_wrapper.h +++ b/main/streams/php_stream_plain_wrapper.h @@ -31,7 +31,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha #define php_stream_fopen(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened), 0 STREAMS_CC TSRMLS_CC) PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path, int options STREAMS_DC TSRMLS_DC); -#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_CC TSRMLS_CC) +#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened), 0 STREAMS_CC TSRMLS_CC) PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC TSRMLS_DC); #define php_stream_fopen_from_file(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_CC TSRMLS_CC) diff --git a/sapi/fpm/fpm/fpm_sockets.h b/sapi/fpm/fpm/fpm_sockets.h index 499ba6baf..cce5712b8 100644 --- a/sapi/fpm/fpm/fpm_sockets.h +++ b/sapi/fpm/fpm/fpm_sockets.h @@ -25,7 +25,7 @@ enum fpm_address_domain fpm_sockets_domain_from_address(char *addr); int fpm_sockets_init_main(); int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq); -int fpm_socket_unix_test_connect(struct sockaddr_un *sun, size_t socklen); +int fpm_socket_unix_test_connect(struct sockaddr_un *sock, size_t socklen); static inline int fd_set_blocked(int fd, int blocked) /* {{{ */ diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 3e04df95b..f33b04978 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -603,7 +603,7 @@ static void cli_usage( TSRMLS_D ) " args... Arguments passed to script.\n"; php_output_startup(); php_output_activate(TSRMLS_C); - php_printf( usage ); + php_printf( "%s", usage ); #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else diff --git a/tests/classes/bug63462.phpt b/tests/classes/bug63462.phpt new file mode 100644 index 000000000..dc5edbd5e --- /dev/null +++ b/tests/classes/bug63462.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test script to verify that magic methods should be called only once when accessing an unset property. +--CREDITS-- +Marco Pivetta <ocramius@gmail.com> +--XFAIL-- +Bug 63462 is not yet fixed +--FILE-- +<?php +class Test { + public $publicProperty; + protected $protectedProperty; + private $privateProperty; + + public function __construct() { + unset( + $this->publicProperty, + $this->protectedProperty, + $this->privateProperty + ); + } + + function __get($name) { + echo '__get ' . $name . "\n"; + return $this->$name; + } + + function __set($name, $value) { + echo '__set ' . $name . "\n"; + $this->$name = $value; + } + + function __isset($name) { + echo '__isset ' . $name . "\n"; + return isset($this->$name); + } +} + +$test = new Test(); + +$test->nonExisting; +$test->publicProperty; +$test->protectedProperty; +$test->privateProperty; +isset($test->nonExisting); +isset($test->publicProperty); +isset($test->protectedProperty); +isset($test->privateProperty); +$test->nonExisting = 'value'; +$test->publicProperty = 'value'; +$test->protectedProperty = 'value'; +$test->privateProperty = 'value'; + +?> + +--EXPECTF-- +__get nonExisting +Notice: Undefined index: nonExisting in %__set__get_006.php on line %d +__get publicProperty +Notice: Undefined index: publicProperty in %__set__get_006.php on line %d +__get protectedProperty +Notice: Undefined index: protectedProperty in %__set__get_006.php on line %d +__get privateProperty +Notice: Undefined index: privateProperty in %__set__get_006.php on line %d +__isset nonExisting +__isset publicProperty +__isset protectedProperty +__isset privateProperty +__set nonExisting +__set publicProperty +__set protectedProperty +__set privateProperty diff --git a/tests/classes/unset_properties.phpt b/tests/classes/unset_properties.phpt index 7f9b56988..264e720c9 100644 --- a/tests/classes/unset_properties.phpt +++ b/tests/classes/unset_properties.phpt @@ -140,15 +140,15 @@ true new publicProperty value via public access protectedProperty set -__isset "protectedProperty"__isset "protectedProperty"false +__isset "protectedProperty"false __get "protectedProperty" __set "protectedProperty" to "new protectedProperty value via setter" __isset "protectedProperty"true new protectedProperty value via setter privateProperty set -__isset "privateProperty"__isset "privateProperty"false +__isset "privateProperty"false __get "privateProperty" __set "privateProperty" to "new privateProperty value via setter" __isset "privateProperty"true -new privateProperty value via setter
\ No newline at end of file +new privateProperty value via setter diff --git a/win32/registry.c b/win32/registry.c index 638d85ae5..685a09d08 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -91,6 +91,7 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_ INIT_PZVAL(data); Z_STRVAL_P(data) = zend_strndup(value, value_len-1); Z_STRLEN_P(data) = value_len-1; + Z_TYPE_P(data) = IS_STRING; zend_hash_update(ht, name, name_len+1, &data, sizeof(zval*), NULL); } } |
