Commit Graph

1771 Commits

Author SHA1 Message Date
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
fb346c8f93 Support references in convert_to_*
conver_to_* functions now accept REFERENCE values, which will be
unwrapped before performing the usual conversion. This is consistent
with convert_scalar_to_number and matches the expected behavior in
a couple random use-sites I checked.

Also includes a couple fixes/cleanups elsewhere and two tests for
cases that previously didn't work (though the reference issue existed
all over the place).
2015-06-16 19:55:33 +02:00
Dmitry Stogov
6ae375db31 Fixed bug #69845 (ArrayObject with ARRAY_AS_PROPS broken) 2015-06-16 10:53:53 +03: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
Dmitry Stogov
8e10e8f921 Avoid zval duplication in ZVAL_ZVAL() macro (it was necessary only in few places).
Switch from ZVAL_ZVAL() to simpler macros where possible (it makes sense to review remaining places)
2015-06-12 12:33:23 +03:00
Nikita Popov
5d3cf577aa Make convert_to_* safe with rc>1
This only involves switching zval_dtor to zval_ptr_dtor for arrays
and making the convert_to_object for arrays a bit more generic.

All the other changes outside zend_operators.c just make use of
this new ability (use COPY instead of DUP).

What's still missing: Proper references handling. I've seen many
convert_to* calls that will break when a reference is used.

Also fixes bug #69788.
2015-06-11 23:23:57 +02:00
Anatol Belski
c8cf54719f Merge branch 'PHP-5.6'
* PHP-5.6:
  fixed test related to fix for bug #67805
2015-06-08 13:28:53 +02:00
Anatol Belski
18b3508c3c Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  fixed test related to fix for bug #67805
2015-06-08 13:28:23 +02:00
Anatol Belski
17f2d1e8a7 fixed test related to fix for bug #67805 2015-06-08 13:27:22 +02:00
Anatol Belski
3c02e6f457 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  updated NEWS
  Fix bug #67805 - SplFileObject setMaxLineLength.
2015-06-08 12:11:58 +02:00
Willian Gustavo Veiga
b470d9a0d6 Fix bug #67805 - SplFileObject setMaxLineLength. 2015-06-08 12:08:05 +02:00
Willian Gustavo Veiga
8e747f6833 Fix bug #67805 - SplFileObject setMaxLineLength. 2015-06-08 11:36:27 +02:00
Anatol Belski
0cd86f6b77 fix dir separator in test 2015-06-08 11:29:04 +02:00
Stanislav Malyshev
c0a54d62e2 fix test 2015-06-01 23:58:19 -07:00
Stanislav Malyshev
75d16a4564 Merge branch 'PHP-5.6'
* PHP-5.6:
  Fix bug #69737 - Segfault when SplMinHeap::compare produces fatal error

Conflicts:
	ext/spl/spl_heap.c
2015-06-01 22:55:16 -07:00
Stanislav Malyshev
e96c64ed5e Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fix bug #69737 - Segfault when SplMinHeap::compare produces fatal error
2015-06-01 22:53:56 -07:00
Stanislav Malyshev
1cbd25ca15 Fix bug #69737 - Segfault when SplMinHeap::compare produces fatal error 2015-06-01 22:07:16 -07:00
Nikita Popov
4e03ba4a6e Add GC support for ArrayObject
gc_024 test changes because the array that ArrayObject holds is
now counted separately from the ArrayObject.
2015-05-20 18:28:09 +02:00
Aaron Piotrowski
e97d5fab35 Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
Aaron Piotrowski
fb7206e452 Merge branch 'master' into throwable-interface 2015-05-17 16:15:35 -05:00
Nikita Popov
440481fb3e Display TypeExceptions like normal exceptions
We currently don't show the argument at which the error actually
occured in the trace - should probably either add it or don't
display args on incomplete frames altogether, otherwise this'll
probably be confusing.
2015-05-17 19:54:12 +02: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
Aaron Piotrowski
64b167d201 Updated tests to reflect exception class changes. 2015-05-16 16:49:14 -05: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
Dmitry Stogov
d880ead8a7 Improve fast_is_[not_]identical() functions to teturn value instead of takeing additional arguments.
Pair INSTANCEOF with the following JMPZ/JMPNZ.
2015-04-29 16:43:23 +03:00
Nikita Popov
e0a39eecf1 Respect USE_OTHER in spl_array_is_object
Also a bit of code cleanup in get_hash_table.
2015-04-25 16:13:39 +02:00
Nikita Popov
66ce7cc083 Don't store $this reference for IS_SELF AO
The var_dump output changes in array_022.phpt were wrong previously,
the "storage" that was referenced there was not the actually used
storage.
2015-04-25 16:13:37 +02:00
Nikita Popov
3140d0c0c8 Drop ArrayObject IS_REF flag 2015-04-25 16:13:32 +02:00
Nikita Popov
c77d97f356 Implement GC for spl dll
As far as I can discern this should be safe, because the rc on the
linked list elements is only > 1 if an iterator points to it and
the iterator will also hold a reference to the list object.

The implementation for mangagement of the GC array is the same as
with the spl object storage.
2015-04-16 15:46:28 +02:00
Nikita Popov
6c98024f87 Drop unused is_self member 2015-04-16 15:33:47 +02:00
Nikita Popov
86152b18a3 Add GC support to SPL heap and PQ
ctor/dtor are now no longer called for insert/delete_top operations,
only for cloning and freeing of the object. Otherwise elements will
have a minimum rc of 2 and GC won't be able to free them.
2015-04-15 22:00:12 +02:00
Nikita Popov
dc764bf644 Use object apply count in var_dump / print_r
Instead of using the array apply count on the debug_info array, use
the object apply count for recursion detection when dumping. This
handles recursion in a more generic way and does not require each
debug_info handler to deal with this.

This allows returning a temporary debug_info array, instead of
having to store it in the object (thus delaying destruction of the
values).

Switch SPL debug_info handlers to use a temporary array.
2015-04-15 22:00:12 +02:00
Nikita Popov
eed18f0ee8 Return null on zpp failure in Array::exchangeArray()
Method was still returning a value despite zpp failing previously...
2015-04-15 20:43:41 +02:00
Nikita Popov
e10be0d0fd Remove unnecessary retval members in SPL
This is what the rv params are for. Avoid holding onto values
longer than necessary.
2015-04-15 20:39:08 +02:00
Nikita Popov
b4b872f4c9 Fix leak in RecursiveRegexIterator::getChildren() 2015-04-15 20:03:15 +02:00
Nikita Popov
7605e02e3b Fix leaks in recursive iterator construction 2015-04-15 19:51:02 +02:00
Dmitry Stogov
2b6a568df1 Changed ArrayIterator implementation using zend_hash_iterator_... API. Allowed modification of itterated ArrayObject using the same behavior as proposed in Fix "foreach" behavior. Removed "Array was modified outside object and internal position is no longer valid" hack. 2015-04-09 15:40:17 +03:00
Dmitry Stogov
4d9a1883aa Fixed bug #68887 (resources are not freed correctly) 2015-04-08 13:29:42 +03:00
Xinchen Hui
f23f7dfed0 Use new macros 2015-04-08 14:30:47 +08:00
Nikita Popov
122d759618 Always throw TypeException on throwing zpp failures
Introduces a ZEND_PARSE_PARAMS_THROW flag for zpp, which forces to
report FAILURE errors using a TypeException instead of a Warning,
like it would happen in strict mode.

Adds a zend_parse_parameters_throw() convenience function, which
invokes zpp with this flag.

Converts all cases I could identify, where we currently have
throwing zpp usage in constructors and replaces them with this API.
Error handling is still replaced to EH_THROW in some cases to handle
other, domain-specific errors in constructors.
2015-04-06 11:27:34 +02: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
Dmitry Stogov
ea09a9fa32 Convert fatal errors into EngineExceptions
Make zval_update_constant_ex(), zval_update_constant(), zend_update_class_constants() and zend_ast_evaluate() return SUCCESS or FAILURE.
2015-04-02 02:05:25 +03:00
Nikita Popov
8d00385871 Reclassify E_STRICT notices
Per RFC https://wiki.php.net/rfc/reclassify_e_strict

While reviewing this, found that there are still three E_STRICTs
left in libraries - need to discuss those.
2015-04-01 11:17:55 +02:00
Dmitry Stogov
4796e0242b Merge branch 'InternalClassClean'
* InternalClassClean:
  Fixed test
  Patch improvement:
  Fixed indentation. Fixed comment style. Fixed commented out code.
  Reverted change to function name and added note of why it is different from the class it is actually changing.
  Made UConverter throw an exception if the constructor fails.
  Fixed PDO constructor to not return null.
  Fixed fileinfo behaviour.
  Made Phar throw exception on bad constructor.
  Converted intl extension to use IntlException in constructors.
  Fixed SplFixedArray and tests.
  Fixed ReflectionExtension and ReflectionProperty.
  Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.
  Fixed PDORow behaviour and message.
