Commit Graph

736 Commits

Author SHA1 Message Date
Dmitry Stogov
0f7f1498be Use ZEND_THIS macro to hide implementation details in extensions code. 2018-11-15 19:54:19 +03:00
Dmitry Stogov
c6ad0b92b7 Replace getThis() by EX(This), when additional check is not necessary. 2018-11-14 02:44:25 +03:00
Peter Kokot
d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00
Peter Kokot
b746e69887 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:32:30 +02:00
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:31:31 +02:00
Peter Kokot
d7a3edd45d Trim trailing whitespace in *.phpt 2018-10-14 19:46:15 +02:00
Peter Kokot
782352c54a Trim trailing whitespace in *.phpt 2018-10-14 19:45:12 +02:00
Peter Kokot
17ccbeec32 Trim trailing whitespace in *.phpt 2018-10-14 19:44:14 +02:00
Gabriel Caruso
9c144e0d82
Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
Peter Kokot
1ad08256f3 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:56:38 +02:00
Peter Kokot
1c850bfcca Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:55:24 +02:00
Peter Kokot
60a69daec6 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:54:08 +02:00
Peter Kokot
37c329d715 Trim trailing whitespace in source code files 2018-10-13 14:17:28 +02:00
Peter Kokot
3362620b5f Trim trailing whitespace in source code files 2018-10-13 14:16:33 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Peter Kokot
c951836721 Remove unused files
- ext/simplexml/tests/bug25756_1.xml
- ext/simplexml/tests/bug25756_2.xml
- ext/simplexml/tests/bug25756.xsd
Added via 503d74aa29 and then removed via
9e29f17493

- ext/mysqli/tests/cacert.pem
- ext/mysqli/tests/client-cert.pem
- ext/mysqli/tests/client-key.pem
Added via e9f9f66f2e and then removed via
6d51b7b2e3

- ext/gd/tests/simpletext私はガラスを食べられます.jpg
Added via 3d3f11ede4 and never used

- ext/gd/tests/src.png
Added via cc938b5df0 and never used

- ext/zlib/tests/gzgetss.test
Added via d536ecac5c as a file content of the
ext/zlib/tests/gzgetss.gzbut but never used in tests directly. Removed for
better clarity of zlib tests

- ext/soap/tests/interop/Round3/GroupD/round3_groupD_import2_absolute.wsdl
- ext/soap/tests/interop/Round4/GroupG/round4_groupG_mimerpc.wsdl
- ext/soap/tests/interop/Round4/GroupG/round4_groupG_mimedoc.wsdl
Added via 1d25fc5c7b and never used

- ext/reflection/tests/exception.inc
Removed via 9f8ba2e8a1

- ext/phar/tests/files/extracted.inc
Removed via 549bf83bd1

