Commit graph

517 commits

Author SHA1 Message Date
Nikita Popov
736633310c Merge branch 'PHP-7.0' into PHP-7.1 2016-10-20 13:26:34 +02:00
Adam Saponara
55d17662cb Fix bug #71241: array_replace_recursive mutates ref params
`array_replace_recursive` can sometimes mutate its params if
references are nested within. This differs from the PHP 5 behavior.
2016-10-20 13:22:04 +02:00
Márcio Almada
cba560e67f add extra test to protected behavior of compact and array string key order 2016-09-01 13:01:42 +02:00
Márcio Almada
00c2c3a476 fix unintentional bc break with compact('this') behavior 2016-09-01 13:01:38 +02: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
Leigh
06607993f6 Improve array_rand distribution 2016-07-06 12:35:13 +01:00
Xinchen Hui
eb65db0808 Use zend_sort in array_multisort (tests change is expected) 2016-06-23 20:58:45 +08:00
Dmitry Stogov
ff363e2e7c Implemented RFC: Replace "Missing argument" warning with "Too few arguments" exception
Squashed commit of the following:

commit 8b45fa2acb
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 01:52:50 2016 +0300

    Separate slow path of ZEND_RECV into a cold function.

commit 9e18895ee5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 23:26:28 2016 +0300

    Required argument can't be IS_UNDEF anymore.

commit 662db66e39
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 17:14:50 2016 +0300

    Replace "Missing argument" warning by "Too few arguments" exception.
2016-06-16 02:32:02 +03:00
Dmitry Stogov
bfcf32237e Fixed bug #72369 (array_merge() produces references in PHP7) 2016-06-09 15:07:44 +03:00
Thomas Punt
39052d4d75 Resolve bug #72017 2016-05-16 19:15:40 +02:00
Bob Weinand
74ef863f5d Fixed bug #72116 (7.0.6 array_fill optimization breaks implementation) 2016-04-28 11:02:47 +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
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
345ecd9822 Fixed #71837 (Wrong arrays behaviour) 2016-03-17 07:41:41 -07:00
Xinchen Hui
c299b272c7 Fixed bug #71660 (array_column behaves incorrectly after foreach by reference) 2016-02-25 16:07:22 +08:00
Xinchen Hui
0fccd154bd Fixed bug #71603 (compact() maintains references in php7) 2016-02-16 11:02:57 +08:00
Thomas Punt
3bbcd84e2f re-apply patch for github PR #1695 2016-01-12 07:07:51 +01:00
Anatol Belski
66d10fe085 Revert "patch for github PR #1695"
This reverts commit 58dd956b63.