2015-04-01 12:11:13 +03:00
Xinchen Hui
fd1a7c5f2d Add XFAIL test 2015-03-31 11:53:52 +08:00
Dmitry Stogov
9155a267ad Merge branch 'InternalClassClean' of github.com:Danack/php-src into InternalClassClean
* 'InternalClassClean' of github.com:Danack/php-src:
  Fixed indentation. Fixed comment style. Fixed commented out code.
  Reverted change to function name and added note of why it is different from the class it is actually changing.
  Made UConverter throw an exception if the constructor fails.
  Fixed PDO constructor to not return null.
  Fixed fileinfo behaviour.
  Made Phar throw exception on bad constructor.
  Converted intl extension to use IntlException in constructors.
  Fixed SplFixedArray and tests.
  Fixed ReflectionExtension and ReflectionProperty.
  Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.
  Fixed PDORow behaviour and message.
2015-03-30 12:14:43 +03:00
Anatol Belski
663074b6b1 cleanup mod version macros and mod defs, round x 2015-03-23 21:30:22 +01:00
Dmitry Stogov
d146d15003 Optimize zend_string_realloc() add more specialized versions zend_string_extend() and zend_string_truncate() 2015-03-20 02:02:42 +03:00
Danack
910a324306 Fixed indentation. Fixed comment style. Fixed commented out code. 2015-03-16 23:14:56 +00:00
Xinchen Hui
9420a2a5b0 Merge branch 'PHP-5.6' 2015-03-14 11:32:09 +08:00
Xinchen Hui
96bb3b838c Merge branch 'PHP-5.5' into PHP-5.6 2015-03-14 11:31:53 +08:00
Xinchen Hui
5b87d52041 Fixed typo 2015-03-14 11:31:12 +08:00
Xinchen Hui
326ac546ab Remove TSRMLS 2015-03-14 01:04:00 +08:00
Xinchen Hui
e827d1a424 Merge branch 'PHP-5.6'
Conflicts:
	ext/spl/spl_observer.c
2015-03-14 01:01:02 +08:00
Xinchen Hui
396bc00caa Merge branch 'PHP-5.5' into PHP-5.6 2015-03-14 00:53:32 +08:00
Xinchen Hui
ed59370f0a Little improvement, update NEWs, added test 2015-03-14 00:52:53 +08:00
Dmitry Stogov
2b42d71908 Changed HashTable layout:
Removed HashTable->arHash (reduced memory consumption). Now hash slots may be accessed using HT_HASH() macro.
Hash slotas are allocated together with Buckets (before them) and lay in reverse order from HashTable->arData base address (see comments in Zend/zend_types.h)
Indexes in hash table and conflict resolution chains (Z_NEXT) may be stored as indeces or offsets in bytes, depending on system (32 or 64-bit).
HashTable data filelds are reordered to keep the most useful for zend_hash_find() data in the same CPU cache line.
2015-03-13 17:13:19 +03:00
Vektah
482500b455 Fix a leak 2015-03-13 15:54:30 +11:00
Vektah
950d3d6e9b Fix bug #69227 and #65967
This patch fixes a use (in zend_gc.c) after free (in spl_observer.c).
See https://bugs.php.net/bug.php?id=69227
2015-03-13 15:02:05 +11:00
Dmitry Stogov
8633685675 Use specialized macro for string zval creation 2015-03-12 16:53:51 +03:00
Dmitry Stogov
48deb1cd94 Free memory if destructor wasn't called 2015-03-11 00:57:28 +03:00
Dmitry Stogov
a30d328671 Errors converted to exceptions are not "recoverable" anymore. 2015-03-10 10:31:55 +03:00
Dmitry Stogov
1c94ff0595 Implement engine exceptions
RFC: https://wiki.php.net/rfc/engine_exceptions_for_php7

Pending changes regarding naming of BaseException and whether it
should be an interface.
2015-03-09 14:01:32 +01:00
Stanislav Malyshev
a8a77fff5c Merge branch 'PHP-5.6'
* PHP-5.6:
  Regression tests for SplFileInfo class setters
2015-03-08 17:13:32 -07:00
Stanislav Malyshev
dcc031470a Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Regression tests for SplFileInfo class setters
2015-03-08 17:13:25 -07:00
Stanislav Malyshev
a2a20d29a8 Merge branch 'pull-request/1134' into PHP-5.5
* pull-request/1134:
  Regression tests for SplFileInfo class setters
2015-03-08 17:13:02 -07:00
Dmitry Stogov
2fa8d67a5c Use zend_string* instead of char* for opened_patch handling. Avoid reallocations and improve string reuse. 2015-03-04 02:05:28 +03:00
Jeremy Mikola
dea7bc8786 Regression tests for SplFileInfo class setters
Adds tests for SplFileInfo class setters accepting either the base and child classes, and throwing an exception for unexpected classes.

Related: http://svn.php.net/viewvc?view=revision&revision=336017 and https://github.com/facebook/hhvm/pull/4917
2015-03-02 14:45:26 -05:00
Danack
c57bde7c9e Fixed SplFixedArray and tests. 2015-03-01 13:44:55 +00:00
Reeze Xia
1b240ff9e3 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fixed bug #69141 Missing arguments in reflection info for some builtin functions
2015-02-28 16:40:06 +08:00
Reeze Xia
f824f91ac9 Fixed bug #69141 Missing arguments in reflection info for some builtin functions
This include:

