?? ??? 2016 PHP 7.0.5
- Core:
+ . Fixed bug #71695 (Global variables are reserved before execution).
+ (Laruence)
. Fixed bug #71629 (Out-of-bounds access in php_url_decode in context
php_stream_url_wrap_rfc2397). (mt at debian dot org)
. Fixed bug #71622 (Strings used in pass-as-reference cannot be used to
--- /dev/null
+--TEST--
+Bug #71695 (Global variables are reserved before execution)
+--FILE--
+<?php
+function provideGlobals() {
+ var_dump(array_key_exists("foo", $GLOBALS));
+ var_dump(isset($GLOBALS["foo"]));
+ $GLOBALS += array("foo" => "foo");
+}
+
+provideGlobals();
+echo $foo;
+?>
+--EXPECT--
+bool(false)
+bool(false)
+foo
uint32_t idx;
Bucket *p;
zval *t;
- uint32_t mode = (overwrite?HASH_UPDATE:HASH_ADD);
IS_CONSISTENT(source);
IS_CONSISTENT(target);
p = source->arData + idx;
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;
if (p->key) {
- t = _zend_hash_add_or_update(target, p->key, &p->val, mode ZEND_FILE_LINE_RELAY_CC);
- if (t && pCopyConstructor) {
- pCopyConstructor(t);
+ if (EXPECTED((t = zend_hash_find_ind(target, p->key)) == NULL)) {
+ t = zend_hash_update_ind(target, p->key, &p->val);
+ if (t && pCopyConstructor) {
+ pCopyConstructor(t);
+ }
+ } else {
+ if (!overwrite) {
+ continue;
+ }
+ if (target->pDestructor) {
+ target->pDestructor(t);
+ }
+ ZVAL_COPY_VALUE(t, &p->val);
+ if (pCopyConstructor) {
+ pCopyConstructor(t);
+ }
}
} else {
- if ((mode==HASH_UPDATE || !zend_hash_index_exists(target, p->h))) {
+ if ((overwrite || !zend_hash_index_exists(target, p->h))) {
t = zend_hash_index_update(target, p->h, &p->val);
if (t && pCopyConstructor) {
pCopyConstructor(t);
PHP_FUNCTION(array_key_exists)
{
zval *key; /* key to check for */
+ zval *val; /* val to check for */
HashTable *array; /* array to check in */
#ifndef FAST_ZPP
switch (Z_TYPE_P(key)) {
case IS_STRING:
- if (zend_symtable_exists(array, Z_STR_P(key))) {
+ if ((val = zend_symtable_find_ind(array, Z_STR_P(key)))) {
RETURN_TRUE;
}
RETURN_FALSE;