|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patch 50816-2.diff for Scripting Engine problem Bug #50816Patch version 2011-07-29 14:30 UTC Return to Bug #50816 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: pierrick@php.net
Index: Zend/tests/bug50816.phpt
===================================================================
--- Zend/tests/bug50816.phpt (revision 0)
+++ Zend/tests/bug50816.phpt (revision 0)
@@ -0,0 +1,35 @@
+--TEST--
+Bug #50816 (Using class constants in array definition fails).
+--FILE--
+<?php
+
+class Foo {
+ const STR_ONE = 'bar';
+ const STR_TWO = 'bar';
+ const INT_ONE = 1;
+ const INT_TWO = 1;
+ const DBL_ONE = 2.2;
+ const DBL_TWO = 2.2;
+ const NULL_ONE = NULL;
+ const NULL_TWO = NULL;
+
+ public static $mapWithConst = array(
+ self::STR_ONE => 'one', self::STR_TWO => 'two',
+ self::INT_ONE => 'one', self::INT_TWO => 'two',
+ self::DBL_ONE => 'one', self::DBL_TWO => 'two',
+ self::NULL_ONE => 'one', self::NULL_TWO => 'two');
+
+}
+var_dump(Foo::$mapWithConst);
+?>
+--EXPECT--
+array(4) {
+ ["bar"]=>
+ string(3) "two"
+ [1]=>
+ string(3) "two"
+ [2]=>
+ string(3) "two"
+ [""]=>
+ string(3) "two"
+}
Index: Zend/tests/bug45742.phpt
===================================================================
--- Zend/tests/bug45742.phpt (revision 313904)
+++ Zend/tests/bug45742.phpt (working copy)
@@ -20,5 +20,5 @@
--EXPECT--
array(1) {
[1]=>
- int(23)
+ int(42)
}
Index: Zend/zend_hash.c
===================================================================
--- Zend/zend_hash.c (revision 313904)
+++ Zend/zend_hash.c (working copy)
@@ -1229,34 +1229,37 @@
if (mode != HASH_UPDATE_KEY_ANYWAY) {
Bucket *q = ht->arBuckets[num_index & ht->nTableMask];
- int found = 0;
while (q != NULL) {
- if (q == p) {
- found = 1;
- } else if (!q->nKeyLength && q->h == num_index) {
- if (found) {
- if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
- break;
- } else {
- if (p->nKeyLength) {
- zend_hash_del(ht, p->arKey, p->nKeyLength);
- } else {
- zend_hash_index_del(ht, p->h);
+ if ((q->h == num_index) && (q->nKeyLength == 0)) {
+ if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
+ Bucket *r = p->pListNext;
+ while(r) {
+ if (r == q) {
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
+ return FAILURE;
}
- return FAILURE;
+ r = r->pListNext;
}
+ break;
} else {
- if (mode & HASH_UPDATE_KEY_IF_AFTER) {
- break;
- } else {
- if (p->nKeyLength) {
- zend_hash_del(ht, p->arKey, p->nKeyLength);
- } else {
- zend_hash_index_del(ht, p->h);
+ Bucket *r = p->pListLast;
+ while(r) {
+ if (r == q) {
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
+ return FAILURE;
}
- return FAILURE;
+ r = r->pListLast;
}
+ break;
}
}
q = q->pNext;
@@ -1273,35 +1276,38 @@
if (mode != HASH_UPDATE_KEY_ANYWAY) {
ulong h = zend_inline_hash_func(str_index, str_length);
Bucket *q = ht->arBuckets[h & ht->nTableMask];
- int found = 0;
while (q != NULL) {
- if (q == p) {
- found = 1;
- } else if (q->h == h && q->nKeyLength == str_length &&
- memcmp(q->arKey, str_index, str_length) == 0) {
- if (found) {
- if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
- break;
- } else {
- if (p->nKeyLength) {
- zend_hash_del(ht, p->arKey, p->nKeyLength);
- } else {
- zend_hash_index_del(ht, p->h);
+ if (q->h == h && q->nKeyLength == str_length &&
+ memcmp(q->arKey, str_index, str_length) == 0) {
+ if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
+ Bucket *r = p->pListNext;
+ while(r) {
+ if (r == q) {
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
+ return FAILURE;
}
- return FAILURE;
+ r = r->pListNext;
}
+ break;
} else {
- if (mode & HASH_UPDATE_KEY_IF_AFTER) {
- break;
- } else {
- if (p->nKeyLength) {
- zend_hash_del(ht, p->arKey, p->nKeyLength);
- } else {
- zend_hash_index_del(ht, p->h);
+ Bucket *r = p->pListLast;
+ while(r) {
+ if (r == q) {
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
+ return FAILURE;
}
- return FAILURE;
+ r = r->pListLast;
}
+ break;
}
}
q = q->pNext;
|
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |