Xinchen Hui
a15902fa71
fixed IS_REFERENCE handling
2016-08-02 11:05:51 +08:00
Xinchen Hui
4d9195927a
Optimized array_reverse
2016-08-01 20:11:08 +08:00
Nikita Popov
11e050920d
Fix memory unsafety in array_walk()
...
Fixes bugs #61967 , #62607 , #69068 , #70713 .
The primary changes are:
a) Use the ht_iterator mechanism to ensure safety not only if the
iterated array itself changes, but also if it is replaced (and
potentially destroyed) entirely. We use the same semantics for
behavior under modification as foreach-by-reference. In
particular, we advance to the next element before processing it.
If the iterated entity is exchanged we iterate the new one from
the start. If it is not an array/object we warn and abort.
b) Always create a reference to the current value. Previously the
code kept the value as a non-reference and updated it to the
reference value produced by the user callback. However this is
unsafe, as the array may have been reallocated in the meantime,
so the previous value pointer is no longer value.
c) Around a recursive walk, incref the reference containing the
array. This ensures that the location where the currently
iterated value is stored cannot be freed.
One problem I was not able to solve is that we cannot decrement
the apply count if the array is exchanged during a recursive walk.
2016-07-30 00:15:32 +02:00
Nikita Popov
261c436d8c
Merge branch 'PHP-7.0' into PHP-7.1
2016-07-29 19:08:15 +02:00
Nikita Popov
8a442a33c3
Fix ref handling in array_merge/replace_recursive()
...
As usual, if the reference has rc=1 it really isn't a reference.
2016-07-29 19:07:04 +02:00
Xinchen Hui
c35dab005c
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Fixed bug #72622 (array_walk + array_replace_recursive create references from nothing)
2016-07-20 16:12:49 +08:00
Xinchen Hui
3c3b8c8365
Fixed bug #72622 (array_walk + array_replace_recursive create references from nothing)
2016-07-20 16:12:37 +08:00
Nikita Popov
d91e2e47d4
Increase array_rand() rehashing treshold
...
From 3/8 to 3/4. I was thinking in terms of nTableSize, where a
requirement > 1/2 is not tenable. However, we're actually working
with nNumUsed, in which case more than 1/4 tombstones should be
quite unusual.
2016-07-18 23:42:07 +02:00
Nikita Popov
f5452b2b46
Optimize the n=1 case of array_rand()
2016-07-18 23:14:39 +02:00
Leigh
bb1f8228ed
Use zend_bitset
2016-07-07 11:16:01 +01:00
Leigh
06607993f6
Improve array_rand distribution
2016-07-06 12:35:13 +01:00
Leigh
6d6ef7aacc
Alias rand to mt_rand
2016-07-05 15:09:49 +01:00
Xinchen Hui
697e3bb48b
Merge branch 'master' of git.php.net:/php-src
...
* 'master' of git.php.net:/php-src:
typo
Turn safe timeout handling into general interrupt handling ability.
Fixed compilation warnings
yet another test rewrite
Add additional LDAP SASL constants
Add tests for LDAP_OPT_* constants
Add LDAP TLS Protocol Min constants
Add tests for the LDAP CRL check option
Add missing LDAP constants
2016-06-23 20:59:28 +08:00
Xinchen Hui
eb65db0808
Use zend_sort in array_multisort (tests change is expected)
2016-06-23 20:58:45 +08:00
Dmitry Stogov
adc95c5114
Fixed compilation warnings
2016-06-23 12:47:06 +03:00
Dmitry Stogov
1616038698
Added ZEND_ATTRIBUTE_FORMAT to some middind functions.
...
"%p" replaced by ZEND_LONG_FMT to avoid compilation warnings.
Fixed most incorrect use cases of format specifiers.
2016-06-21 16:00:37 +03:00
Dmitry Stogov
4042f543c4
HANDLE_BLOCK/UNBLOCK_INTERRUPTIONS() protection on inter-process data is completely useless now.
...
Historicaly, these macros were introduced as a protection from execution timeout handling, but we don't need them anymore after "safe execution timeout" implementation.
These macros are still useful to protect from termination during inner process data modification, because of OS signals (e.g. SIGTERM during OPcache SHM update).
2016-06-20 15:50:41 +03:00
Dmitry Stogov
a9512af810
Implemented RFC: Fix inconsistent behavior of $this variable
...
Squashed commit of the following:
commit bdd3b6895c
Author: Dmitry Stogov <dmitry@zend.com>
Date: Thu Jun 16 00:19:42 2016 +0300
Fixed GOTO VM
commit 2f1d7c8b89
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Jun 15 21:01:57 2016 +0300
Removed unused variable
commit cf749c42b0
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Jun 15 19:06:16 2016 +0300
Protection from $this reassign through mb_parse_str()
commit 59a9a6c83c
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Jun 15 18:14:50 2016 +0300
Added type inference rule for FETCH_THIS opcode
commit 73f8d14a85
Author: Dmitry Stogov <dmitry@zend.com>
Date: Wed Jun 15 18:11:18 2016 +0300
Restored PHP-7 behavior of isset($this->foo).
It throws exception if not in object context.
Removed useless opcode handlers.
commit fa0881381e
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue May 31 12:25:47 2016 +0300
Changed "Notice: Undefined variable: this" into "Exception: Using $this when not in object context".
commit e32cc528c0
Author: Dmitry Stogov <dmitry@zend.com>
Date: Tue May 24 02:02:43 2016 +0300
Throw exception on attempt to re-assign $this through extract() and parse_str().
commit 41f1531b52
Author: Dmitry Stogov <dmitry@zend.com>
Date: Mon May 23 22:18:36 2016 +0300
Fixed inconsistent $this behavior
2016-06-16 02:30:23 +03:00
Xinchen Hui
42f23effa9
Value should not be a reference here
2016-06-13 13:40:53 +08:00
Dmitry Stogov
b602495e5c
Optimization
2016-06-09 16:01:55 +03:00
Dmitry Stogov
df7dccea83
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Fixed bug #72369 (array_merge() produces references in PHP7)
2016-06-09 15:09:09 +03:00
Dmitry Stogov
bfcf32237e
Fixed bug #72369 (array_merge() produces references in PHP7)
2016-06-09 15:07:44 +03:00
Nikita Popov
91f5940329
Forbid dynamic calls to scope introspection functions
...
Per RFC:
https://wiki.php.net/rfc/forbid_dynamic_scope_introspection
2016-05-24 20:48:24 +02:00
Anatol Belski
41cb432ec4
Merge branch 'PHP-7.0'
...
* PHP-7.0:
update NEWS
Tidy up
Remove unnecessary boundary checks
Resolve bug #72017
2016-05-16 19:31:20 +02:00
Thomas Punt
0e21742bf8
Tidy up
2016-05-16 19:15:40 +02:00
Thomas Punt
367fde9947
Remove unnecessary boundary checks
2016-05-16 19:15:40 +02:00
Thomas Punt
39052d4d75
Resolve bug #72017
2016-05-16 19:15:40 +02:00
Bob Weinand
6d420dc782
Merge branch 'PHP-7.0'
2016-04-28 11:10:53 +02:00
Bob Weinand
74ef863f5d
Fixed bug #72116 (7.0.6 array_fill optimization breaks implementation)
2016-04-28 11:02:47 +02:00
Dmitry Stogov
6499162ff0
- get rid of EG(scope). zend_get_executed_scope() should be used instead.
...
- ichanged zval_update_constant_ex(). Use IS_TYPE_IMMUTABLE flag on shared constants and AST, instead of "inline_change" parameter.
2016-04-28 04:13:34 +03:00
Nikita Popov
30c82321d7
Merge branch 'PHP-7.0'
2016-04-16 09:59:35 +02:00
Nikita Popov
d8590940a1
Use symtable lookup for arrays in array_column
2016-04-16 09:59:01 +02:00
Nikita Popov
28801bf249
Respect property visibility in array_column
2016-04-16 09:59:01 +02:00
Nikita Popov
c0d8dc5bd7
Fixed bug #72031
2016-04-16 09:58:57 +02:00
Dmitry Stogov
58dd3b3a6f
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Optimized array_fill(). This is a perfect function for fast creation of packed arrays.
2016-04-07 01:02:01 +03:00
Dmitry Stogov
b31240f995
Optimized array_fill(). This is a perfect function for fast creation of packed arrays.
2016-04-07 01:01:11 +03:00
Nikita Popov
bc1f884ef7
Merge branch 'PHP-7.0'
2016-03-30 22:49:36 +02:00
Nikita Popov
b1e854f776
Fix bug #71334
...
Always duplicate the array before doing a sort with user-defined
comparison function, to avoid access to the intermediate
inconsistent state.
I've also dropped the "array modification" warning, as protection
against modifications is no longer relevant if we're always working
on a copy anyway.
This also required some changes to how SplArray forwards calls to
sorting functions.
2016-03-30 22:49:27 +02:00
Xinchen Hui
f2b6b26189
Merge branch 'PHP-7.0'
...
Conflicts:
Zend/zend_compile.c
2016-03-17 07:51:26 -07:00
Xinchen Hui
345ecd9822
Fixed #71837 (Wrong arrays behaviour)
2016-03-17 07:41:41 -07:00
Dmitry Stogov
e66ac376cf
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Introduce zend_symtable_exists_ind() for API consistency
2016-03-02 11:54:44 +03:00
Dmitry Stogov
ab800642df
Introduce zend_symtable_exists_ind() for API consistency
2016-03-02 11:53:47 +03:00
Xinchen Hui
f4f140c05d
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Use hash_exists_ind in symbol table
2016-03-02 12:12:12 +08:00
Xinchen Hui
2d4186dde7
Use hash_exists_ind in symbol table
2016-03-02 12:11:13 +08:00
Xinchen Hui
715a198e1f
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Maybe we should introduce a symtable_exists_ind
2016-03-01 20:01:19 +08:00
Xinchen Hui
961c8d568d
Maybe we should introduce a symtable_exists_ind
2016-03-01 20:01:02 +08:00
Xinchen Hui
b17d2ad5f6
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Fixed bug #71695 (Global variables are reserved before execution).
2016-03-01 19:21:16 +08:00
Xinchen Hui
186844be92
Fixed bug #71695 (Global variables are reserved before execution).
...
Instead of slow down hash_merge, we may also check the array(whether it
contains INDIRECT) outside of the loop, however, consisdering hash_merge
is not widly used, I prefer fix this in the current way to keep the
codes simple
2016-03-01 19:19:07 +08:00
Xinchen Hui
b378c7cff1
Merge branch 'PHP-7.0'
...
* PHP-7.0:
Fixed bug #71660 (array_column behaves incorrectly after foreach by reference)
2016-02-25 16:07:38 +08:00
Xinchen Hui
c299b272c7
Fixed bug #71660 (array_column behaves incorrectly after foreach by reference)
2016-02-25 16:07:22 +08:00