- setcookie (missing "httponly")
- setrawcookie (missing "httponly")
- spl_autoload_register (missing 2 optional params)
- mktime  (missing "is_dst")
- gmmktime (missing "is_dst")
2015-02-28 16:37:14 +08:00
Xinchen Hui
aadf7366e0 Merge branch 'PHP-5.6'
Conflicts:
	ext/spl/spl_observer.c
2015-02-25 18:23:54 +08:00
Xinchen Hui
9641bac0f5 Merge branch 'PHP-5.5' into PHP-5.6 2015-02-25 18:22:18 +08:00
Xinchen Hui
ffdc5728c8 Fixed bug #69108 ("Segmentation fault" when (de)serializing SplObjectStorage) 2015-02-25 18:21:59 +08:00
Julien Pauli
ee2f749a22 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fixed test fails for bug68557
2015-02-23 10:35:35 +01:00
Xinchen Hui
d5a1a3342b Fixed test fails for bug68557 2015-02-23 10:35:16 +01:00
Xinchen Hui
ea94be490a Fixed test fails for bug68557 2015-02-21 12:36:38 +08:00
Anatol Belski
cfae254b6b Merge branch 'PHP-5.6'
* PHP-5.6:
  split test for bug #68557 for windows
2015-02-20 16:02:32 +01:00
Anatol Belski
b21d0848c9 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  split test for bug #68557 for windows
2015-02-20 16:02:07 +01:00
Anatol Belski
3082177bee split test for bug #68557 for windows 2015-02-20 16:01:34 +01:00
Julien Pauli
72af5cda27 Merge branch 'PHP-5.6'
* PHP-5.6:
  fix #68557

Conflicts:
	ext/spl/spl_directory.c
2015-02-20 15:40:46 +01:00
Julien Pauli
13c3b78f1e Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  fix #68557
2015-02-20 15:38:48 +01:00
Julien Pauli
c111d1cd70 fix #68557 2015-02-20 15:09:35 +01:00
Xinchen Hui
b73fa1fa8f Fixed build on windows 2015-02-14 12:57:53 +08:00
Dmitry Stogov
e10e151e9b Merged zend_array and HashTable into the single data structure.
Now each HashTable is also zend_array, so it's refcounted and may be a subject for Copy on Write
zend_array_dup() was changed to allocate and return HashTable, instead of taking preallocated HashTable as argument.
2015-02-13 22:20:39 +03:00
Dmitry Stogov
4241a090ad Avoid reallocation in preg_replace() if nothing was replaced 2015-02-10 13:30:25 +03:00
Dmitry Stogov
9e70d7672d Move zend_object->guards into additional slot of zend_object->properties_table[]. As result size of objects without __get/__set/__unset/__isset magic methods is reduced. 2015-02-04 15:24:13 +03:00
Xinchen Hui
59593ba66c Fixed #68915 (wrong assertion here) 2015-01-27 15:58:32 +08:00
Dmitry Stogov
3e31838d19 zend_read_property() has to provide a holder for return value.
Previously it was possible that zend_read_property() returned pointer to zval allocated on stack.
2015-01-22 11:50:42 +03:00
Andrea Faulds
0be3626ec6 fix build 2015-01-18 19:20:12 +00:00
Xinchen Hui
4b3ae843fc Fixed #68832 (Unchecked return value) 2015-01-17 22:19:25 -05:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Xinchen Hui
0579e8278d bump year 2015-01-15 23:26:37 +08:00
Xinchen Hui
73c1be2653 Bump year 2015-01-15 23:26:03 +08:00
Stanislav Malyshev
8d26c53f7c Fix bug #68816 - pointer to local outside of scope 2015-01-14 16:14:43 -08:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Nikita Popov
1266515e19 Fix uses of zval_add_ref and add comment on usage
zval_add_ref should be used as a copy ctor, after the value was
already copied.

In particular when used with hash insertions, it should be applied
to the return value of the insert function.
2015-01-05 17:02:11 +01:00
Stanislav Malyshev
ee7decb7ff Revert "Add type info for spl_autoload_register"
This reverts commit ad728725cb.

Revert the change for now, probably needs better handling with account to BC
or joined with exceptions-in-engine RFC.
2014-12-29 09:50:00 -08:00
Levi Morrison
ad728725cb Add type info for spl_autoload_register 2014-12-28 10:16:25 -07:00
Levi Morrison
9a7ee202bb Fix bug #68641
Include more reflection information for spl_autoload_register
2014-12-27 19:05:16 -07:00