- ext/phar/tests/cache_list/files/extracted.inc
Added via 05c3104097 and never used
2018-09-26 12:54:20 +02:00
Peter Kokot
bfa2c7158f Fix permissions
Certain files don't need to be executables.
2018-09-21 14:12:25 +02:00
Peter Kokot
409b5133cc Change some permissions from 755 to 644
This patch syncs file permissions accross the PHP source code files
since these don't need to be executable.
2018-08-28 23:26:49 +02:00
Christoph M. Becker
692e5d5c88 Fix #76712: Assignment of empty string creates extraneous text node
We work around this peculiarity of libxml by using xmlNodeSetContent(),
which does not exhibit this behavior.  This also saves us from manually
calculating the string length.
2018-08-25 14:24:09 +02:00
Peter Kokot
cf3b852109 Trim trailing whitespaces in build files
Some editors utilizing .editorconfig automatically trim whitespaces. For
convenience this patch removes whitespaces in certain build files:
- ext/*/config*.m4
- configure.ac
- acinclude.m4
2018-07-29 03:43:45 +02:00
Gabriel Caruso
7ec64a831d
Remove superfluous check for PHP 7+ tests 2018-07-27 00:48:30 -03:00
Peter Kokot
a5e80b22e1 Fix typos in code comments 2018-07-25 11:57:11 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
7d4e18b05d Improved user iterator implementation to reduce zend_class_entry memory consumption and avoid race condition during resolving/caching of user iterator functions of internal classes in ZTS build. 2018-07-12 14:04:14 +03:00
Dmitry Stogov
67b4c3379a Uze ZVAL_COPY_DEREF() instead of ZVAL_DEREF() and ZVAL_COPY() 2018-07-09 12:46:46 +03:00
Dmitry Stogov
4a475a4976 Replace legacy zval_dtor() by zval_ptr_dtor_nogc() or even more specialized destructors.
zval_dtor() doesn't make a lot of sense in PHP-7.* and it's used incorrectly in some places.
Its occurances should be replaced by zval_ptr_dtor() or zval_ptr_dtor_nogc(), or even more specialized destructors.
2018-07-04 19:22:24 +03:00
Peter Kokot
07257a59d0 Normalize SimpleXML phpinfo output 2018-06-02 13:44:41 +02:00
Dmitry Stogov
f2b4ec4bdc Export standard object handlers, to avoid indirect access 2018-05-31 11:57:22 +03:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Dmitry Stogov
1af60a2a71 Keep initialized object_handlers structures in read-only memory. 2018-03-14 14:01:45 +03:00
Christoph M. Becker
ef255c9f0f Revert "[ci skip] Add missing return types to protos"
This reverts commit a2c7c46d5e.

Since apparently there have been some mistakes in this commit, and it's
not clear yet how to solve them, we're reverting for now.
2018-02-27 17:40:03 +01:00
Gabriel Caruso
a2c7c46d5e [ci skip] Add missing return types to protos 2018-02-24 11:45:17 +01:00
Gabriel Caruso
ded3d984c6 Use EXPECT instead of EXPECTF when possible
EXPECTF logic in run-tests.php is considerable, so let's avoid it.
2018-02-20 21:53:48 +01:00
Craig Duncan
9439dd0b5b Add a test for iterating SXE properties by reference 2018-02-19 21:58:57 +01:00
Nikita Popov
ede663f381 Convert iterator by reference errors to exceptions
I'm using RuntimeException in SPL, because other SPL classes that
throw this error used it. Error is used for everything else, because
that's what core does.
2018-02-19 21:58:56 +01:00
Joe
47b90e910b
Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixes bug #75871 Use pkg-config for libxml2 if available
2018-02-08 10:51:47 +01:00
Joe
f9a16d492e
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixes bug #75871 Use pkg-config for libxml2 if available
2018-02-08 10:51:07 +01:00
Pedro Magalhães
5673c641dc
Fixes bug #75871 Use pkg-config for libxml2 if available 2018-02-08 10:50:22 +01:00
Gabriel Caruso
ce1d69a1f6 Use int instead of integer in type errors
PHP requires integer typehints to be written "int" and does not
allow "integer" as an alias. This changes type error messages to
match the actual type name and avoids confusing messages like
"must be of the type integer, integer given".
2018-02-04 19:08:23 +01:00
Gabriel Caruso
84488d921b Remove superfluous SKIPIF sections in more tests 2018-02-04 16:57:08 +01:00
Nikita Popov
c58b307833 Remove checks for unicode.semantics ini option 2018-02-03 19:50:20 +01:00
Gabriel Caruso
c6c9e71a5b Add missing SKIPIF sections 2018-02-03 13:54:34 +01:00
Dmitry Stogov
f7f790fcc9 Scalar types don't have reference counter 2018-01-17 16:17:43 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Nikita Popov
b2b2b437af Add _IS_NUMBER as cast_object() target type
convert_scalar_to_number() will now call cast_object() with an
_IS_NUMBER argument, in which case the cast handler should return
either an integer or floating point number, whichever is more
appropriate.

Previously convert_scalar_to_number() unconditionally converted
objects to integers instead.

Fixes bug #53033.
Fixes bug #54973.
Fixes bug #73108.
2017-12-26 12:39:06 +01:00
Nikita Popov
2667ddc46d Remove unnecessary readobj==writeobj checks
This can no longer be the case since PHP 7. The writeobj must
always point to a different zval.
2017-12-25 21:19:45 +01:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
Dmitry Stogov
1db8402208 Move zend_object_iterator_funcs structures into read-only data segment 2017-12-14 14:21:22 +03:00
Dmitry Stogov
6a9d2b2190 Cleanup type conversion 2017-12-07 19:24:55 +03:00
Nikita Popov
b72b1a4e4d Add zend_object_alloc() API
Using ecalloc() to create objects is expensive, because the
dynamic-size memset() is unreasonably slow. Make sure we only
zero the main object structure with known size, as the properties
are intialized separately anyway.

Technically we do not need to zero the embedded zend_object
structure either, but as long as the memset argument is constant,
a couple more bytes don't really matter.
2017-11-25 17:12:37 +01:00
Dmitry Stogov
ccc12b82da Avoid unnecessary reference-counting on strings. 2017-11-16 17:09:32 +03:00
Dmitry Stogov
9cf87aa196 Avoid HashTable allocations for empty arrays (using zend_empty_array). 2017-10-24 17:27:31 +03:00
Peter Kokot
5971180aa6 Remove PHP examples from simplexml 2017-10-05 12:35:19 +02:00
Dmitry Stogov
44e0b79ac6 Refactored array creation API. array_init() and array_init_size() are converted into macros calling zend_new_array(). They are not functions anymore and don't return any values. 2017-09-20 02:25:56 +03:00
Anatol Belski
8a9ff55397 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix test compat with libxml2 2.9.5
2017-09-11 16:16:09 +02:00
Anatol Belski
a77eddff96 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix test compat with libxml2 2.9.5
2017-09-11 16:15:32 +02:00
Anatol Belski
cab41ecb93 Fix test compat with libxml2 2.9.5
One warning disappeared, but the flow is still valid.
2017-09-11 16:12:04 +02:00
Dmitry Stogov
1cbe4e009c Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Skip 64-bit related test
2017-08-15 13:01:06 +03:00
Dmitry Stogov
0f3e01f5cc Skip 64-bit related test 2017-08-15 13:00:45 +03:00
Xinchen Hui
9b87b73fec Req #74963 (Improved error message on fetching property of non-object) 2017-07-31 11:51:23 +08:00
Xinchen Hui
01090e6ced Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Update NEWS
  Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces)
2017-07-21 18:17:33 +08:00
Xinchen Hui
08177312fb Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces)
2017-07-21 18:16:54 +08:00
Xinchen Hui
3a7b0027f3 Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces) 2017-07-21 18:16:11 +08:00
Dmitry Stogov
27e7aea412 "Countable" interface is moved from SPL to Core 2017-05-25 12:47:43 +03:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Sammy Kaye Powers
478f119ab9 Update copyright headers to 2017 2017-01-04 11:14:55 -06:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Pedro Magalhães
617dcf1b37 Remove the binary cast from unrelated tests 2016-11-20 21:11:53 +01:00
Pedro Magalhães
9c5af4e4cb Remove the b prefix from literals on unrelated tests 2016-11-20 21:11:53 +01:00
Christoph M. Becker
1ccada35c0 Fix tests: don't count non-countables 2016-11-13 18:16:17 +01:00
Anatol Belski
a5e9a73db2 fix typo
(cherry picked from commit efc1f33b58)
2016-10-14 01:43:54 +02:00
Stanislav Malyshev
e7e60851ae Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML()
(cherry picked from commit 96a8cf8e1b)
(cherry picked from commit 4ef79370a8)
2016-10-14 01:42:05 +02:00
Anatol Belski
929b04520e Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  fix typo
2016-10-12 17:13:23 +02:00
Anatol Belski
efc1f33b58 fix typo 2016-10-12 17:12:38 +02:00
Anatol Belski
d103a41679 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  followup with #73276 merge
  fix test
  Fix bug #73276 - crash in openssl_random_pseudo_bytes function
  Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML()
  Fix for #73240 - Write out of bounds at number_format
  avoid strlen
  Bug #73218: add mitigation for ICU int overflow
  Add more locale length checks, due to ICU bugs.
  Fix bug #73150: missing NULL check in dom_document_save_html
  Clear FG(user_stream_current_filename) when bailing out
  set versions and release date
  sync NEWS
  Revert "Fixed bug #73067 (__debugInfo crashes when throwing an exception)"
  Fix for #73240 - Write out of bounds at number_format
  Fix bug #73257 and bug #73258 - SplObjectStorage unserialize allows use of non-object as key
  set versions
  Fix bug #73091 - Unserializing DateInterval object may lead to __toString invocation
2016-10-12 16:06:11 +02:00
Stanislav Malyshev
4ef79370a8 Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML()
(cherry picked from commit 96a8cf8e1b)
2016-10-12 15:40:21 +02:00
Christoph M. Becker
04fb35172b Merge branch 'PHP-7.1' 2016-09-09 16:33:17 +02:00
Christoph M. Becker
7d80b64ac8 Merge branch 'PHP-7.0' into PHP-7.1 2016-09-09 16:32:27 +02:00
Christoph M. Becker
7a90fc96d8 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-09 16:30:26 +02:00
Christoph M. Becker
c42a7f2f3f Remove ignored --FAIL-- section from test case
This is just confusing.
2016-09-09 16:27:50 +02:00
Nikita Popov
bbe0cca221 Drop SXE_ELEMENT_BY_NAME
Effectively commented out code
2016-09-04 12:31:06 +02:00
Nikita Popov
d49024c6de Merge branch 'PHP-7.0' into PHP-7.1 2016-08-30 13:06:32 +02:00
Nikita Popov
bfd4277008 Fix bug #72957 2016-08-30 13:05:53 +02:00
Nikita Popov
6adb7e0b7a Followup for bug #72971
Property writes did not respect the namespace either. This is an
incomplete fix in that it only handles the case where an existing
child element is modified, not when a new one is created.
2016-08-30 12:53:50 +02:00
Nikita Popov
51a564e505 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-30 10:56:06 +02:00
Nikita Popov
07cc6a6ba2 Fix bug #72971 2016-08-30 10:54:31 +02:00
Nikita Popov
735bec4f40 Avoid uncollectable cycle in sxe_property_get_adr
The code was storing the created object in a property on the
created object, creating a trivial cycle. This cycle cannot be
collected (even if sxe->tmp is exposed via get_gc), because it
is never rooted (and we cannot safely manually root it).

Change the code to store the created object on the parent node
instead.

The only reason this is not showing up as a leak is that sxe->tmp
is dtor'ed in the dtor handler, which means that these objects
do get collected on shutdown -- but never earlier.
2016-07-16 23:43:24 +02:00
Nikita Popov
2c51a2d00b Remove unnecessary use of sxe->tmp 2016-07-16 23:16:51 +02:00
Xinchen Hui
f24ed8c2fe Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72588 (Using global var doesn't work while accessing SimpleXML element)
2016-07-13 10:50:15 +08:00
Xinchen Hui
8129b83992 Fixed bug #72588 (Using global var doesn't work while accessing SimpleXML element) 2016-07-13 10:49:58 +08:00
Aaron Piotrowski
24237027bc Merge branch 'throw-error-in-extensions' 2016-07-05 02:08:39 -05:00
Dmitry Stogov
323b2733f6 Fixed compilation warnings 2016-06-22 00:40:50 +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
Anatol Belski
3d3f11ede4 Fixed the UTF-8 and long path support in the streams on Windows.
Since long the default PHP charset is UTF-8, however the Windows part is
out of step with this important point. The current implementation in PHP
doesn't technically permit to handle UTF-8 filepath and several other
things. Till now, only the ANSI compatible APIs are being used. Here is more
about it

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317752%28v=vs.85%29.aspx

The patch fixes not only issues with multibyte filenames under
incompatible codepages, but indirectly also issues with some other multibyte
encodings like BIG5, Shift-JIS, etc. by providing a clean way to access
filenames in UTF-8. Below is a small list of issues from the bug tracker,
that are getting fixed:

https://bugs.php.net/63401
https://bugs.php.net/41199
https://bugs.php.net/50203
https://bugs.php.net/71509
https://bugs.php.net/64699
https://bugs.php.net/64506
https://bugs.php.net/30195
https://bugs.php.net/65358
https://bugs.php.net/61315
https://bugs.php.net/70943
https://bugs.php.net/70903
https://bugs.php.net/63593
https://bugs.php.net/54977
https://bugs.php.net/54028
https://bugs.php.net/43148
https://bugs.php.net/30730
https://bugs.php.net/33350
https://bugs.php.net/35300
https://bugs.php.net/46990
https://bugs.php.net/61309
https://bugs.php.net/69333
https://bugs.php.net/45517
https://bugs.php.net/70551
https://bugs.php.net/50197
https://bugs.php.net/72200
https://bugs.php.net/37672

Yet more related tickets can for sure be found - on bugs.php.net, Stackoverflow
and Github. Some of the bugs are pretty recent, some descend to early
2000th, but  the user comments in there last even till today. Just for example,
bug #30195 was opened in 2004, the latest comment in there was made in 2014. It
is certain, that these bugs descend not only to pure PHP use cases, but get also
redirected from the popular PHP based projects. Given the modern systems (and
those supported by PHP) are always based on NTFS, there is no excuse to keep
these issues unresolved.

The internalization approach on Windows is in many ways different from
UNIX and Linux, while it supports and is based on Unicode. It depends on the
current system code page, APIs used and exact kind how the binary was compiled
The locale doesn't affect the way Unicode or ANSI API work. PHP in particular
is being compiled without _UNICODE defined and this is conditioned by the
way we handle strings. Here is more about it

https://msdn.microsoft.com/en-us/library/tsbaswba.aspx

However, with any system code page ANSI functions automatically convert
paths to UTF-16. Paths in some encodings incompatible with the
current system code page, won't work correctly with ANSI APIs. PHP
till now only uses the ANSI Windows APIs.

For example, on a system with the current code page 1252, the paths
in cp1252 are supported and transparently converted to UTF-16 by the
ANSI functions. Once one wants to handle a filepath encoded with cp932 on
that particular system, an ANSI or a POSIX compatible function used in
PHP will produce an erroneous result. When trying to convert that cp932 path
to UTF-8 and passing to the ANSI functions, an ANSI function would
likely interpret the UTF-8 string as some string in the current code page and
create a filepath that represents every single byte of the UTF-8 string.
These behaviors are not only broken but also disregard the documented
INI settings.

This patch solves the issies with the multibyte paths on Windows by
intelligently enforcing the usage of the Unicode aware APIs. For
functions expect Unicode (fe CreateFileW, FindFirstFileW, etc.), arguments
will be converted to UTF-16 wide chars. For functions returning Unicode
aware data (fe GetCurrentDirectoryW, etc.), resulting wide string is
converted back to char's depending on the current PHP charset settings,
either to the current ANSI codepage (this is the behavior prior to this patch)
or to UTF-8 (the default behavior).

In a particular case, users might have to explicitly set
internal_encoding or default_charset, if filenames in ANSI codepage are
necessary. Current tests show no regressions and witness that this will be an
exotic case, the current default UTF-8 encoding is compatible with any
supported system. The dependency libraries are long switching to Unicode APIs,
so some tests were also added for extensions not directly related to streams.
At large, the patch brings over 150 related tests into the core. Those target
and was run on various environments with European, Asian, etc. codepages.
General PHP frameworks was tested and showed no regressions.

The impact on the current C code base is low, the most places affected
are the Windows only places in the three files tsrm_win32.c, zend_virtual_cwd.c
and plain_wrapper.c. The actual implementation of the most of the wide
char supporting functionality is in win32/ioutil.* and win32/codepage.*,
several  low level functionsare extended in place to avoid reimplementation for
now. No performance impact was sighted. As previously mentioned, the ANSI APIs
used prior the patch perform Unicode conversions internally. Using the
Unicode  APIs directly while doing custom conversions just retains the status
quo. The ways to optimize it are open (fe. by implementing caching for the
strings converted to wide variants).

The long path implementation is user transparent. If a path exceeds the
length of _MAX_PATH, it'll be automatically prefixed with \\?\. The MAXPATHLEN
is set to 2048 bytes.

Appreciation to Pierre Joye, Matt Ficken, @algo13 and others for tips, ideas
and testing.

Thanks.
2016-06-20 12:45:39 +02:00
Aaron Piotrowski
771e5cc247 Replace zend_ce_error with NULL and replace more E_ERROR with thrown Error 2016-06-13 09:02:17 -05:00
Aaron Piotrowski
e3c681aa5c Merge branch 'master' into throw-error-in-extensions 2016-06-10 22:02:23 -05:00
Anatol Belski
58c82ff0b0 Merge branch 'PHP-7.0'
* PHP-7.0:
  fix regression introduced in 5683b6fa39
2016-03-08 13:16:46 +01:00
Anatol Belski
7a4c2fa829 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  fix regression introduced in 5683b6fa39
2016-03-08 13:16:08 +01:00
Anatol Belski
8ca02bb233 fix regression introduced in 5683b6fa39
Test extended. Basically, both iterator type and next node have
to be checked.
2016-03-08 12:59:59 +01:00
Nikita Popov
2eb4728611 Remove HAVE_SPL checks
SPL is always built.

Also clean up spl_ce_RuntimeException handling in PDO.
2016-01-30 14:53:00 +01:00
Lior Kaplan
ed35de784f Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Happy new year (Update copyright to 2016)
2016-01-01 19:48:25 +02:00
Lior Kaplan
49493a2dcf Happy new year (Update copyright to 2016) 2016-01-01 19:21:47 +02:00
Anatol Belski
a3dceb485a fix test 2015-08-26 16:39:48 +02:00
Anatol Belski
2c523f21c9 add range checks to simplexml 2015-08-26 16:39:47 +02:00
Christoph M. Becker
8d31e463a0 fixed test 2015-08-01 23:52:35 +02:00
Nikita Popov
36e49c702b Fix simplexml warnings 2015-07-17 21:12:15 +02:00
Aaron Piotrowski
7ec1e17464 Update memory freeing and other issues, revert some changes 2015-07-05 23:25:53 -05:00
Aaron Piotrowski
907476f34c Convert E_ERROR to thrown Error in extensions 2015-07-05 12:16:57 -05:00
Aaron Piotrowski
ed1b64877d Switch position of ce in exception ce variable names 2015-07-03 09:45:03 -05:00
Aaron Piotrowski
a812a74c2e Change zend_exception_get_default() to zend_exception_ce 2015-07-03 09:44:48 -05:00
Dmitry Stogov
6daed13c8b Cleanup (removed dead code) 2015-07-01 22:18:40 +03:00
Dmitry Stogov
4bd22cf1c1 Improved zend_string API (Francois Laupretre)
Squashed commit of the following:

commit d96eab8d79
Author: Francois Laupretre <francois@tekwire.net>
Date:   Fri Jun 26 01:23:31 2015 +0200

    Use the new 'ZSTR' macros in the rest of the code.

    Does not change anything to the generated code (thanks to compat macros) but cleaner.

commit b352643910
Author: Francois Laupretre <francois@tekwire.net>
Date:   Thu Jun 25 13:45:06 2015 +0200

    Improve zend_string API

    Add missing methods
2015-06-29 16:44:54 +03:00
Rasmus Lerdorf
28d7bb97a1 Fix more proto comments 2015-06-23 17:46:20 -04:00
Aaron Piotrowski
77cf6d81b4 Fix some missed tests 2015-06-15 08:20:30 -05: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
1c754f0b71 Get rid of more ZVAL_ZVAL() macros 2015-06-12 13:33:14 +03: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
Christoph M. Becker
c1401ad7b6 split simplexml tests for 7 2015-05-31 21:35:21 +02:00
Anatol Belski
6f1c006b6d Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  split the original test to check behaviour diff on 32- and 64-bit
  recovered original meaning of SXE xpath test
2015-05-31 21:30:46 +02:00
Christoph M. Becker
b24fedbd24 split the original test to check behaviour diff on 32- and 64-bit 2015-05-31 21:28:44 +02:00
Christoph M. Becker
e44b040faf recovered original meaning of SXE xpath test 2015-05-31 21:27:02 +02:00
Anatol Belski
8e02be16d7 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Refactored the fix for bug #66084, by cmb@php.net
  Merge the fix for #69703 to 5.5 per request from Julien
2015-05-29 21:18:04 +02:00
Anatol Belski
5683b6fa39 Refactored the fix for bug #66084, by cmb@php.net 2015-05-29 21:16:56 +02:00
Christoph M. Becker
36eb66692c removed test for unrelated bug #68946 2015-05-29 20:43:40 +02:00
Christoph M. Becker
f27b9ead6b fixed whitespace dependend behavior of casting SimpleXMLElements to boolean 2015-05-29 20:43:38 +02:00
Christoph M. Becker
8e5b906459 added tests for bug #61335, bug #67572 and bug #68946 (the latter already passing, but better safe than sorry) 2015-05-29 20:43:36 +02:00
Christoph M. Becker
db4a6def47 fixed whitespace depending (mis)behavior of var_dump'ing and print_r'ing SimpleXMLElements 2015-05-29 20:43:34 +02:00
Christoph M. Becker
1a3a674ee6 added failing tests for bug #62639, bug #67116, bug #69169 and bug #69491 2015-05-29 20:43:33 +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
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
Anatol Belski
becfdeb2ff improve searchability for libxml2 headers
and bring the configs inline with the current libxml2 build
2015-05-10 22:22:03 +02:00
Xinchen Hui
55d94a4532 Merge branch 'master' of git.php.net:php-src 2015-05-06 10:51:52 +08:00
Dmitry Stogov
f6663c7201 Loop splitting and specialization 2015-05-05 18:51:08 +03:00
Dmitry Stogov
81dd375b5f Fixed compilation warning 2015-05-05 16:28:54 +03:00
Dmitry Stogov
275afbacd1 Use zend heap instead of system 2015-05-05 16:06:10 +03:00
Dmitry Stogov
a610e8c4c6 Use better zend_hash_*() functions. 2015-05-05 12:58:11 +03:00
Dmitry Stogov
17e4c62872 Removed check for count() in SXE class 2015-05-05 12:57:30 +03:00
Xinchen Hui
5f8bc73fc3 fixed comment 2015-05-05 17:37:42 +08:00
Xinchen Hui
7b9e4e19e1 Unused macros 2015-05-05 17:25:25 +08:00
Xinchen Hui
8c0ebb4c5d Optimize cast simplexml to IS_BOOL 2015-05-05 17:23:54 +08:00
Xinchen Hui
b6e893c143 Unused var 2015-05-05 17:02:54 +08:00
Dmitry Stogov
859aa06205 Avoid repeatable lookups for count() method in the same class entry. 2015-05-05 11:10:21 +03: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
Anatol Belski
663074b6b1 cleanup mod version macros and mod defs, round x 2015-03-23 21:30:22 +01:00