crashes on travis
2016-01-11 22:03:36 +01:00
Thomas Punt
58dd956b63 patch for github PR #1695 2016-01-11 21:11:55 +01:00
Xinchen Hui
decb934e3a Fixed test (extract is no affected) 2015-12-25 21:31:42 -08:00
Xinchen Hui
c56efb848b Fixed bug #71220 (Null pointer deref (segfault) in compact via ob_start) 2015-12-25 21:25:53 -08:00
Xinchen Hui
801e46d8c0 Add test for bug (count on symbol table)
I should have do this ....
2015-11-23 06:21:30 -08:00
Xinchen Hui
fce44a5a13 Fixed bug #70910 (extract() breaks variable references) 2015-11-13 19:39:59 -08:00
Xinchen Hui
179fba3f38 Fixed bug #70808 (array_merge_recursive corrupts memory of unset items)
I knew, this fix seems ugly
2015-10-29 14:33:58 +08:00
Dmitry Stogov
3815e97136 Fixed bug #70668 (array_keys() doesn't respect references when $strict is true) 2015-10-08 14:59:02 +03:00
Dmitry Stogov
24e88348f3 Revert "Merge branch 'array_keys_strict_refs' of https://github.com/tony2001/php-src"
This reverts commit a6be0f3fd6.
2015-10-06 23:48:12 +03:00
Bob Weinand
a6be0f3fd6 Merge branch 'array_keys_strict_refs' of https://github.com/tony2001/php-src 2015-10-05 14:50:04 +02:00
Dmitry Stogov
2d475eb943 Fixed tests on 32-bit systems 2015-08-17 12:54:33 +03:00
Anatol Belski
86984d7ade add range() tests 2015-08-14 14:34:48 +02:00
Xinchen Hui
dc5c6ab774 Fixed bug #70250 (extract() turns array elements to references) 2015-08-13 13:30:25 +08:00
Xinchen Hui
a6b47e8d68 Merge branch 'zval_dump_consistent' of https://github.com/laruence/php-src 2015-07-30 13:14:38 +08:00
Xinchen Hui
7d5fb7bbf3 Fixed bug #69674 (SIGSEGV array.c:953) 2015-07-29 10:46:12 +08:00
Xinchen Hui
c55c7ef0ec Make debug_val_dump and var_dump prints int and float the same 2015-07-23 12:14:34 +08:00
Tjerk Meesters
3bf012a98d Feature: Enhanced array_column() to also work with object elements. 2015-06-27 07:35:44 +08:00
Anatol Belski
269acaa363 Merge branch 'pull-request/1284'
* pull-request/1284:
  Rename interface macros
  Fix typo in UPGRADING
  Move definition of Throwable to zend_exceptions.h/c
  Check for zend_ce_throwable instead
  Fix some missed tests
  Add Throwable tests
  Fix previous exception type check
  Updated UPGRADING with RFC link
  Changed AssertionException to AssertionError
  Update exception error messages
  Throwable method signatures.
  Update exception names in tests after formatting changes.
  Merge exception formatting changes.
  Make zend_get_exception_base static.
  Fix a few missed tests.
  Fix handler double copy.
  Updated tests to reflect exception class changes.
  Remodel exceptions based on Throwable interface
2015-06-17 21:55:03 +02:00
Nikita Popov
183c00ddb6 Fix references handling in convert_scalar_to_number 2015-06-16 18:02:45 +02:00
Aaron Piotrowski
110e0a5a2c Merge branch 'master' into throwable-interface
# Conflicts:
#	Zend/zend_language_scanner.c
#	Zend/zend_language_scanner.l
#	ext/simplexml/tests/SimpleXMLElement_xpath.phpt
2015-06-14 18:53:11 -05:00
Xinchen Hui
ed8d1ba7dd Fixed bug #69723 (Passing parameters by reference and array_column) 2015-05-29 13:50:44 +08:00
Aaron Piotrowski
e97d5fab35 Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
Nikita Popov
3ae995f03c Tweak uncaught exception message display
This implements a reduced variant of #1226 with just the following
change:

-Fatal error: Uncaught exception 'EngineException' with message 'Call to private method foo::bar() from context ''' in %s:%d
+Fatal error: Uncaught EngineException: Call to private method foo::bar() from context '' in %s:%d

The '' wrapper around messages is very weird if the exception
message itself contains ''. Futhermore having the message wrapped
in '' doesn't work for the "and defined" suffix of
TypeExceptions.
2015-05-17 18:47:06 +02:00
Nikita Popov
c9f27ee422 Display EngineExceptions like ordinary exceptions
TypeException stays as-is for now because it uses messages that are
incompatible with the way exception messages are displayed.

closure_038.phpt and a few others now show that we're generating
too many exceptions for compound operations on undefined properties
-- this needs to be fixed in a followup.
2015-05-15 23:40:32 +02:00
Nikita Popov
94bea670de Fix bug #69413 2015-04-10 09:49:07 +02:00
Xinchen Hui
b6aeab1b91 Fixed bug #69371 (Hash table collision leads to inaccessible array keys) 2015-04-05 18:45:14 +08:00
Dmitry Stogov
dcaa79546b Don't relay on reference-counter when parameter expected to be a reference, but value given. 2015-04-03 16:35:06 +03:00