Compare commits

...
419 Commits
Author SHA1 Message Date
Gabriel Caruso 8b1ed68034 Update versions for PHP 8.0.5 2021-04-27 12:20:50 +00:00
Gabriel Caruso 57101a3dd7 Prepare NEWS for PHP 8.0.5 stable 2021-04-27 14:14:56 +02:00
Christoph M. Becker 0c2649011d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing NEWS entry for #80710
2021-04-27 14:14:17 +02:00
Stanislav Malyshev c526fa2d7b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80710: imap_mail_compose() header injection
2021-04-27 14:11:55 +02:00
Gabriel Caruso 4488c43757 Update NEWS for PHP 8.0.5RC1 2021-04-13 11:01:36 +00:00
Gabriel Caruso 1250c4ee43 Prepare NEWS for 8.0.5RC1
We'll skip PHP 8.0.4...
2021-04-13 12:55:28 +02:00
Derick Rethans 3c06794e93 Merge branch 'PHP-7.4' into PHP-8.0 2021-04-13 11:34:55 +01:00
Derick Rethans 8e48895f48 Prepare for 7.4.19 2021-04-13 11:34:40 +01:00
Noriko Yamamoto 2ebd1c4e86 change PHP_EGG_LOGO_DATA_URI to php8 elePHPant called InPHPinity
Closes GH-6827.
2021-04-13 11:49:42 +02:00
Derick Rethans fac39fa36d Merge branch 'PHP-7.4' into PHP-8.0 2021-04-13 10:00:54 +01:00
Derick Rethans d4f7e8cedc Prepare NEWS for 7.4.18RC1 2021-04-13 10:00:45 +01:00
Nikita Popov 1395b874f4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80950
2021-04-12 16:06:50 +02:00
Nikita Popov a1fdfa700b Fixed bug #80950
Function info for curl_exec() incorrect specified that the
function cannot return true. This is already fixed in PHP 8,
as the func info entry was removed there.
2021-04-12 16:05:37 +02:00
Nikita Popov 8effbd1cb0 PDO: Respect connection transaction state for dtor rollback
As mentioned in bug #80949, if a transaction is implicitly
committed, then PDO may still issue a ROLLBACK when the PDO
object is destroyed, as the transaction is still marked as active
in PDO's (inaccurate) transaction emulation.

Make sure we use the connection transaction state also for that
final ROLLBACK. A caveat here is that the connection might have
been dropped already, which may be the case for some drivers if
construction fails. Make sure we don't crash in that case.
2021-04-12 12:39:44 +02:00
Christoph M. Becker d74c61c133 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79812: Potential integer overflow in pcntl_exec()
2021-04-12 12:15:07 +02:00
Christoph M. Becker 0a36d417e8 Fix #79812: Potential integer overflow in pcntl_exec()
We use the proper type, and make sure that no overflow can occur by
using `safe_emalloc()` (we can assume that neither string length is
`SIZE_MAX`).

Closes GH-6845.
2021-04-12 12:12:40 +02:00
Nikita Popov 6700198d64 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Disable ifunc support on openbsd
2021-04-12 11:28:24 +02:00
David Carlier a04fac84e7 Disable ifunc support on openbsd
Enabling it leads to segfault when resolvers are used e.g.
php_stripslashes.

Closes GH-6851.
2021-04-12 11:27:50 +02:00
Rowan Tommins 4e98e65d53 Remove the "getdir" function which was introduced accidentally
The actual name of this function is dir(), but ever since it was
introduced in PHP 3, its internal name was "getdir", leading to it
being mistaken for an alias. This went unnoticed until the switch
to stubs for generating arginfo, at which point getdir() became a
real but undocumented function.

Fixes bug #80914.

Closes GH-6855.
2021-04-12 11:13:57 +02:00
Dmitry Stogov 9c6b926dae Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update zend_alloc.c
2021-04-12 09:28:41 +03:00
fishmore 600402d986 Update zend_alloc.c
Don't free main thunk.  It will crash.
2021-04-12 09:28:24 +03:00
Matteo Beccati 4f236635e7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
2021-04-12 08:05:41 +02:00
Matteo Beccati 340a06778c Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR 2021-04-12 08:03:07 +02:00
Matteo Beccati 7f4784c1c9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Increased test compatibility
2021-04-11 17:32:13 +02:00
Matteo Beccati da3a807f22 Increased test compatibility
The test expects no masked signals at the beginning, but when run as part
of a Bamboo build, SIGQUIT is already masked and the test fails.
2021-04-11 17:19:58 +02:00
Nikita Popov 26d417d758 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix gidlist allocation leak on error
2021-04-11 10:38:07 +02:00
Nikita Popov 454d297564 Fix gidlist allocation leak on error 2021-04-11 10:37:40 +02:00
Dmitry Stogov 61e385a358 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed type inference for OP_DATA
2021-04-09 14:53:34 +03:00
Dmitry Stogov 7a8ffcec7d Fixed type inference for OP_DATA 2021-04-09 14:52:55 +03:00
Nikita Popov 332a367538 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Don't mark non-refcounted phi as live
2021-04-08 18:21:00 +02:00
Nikita Popov 29fa4d203a Don't mark non-refcounted phi as live
If the value is not refcounted, then it doesn't matter if the
FREE gets dropped.
2021-04-08 18:20:09 +02:00
Nikita Popov 59b2a899ca Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix DCE of FREE of COALESCE
2021-04-08 17:01:19 +02:00
Nikita Popov 0826a54836 Fix DCE of FREE of COALESCE
When encountering the following SSA graph:

    BB1:
    #2.T1 [string] = COALESCE #1.CV0($str) [null, string] BB2

    BB2:
    #5.T1 [string] = QM_ASSIGN string("")

    BB3:
    #7.X1 [string] = Phi(#2.X1 [string], #5.X1 [string])
    FREE #7.T1 [string]

We would currently determine that #7, #5 are dead, and eliminate
the FREE and QM_ASSIGN. However, we cannot eliminate #2, as
COALESCE is also responsible for control flow.

Fix this my marking all non-CV phis as live to start with. This
can be relaxed to check the kind of the source instruction, but
I couldn't immediately come up with a case where it would be
useful.
2021-04-08 17:01:13 +02:00
Remi Collet f421ebc056 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Improve fix for #80783
2021-04-08 15:28:29 +02:00
Remi Collet 25f5a1b2e1 Improve fix for #80783 2021-04-08 15:28:03 +02:00
Nikita Popov 032905b5a0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Support more than NGROUPS_MAX groups on macos
2021-04-08 12:25:16 +02:00
Nikita Popov eebcfeb68e Support more than NGROUPS_MAX groups on macos
I suspect this is the cause for our recent CI failures. Apparently,
on macos it is possible for getgroups() to return more than
NGROUPS_MAX groups. We avoid an EINVAL in that case by fetching
the exact number of groups in advance. This should work on both
macos and posix systems.
2021-04-08 12:23:39 +02:00
Christoph M. Becker ba6714a200 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update version in main/php_version.h as well
2021-04-07 12:52:44 +02:00
Christoph M. Becker 0a181ca27a Update version in main/php_version.h as well
Otherwise the file is modified by each new build, what is confusing.
2021-04-07 12:45:21 +02:00
Christoph M. Becker de9734a5bb Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80880: SSL_read on shutdown, ftp/proc_open
2021-04-06 14:07:25 +02:00
Christoph M. Becker 9688071679 Fix #80880: SSL_read on shutdown, ftp/proc_open
When `SSL_read()` after `SSL_shutdown()` fails with `SSL_ERROR_SYSCALL`,
we should not warn about this, because it is likely caused by the peer
having closed the connection without having sent a close_notify
shutdown alert.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-6803.
2021-04-06 14:03:19 +02:00
Nikita Popov 304190c49d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  .gdbinit: make zbacktrace show the correct stack when switching threads
2021-04-05 21:11:19 +02:00
Dylan K. Taylor 50f476591f .gdbinit: make zbacktrace show the correct stack when switching threads
I found this mainly to be a problem when working with threading
extensions. zbacktrace doesn't show the correct stack when switching
threads.

Closes GH-6814.
2021-04-05 21:10:52 +02:00
Dmitry Stogov e0996decc3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
2021-03-31 13:11:11 +03:00
Dmitry Stogov 39d8fc1edc Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
Old registers (r28/r29) might be clobbered by _restgpr routine used for return from C function compiled with -Os.
2021-03-31 13:10:21 +03:00
Christoph M. Becker 443478109b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle reference zvals when outputting superglobals in phpinfo()

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:52:38 +02:00
Rowan Tommins 206fd35a98 Handle reference zvals when outputting superglobals in phpinfo()
Fixes <https://bugs.php.net/80915>.

Closes GH-80915.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:49:22 +02:00
Nikita Popov b95b553489 Remove zero size special case for copy_to_stream
This doesn't seem to serve a purpose anymore. Stats are expensive,
so doing an unnecessary stat just to short-circuit the zero size
case is rather dubious. It can also break with stream wrappers
that return inaccurate sizes (symfony/symfony#40574) and probably
can also break with stream filters.

Drop the special case and adjust code to make it more obvious that
it will still be handled correctly.

Closes GH-6807.
2021-03-29 15:21:59 +02:00
Christoph M. Becker dd227f61df Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #69668: SOAP special XML characters in namespace URIs not encoded

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-29 14:19:39 +02:00
Christoph M. Becker 75cb678206 Fix #69668: SOAP special XML characters in namespace URIs not encoded
`xmlNewNs()` does not XML encode the passed `href`, so we need to do
that manually.

Closes GH-6804.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-29 14:17:55 +02:00
Máté Kocsis d7ae64627f Fix PDOStatement::bindColumn() parameter default value 2021-03-25 19:31:04 +01:00
Dmitry Stogov 6800f0a3c2 XFAIL on WIN64 because of problem in libffi
(cherry picked from commit 6689bedd17)
2021-03-24 13:57:31 +01:00
Christoph M. Becker 5832be768c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
2021-03-24 11:52:54 +01:00
Christoph M. Becker 498eb8e052 Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
A string passed to `php_libxml_xmlCheckUTF8()` may be longer than
1<<31-1 bytes, so we're better using a `size_t`.

Closes GH-6802.
2021-03-24 11:50:50 +01:00
Christoph M. Becker 733b514326 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Properly initialize PS(mod) on RINIT
2021-03-23 13:13:43 +01:00
Christoph M. Becker 688e56d0ac Properly initialize PS(mod) on RINIT
We need to do that in case a user handler has been set.  However, we
can't do that in `php_rinit_session_globals()` since that function is
called by PHP function `session_destroy()` too, but in that case we
don't want to reset PS(mod).

Closes GH-6795.
2021-03-23 13:12:19 +01:00
Christoph M. Becker 90be86fc91 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80889: amendment
2021-03-22 22:49:46 +01:00
Christoph M. Becker 838951c2d6 Fix #80889: amendment
`session_set_save_handler()` may be called with callables instead of an
object; we need to cater to that as well.

We also extract a set_user_save_handler_ini() function to avoid code
duplication.

Closes GH-6796.
2021-03-22 22:17:35 +01:00
Jakub Zelenka 4dca1140cf Merge branch 'PHP-7.4' into PHP-8.0 2021-03-21 21:21:05 +00:00
Jakub Zelenka bc7ea73da5 Use ServerClientTestCase in a test for default_socket_timeout=-1 2021-03-21 21:19:40 +00:00
Jakub Zelenka 713b82131b Merge branch 'PHP-7.4' into PHP-8.0 2021-03-21 19:00:38 +00:00
Jakub Zelenka 538f95b1b7 Fix NEWS entry position for the latest FPM fix 2021-03-21 18:58:57 +00:00
Jakub Zelenka c483b59124 Fix bug #80024: Duplication of info about inherited socket after pool removing 2021-03-21 18:52:07 +00:00
Christoph M. Becker 2a1ed81ffc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80889: Cannot set save handler when save_handler is invalid
2021-03-19 17:03:54 +01:00
Christoph M. Becker 06bfada99b Fix #80889: Cannot set save handler when save_handler is invalid
There is no need to require a (valid) save_handler to be set, when a
user handler is supposed to be set.  We just have to make sure, that
no user handler is already set in this case.

Closes GH-6788.
2021-03-19 16:59:54 +01:00
Christoph M. Becker 97cfdcd73b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80783: PDO ODBC truncates BLOB records at every 256th byte
2021-03-18 15:18:53 +01:00
Christoph M. Becker bccca0b53a Fix #80783: PDO ODBC truncates BLOB records at every 256th byte
It is not guaranteed, that the driver inserts only a single NUL byte at
the end of the buffer.  Apparently, there is no way to find out the
actual data length in the buffer after calling `SQLGetData()`, so we
adjust after the next `SQLGetData()` call.

We also prevent PDO::ODBC_ATTR_ASSUME_UTF8 from fetching garbage, by
fetching all chunks with the same C type.

Closes GH-6716.
2021-03-18 15:13:27 +01:00
Dmitry Stogov 465cfc499b Additional fix for bug #80847.
On x86_64 part of structure may be passed in CPU registers.
2021-03-18 16:13:42 +03:00
Nikita Popov 4dce2f83f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix locale switch back to C in pcre
2021-03-18 10:50:57 +01:00
Nikita Popov 4be867e910 Fix locale switch back to C in pcre
The compile context is shared between patterns, so we need to set
the character tables unconditionally in case we switched from
a non-C locale to the C locale.
2021-03-18 10:48:43 +01:00
Dmitry Stogov 7e494d9225 Fixed bug #80861 (erronous array key overflow in 2D array with JIT) 2021-03-17 22:59:59 +03:00
Nikita Popov 34e39ebaf5 Fix signed/unsigned warnings in PDO ODBC
Add add skipif to test.

(cherry picked from commit aa58db7232)
2021-03-17 16:33:32 +01:00
Nikita Popov d80118dc16 imagecolortransparent() cannot return null 2021-03-17 15:09:06 +01:00
Nikita Popov c17434429d Return bool from imageinterlace()
The function accepts a bool since PHP 8.0, so it should also return
a bool to keep things consistent.

Furthermore a null return from this functions is not possible.
2021-03-17 15:05:09 +01:00
Dmitry Stogov faf1567212 Fixed bug #80839 (PHP problem with JIT) 2021-03-17 16:55:09 +03:00
Christoph M. Becker fddd0ac552 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #66783: UAF when appending DOMDocument to element
2021-03-17 12:40:03 +01:00
Christoph M. Becker a08847ab39 Fix #66783: UAF when appending DOMDocument to element
According to the DOM standard, elements may only contain element, text,
processing instruction and comment nodes[1].  It is also specified that
a HierarchyRequestError should be thrown if a document is to be
inserted[2].  We follow that standard, and prevent the use-after-free
this way.

[1] <https://dom.spec.whatwg.org/#node-trees>
[2] <https://dom.spec.whatwg.org/#mutation-algorithms>

Closes GH-6765.
2021-03-17 12:37:18 +01:00
Christoph M. Becker c7fadd2328 8.0.5 is next
We also move the NEWS entry for bug 80847 to the proper version.
2021-03-17 12:14:26 +01:00
Dmitry Stogov 38ebb55c7c Fixed bug #80847 (CData structs with fields of type struct can't be passed as C function argument) 2021-03-17 09:55:20 +03:00
Nikita Popov 82622d7583 Fix refcount inference for typed properties
We were not adding RC1/RCN if the MAY_BE_OBJECT came from a class
type and there was no other refcounted type in the union.
2021-03-16 11:17:18 +01:00
Derick Rethans c2ff964de0 Merge branch 'PHP-7.4' into PHP-8.0 2021-03-16 09:41:40 +00:00
Derick Rethans 4adc08a403 Fix build version too 2021-03-16 09:41:21 +00:00
Derick Rethans 7dbe27222c Merge branch 'PHP-7.4' into PHP-8.0 2021-03-16 09:40:21 +00:00
Derick Rethans 5e4ee3d0bd NEWS for 7.4.18 2021-03-16 09:40:05 +00:00
Derick Rethans eb1d1fe373 Prepare for 7.4.17RC1 2021-03-16 09:33:33 +00:00
Máté Kocsis 465aa1d38f Fix ldap_next_entry() parameter name 2021-03-16 09:31:46 +01:00
Máté Kocsis b03438ba3a Fix crash in LDAP search functions during argument validation 2021-03-16 09:31:37 +01:00
Máté Kocsis 5ecc078a17 Add missing skipif sections to ext/dom tests 2021-03-15 23:45:37 +01:00
Christoph M. Becker eae69fcf71 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80817: dba_popen() may cause segfault during RSHUTDOWN
2021-03-15 18:39:26 +01:00
Christoph M. Becker f448b0e6dd Fix #80817: dba_popen() may cause segfault during RSHUTDOWN
We need to close persistent streams with the proper flag.
2021-03-15 18:37:44 +01:00
Nikita Popov 50254de0a2 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80866
2021-03-15 14:48:02 +01:00
Dharman 282355efd5 Fix bug #80866
Closes GH-6774.
2021-03-15 14:47:45 +01:00
Nikita Popov 6493b516f9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80837
2021-03-15 14:38:49 +01:00
Dharman c93b461ad7 Fix bug #80837
The error needs to be reported on the statement, not the connection.
2021-03-15 14:38:09 +01:00
Nikita Popov 3306baca50 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update ubuntu on i386 job
  Downgrade security level in tests using TLS < 1.2
2021-03-15 14:12:42 +01:00
Nikita Popov fc4cd598a2 Update ubuntu on i386 job
There is a failure with apt on PHP-7.4 that's not present on
PHP-8.0/master. Switching to a newer ubuntu version on PHP-7.4
avoids the issue.
2021-03-15 14:11:19 +01:00
Nikita Popov 703bbf5210 Downgrade security level in tests using TLS < 1.2
A few additional tests have been added on master that require
lower security level.

(cherry picked from commit c2a6395dcb)
2021-03-15 14:11:12 +01:00
Michael Heimpold eaf9421df6 ext/opcache: fix configure output while checking mmap MAP_ANON support
It seems that f3efb9e3fb introduced a "typo" which may result
in the following confusing message:

checking for mmap() using MAP_ANON shared memory support... no=yes

Let's fix this.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>

Closes GH-6758.
2021-03-15 10:52:57 +01:00
Dmitry Stogov 3b377b51a2 Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage) 2021-03-10 16:03:47 +03:00
Christoph M. Becker 7931956805 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #51903: simplexml_load_file() doesn't use HTTP headers
2021-03-08 15:15:59 +01:00
Christoph M. BeckerandMichael Wallner f901bec494 Fix #51903: simplexml_load_file() doesn't use HTTP headers
The `encoding` attribute of the XML declaration is optional; it is good
practice to use external encoding information where available if it is
missing.  Thus, we check for `charset` info of `Content-Type` headers,
and see whether the encoding is supported.

We cater to trailing parameters and quoted-strings, but not to escaped
backslashes and quotes in quoted-strings, since no known character
encoding contains these anyway.

Co-authored-by: Michael Wallner <mike@php.net>

Closes GH-6747.
2021-03-08 15:07:01 +01:00
Christoph M. Becker 3880b8785b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2021-03-08 14:51:45 +01:00
manuel 5787f91c55 Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
Don't wait for further responses after a HTTP 101 (Switching Protocols) response

Closes GH-6730.
2021-03-08 14:36:31 +01:00
Máté Kocsis 0f8312342f Fix the error message of attribute flag validation 2021-03-06 00:56:25 +01:00
George Wang 8462a3de1a Merge branch 'PHP-7.4' into PHP-8.0 2021-03-05 11:00:53 -05:00
George Wang 8fc0bdfb0a Merge branch 'PHP-7.4' of git.php.net:php-src into PHP-7.4 2021-03-05 10:57:46 -05:00
George Wang 797edd6211 LiteSpeed SAPI v7.9: Process manager keeps forked child process alive for longer time based on load. Reduces PM overhead for busy setup. 2021-03-05 10:46:12 -05:00
David Carlier ae23852e41 Add supports for FreeBSD's PROT_MAX to let mprotect knows X flag can be applied in addition.
Closes GH-6738.
2021-03-05 16:44:08 +01:00
Christoph M. Becker 1c16749eaa Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Print error code if CreateMutex() fails
2021-03-05 15:08:24 +01:00
Christoph M. Becker e0e167e581 Print error code if CreateMutex() fails
This issue came up recently in a bug report[1]; without the error code,
users can barely guess why the function failed.

[1] <https://bugs.php.net/80812>

Closes GH-6745.
2021-03-05 15:06:18 +01:00
Dmitry Stogov 187ba4353a Fix ASAN warning (Zend/zend_string.h:165:2: runtime error: null pointer passed as argument 2 of memcpy(), which is declared to never be null) 2021-03-04 17:27:26 +03:00
Christoph M. Becker 4f478af16d Fix #80825: ZipArchive::isCompressionMethodSupported does not exist
`HAVE_METHOD_SUPPORTED` should have been defined after we updated to
libzip 1.7.1 months ago.
2021-03-03 22:56:42 +01:00
Christoph M. Becker 303a4ae44a Fix test wrt. server.inc changes 2021-03-03 12:04:06 +01:00
Christoph M. Becker 90b24401d6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78719: http wrapper silently ignores long Location headers
2021-03-03 10:47:51 +01:00
Christoph M. Becker 51e2015af3 Fix #78719: http wrapper silently ignores long Location headers
When opening HTTP streams, and reading the headers, we currently
discard header lines longer than `HTTP_HEADER_BLOCK_SIZE` (1024 bytes).
While this is not generally forbidden by RFC 7230, section 3.2.5, it
is not generally allowed either, since that may change the "message
framing or response semantics".

We thus fix this by allowing arbitrarily long header lines.

Closes GH-6720.
2021-03-03 10:45:25 +01:00
Dmitry Stogov 957cb13a49 Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT) 2021-03-01 23:57:20 +03:00
Christoph M. Becker 37c9728615 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80751: Comma in recipient name breaks email delivery
2021-03-01 18:50:11 +01:00
Christoph M. BeckerandNikita Popov 71297a254b Fix #80751: Comma in recipient name breaks email delivery
So far, `SendText()` simply separates potential email address lists at
any comma, disregarding that commas inside a quoted-string do not
delimit addresses.  We fix that by introducing an own variant of
`strtok_r()` which caters to quoted-strings.

We also make `FormatEmailAddress()` aware of quoted strings.

We do not cater to email address comments, and potentially other quirks
of RFC 5322 email addresses, but catering to quoted-strings is supposed
to solve almost all practical use cases.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6735.
2021-03-01 18:46:21 +01:00
Nikita Popov 75a4f484f0 Fixed bug #80811
When filling in defaults for skipped params, make sure that
reference parameters get the expected reference wrapper.
2021-03-01 16:30:01 +01:00
Nikita Popov 5875bf754e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:29 +01:00
Nikita Popov 2c508c4d40 Always remove HT iterators, even for uninit HT
Fixes oss-fuzz #31423.
2021-03-01 16:22:11 +01:00
Nikita Popov 2c182a77f7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80805
2021-03-01 15:13:25 +01:00
Nikita Popov e857936518 Fixed bug #80805
Handle missing result_var in binary_op_result_type.

(cherry picked from commit 8446e28275)
2021-03-01 15:13:15 +01:00
George Peter Banyard 1ee6aad248 Fix Bug #80800 imap_open() fails when the flags parameter includes CL_EXPUNGE
This also affected imap_reopen().
Add a supplementary test that the CL_EXPUNGE flag does have
the intended effect.

Closes GH-6732
2021-02-27 13:12:22 +00:00
Felipe Pena 8813f2e0c3 Merge branch 'PHP-7.4' into PHP-8.0 2021-02-25 20:54:24 +00:00
Felipe Pena 988c3f9659 Fix memleak on ReflectionFunction and ReflectionGenerator classes when calling __construct after instantiation 2021-02-25 20:53:14 +00:00
Remi Collet 18071aaa08 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  skip test with openssl < 1.1.0
2021-02-25 13:54:19 +01:00
Remi Collet ae0585c98e skip test with openssl < 1.1.0
The test fails, but without any crash
(this test is designed to catch a crash)
2021-02-25 13:52:35 +01:00
Christoph M. Becker fb683030bf Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Capture Microsoft-defined HRESULT exit codes exit codes
2021-02-25 12:03:43 +01:00
Dylan K. Taylor a480bf8093 Capture Microsoft-defined HRESULT exit codes exit codes
The lack of such a check leads to false-passes of tests on Windows
which expect no output, but produce a segfault or similar issue. I
discovered this a while ago due to bad tests in an extension I maintain.

Closes GH-6722.
2021-02-25 12:01:04 +01:00
David CARLIER ddea5c0816 crc32 module, clang spurious warning removal.
Closes GH-6725.
2021-02-25 10:17:21 +01:00
Nikita Popov f06efce387 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  mysqlnd pam fix test error message
2021-02-25 09:52:07 +01:00
Daniel Black 8309c04464 mysqlnd pam fix test error message
Closes GH-6727.
2021-02-25 09:51:51 +01:00
Nikita Popov 44ef32ff2c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix potential file collision in dom tests
2021-02-24 21:30:44 +01:00
Nikita Popov 766f827e26 Fix potential file collision in dom tests 2021-02-24 21:30:20 +01:00
Felipe Pena aaea81de7c Merge branch 'PHP-7.4' into PHP-8.0 2021-02-24 19:07:22 +00:00
Felipe Pena 3ec37a74a2 Fix bug #80757 (Exit code is 0 when could not open file) 2021-02-24 18:50:27 +00:00
Felipe Pena 78b0a85de6 Update NEWS 2021-02-24 18:40:32 +00:00
Dmitry Stogov b7fa5268e4 Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1) 2021-02-24 12:20:20 +03:00
Christoph M. Becker 8162c3d1fd Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  run-tests: fixed exit code not being set on BORKED tests
2021-02-23 13:22:50 +01:00
Christoph M. Becker 67bb06cc9b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  run-tests: fixed exit code not being set on BORKED tests
2021-02-23 13:15:30 +01:00
Dylan K. Taylor 729cd8bacd run-tests: fixed exit code not being set on BORKED tests
When no test paths are specified this shows up when 'make test' is used on a PECL extension without specifying tests to run (or in php-src too, I guess...)

Closes GH-6717.
2021-02-23 12:50:03 +01:00
Christoph M. Becker 3f282e57ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update php_version.h to proper version number
2021-02-23 12:16:15 +01:00
Christoph M. Becker 81396ea890 Update php_version.h to proper version number 2021-02-23 12:09:06 +01:00
Nikita Popov 79cf2c56d3 Fixed bug #80786
Don't use r0 as temporary register in math_double_long if it is
already used for a memory result.

This was already done in one branch, but not the other.
2021-02-23 10:22:00 +01:00
Christoph M. Becker b418fe266d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #75776: Flushing streams with compression filter is broken
2021-02-22 15:32:17 +01:00
Christoph M. Becker 963e50c8c4 Fix #75776: Flushing streams with compression filter is broken
First, the `bzip2.compress` filter has the same issue as `zlib.deflate`
so we port the respective fix[1] to ext/bz2.

Second, there is still an issue, if a stream with an attached
compression filter is flushed before it is closed, without any writes
in between.  In that case, the compression is never finalized.  We fix
this by enforcing a `_php_stream_flush()` with the `closing` flag set
in `_php_stream_free()`, whenever a write filter is attached.  This
call is superfluous for most write filters, but does not hurt, even
when it is unnecessary.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=20e75329f2adb11dd231852c061926d0e4080929>

Closes GH-6703.
2021-02-22 15:28:46 +01:00
Christoph M. Becker 1d2bbce532 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80771: phpinfo(INFO_CREDITS) displays nothing in CLI
2021-02-22 14:34:21 +01:00
Christoph M. Becker 073b6ea818 Fix #80771: phpinfo(INFO_CREDITS) displays nothing in CLI
There is no good reason not to show the credits in text based SAPIs,
except for brevity.  Thus, we suppress the credits from `php -i`.

Closes GH-6710.
2021-02-22 14:31:51 +01:00
Christoph M. Becker 6dcd640f35 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80774: session_name() problem with backslash
2021-02-22 12:35:23 +01:00
Christoph M. Becker d7c98ca1ac Fix #80774: session_name() problem with backslash
Since we do no longer URL decode cookie names[1], we must not URL
encode the session name.  We need to prevent broken Set-Cookie headers,
by rejecting names which contain invalid characters.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=6559fe912661ca5ce5f0eeeb591d928451428ed0>

Closes GH-6711.
2021-02-22 12:32:56 +01:00
Nikita Popov ab98944195 Fix trampoline leak on dynamic static call of non-static method
Fixes oss-fuzz #30317.
2021-02-22 10:32:59 +01:00
Nikita Popov ed4f90f0c7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80781
2021-02-22 09:38:34 +01:00
Nikita Popov 6dd85f83f7 Fixed bug #80781
zend_find_array_dim_slow() may throw, make sure to handle this.
This backports the code we already use for this on PHP-8.0,
and also backports an exception check that makes this easier to
catch.
2021-02-22 09:36:43 +01:00
Nikita Popov 85ffe8dcdc Avoid signed integer overflow in substr()
Perform negation after the (size_t) cast rather than before,
so as to avoid a signed integer overflow for PHP_INT_MIN.

Fixes oss-fuzz #31069.
2021-02-18 10:34:54 +01:00
Christoph M. Becker 553a0c52b1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80763: msgfmt_format() does not accept DateTime references
2021-02-17 17:30:47 +01:00
Christoph M. Becker 84b6152842 Fix #80763: msgfmt_format() does not accept DateTime references
`intl_zval_to_millis()` needs to cater to references.

Closes GH-6707.
2021-02-17 17:26:48 +01:00
Nikita Popov cbdd21a22d Color LEAK&FAIL like a failure 2021-02-17 16:40:19 +01:00
Sara Golemon 8c6db654e7 Prep for 8.0.4 2021-02-17 15:24:43 +00:00
Dmitry Stogov 7f68a7afe6 Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts) 2021-02-17 11:51:13 +03:00
Dylan T 408272b8d9 Remove generated zend_jit_x86.c on make clean
Not removing this causes build failure when reconfiguring and rebuilding after a `make clean`, e.g. enabling/disabling ZTS.

This makes https://bugs.php.net/bug.php?id=80561 more bearable. Ideally it would be rebuilt automatically on configuration change if necessary, but I have no idea how to implement this.

Closes GH-6702.
2021-02-17 09:45:12 +01:00
Dmitry Stogov fad87a24da Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true) 2021-02-16 20:02:12 +03:00
Nikita Popov edb9229b8b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle incomplete result set metadata more gracefully
2021-02-16 15:34:47 +01:00
Nikita Popov 9552cf6b84 Handle incomplete result set metadata more gracefully
Rather than segfaulting because sname is missing lateron, report
a FAIL here. As this indicates a server bug, the errors is reported
as an out of band warning, rather than a client error.

This fixes the PHP side of bug #80713.
2021-02-16 15:34:14 +01:00
Nikita Popov b63ea1047a Mark resource-like objects as non-comparable
As these hold on to some internal resource, there can't be two
"equal" objects with different identity. Make sure the lack of
public properties doesn't result in these being treated as always
equal.
2021-02-16 14:20:45 +01:00
Nikita Popov cb9785add1 Fixed bug #80723
This fixes the issue just for the Socket class. Presumably we'll
want to do the same for other "resource" objects.
2021-02-16 12:33:50 +01:00
Derick Rethans 2dc75a9e93 Merge branch 'PHP-7.4' into PHP-8.0 2021-02-16 11:31:43 +00:00
Derick Rethans 2d858fbfb1 Fixed dates 2021-02-16 11:31:34 +00:00
Derick Rethans f73e419996 Merge branch 'PHP-7.4' into PHP-8.0 2021-02-16 11:27:17 +00:00
Derick Rethans 6d3d9104e6 PHP-7.4 is now 7.4.17-dev 2021-02-16 11:26:47 +00:00
Nikita Popov 2d7ada2c0b Increase timeout on asan job
Regularly runs against the 5:10 hour limit on master. Increase it
to 6:00 hours.
2021-02-16 10:15:08 +01:00
Nikita Popov 4fb8252186 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Suppress OpenSSL error on missing optional config
2021-02-16 10:12:42 +01:00
Nikita Popov 7566742754 Suppress OpenSSL error on missing optional config
openssl_pkey_new() fetches various options from the config file --
most of these are optional, and not specifying them is not an error
condition from the perspective of the user. Unfortunately, the
CONF_get_string() API pushes an error when accessing a key that
doesn't exist (_CONF_get_string does not, but that is presumably a
private API). This commit adds a helper php_openssl_conf_get_string()
that automatically clears the error in this case. I've found that
OpenSSL occasionally does the same thing internally:
https://github.com/openssl/openssl/blob/22040fb790c854cefb04bed98ed38ea6357daf83/apps/req.c#L515-L517

Closes GH-6699.
2021-02-16 10:11:00 +01:00
Christoph M. Becker afe17cc1b6 Adapt test case for libcurl 7.75.0+
libcurl 7.75.0 finally adds support for `gophers://`, i.e. gopher over
TLS.  The protocol is neither standardized, nor is the protocol
registered with IANA, but well, it is there and the test case should
cater to that.
2021-02-16 00:28:34 +01:00
Nikita Popov f43097a2d7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80747
2021-02-15 15:34:21 +01:00
Nikita Popov 64b1085464 Fixed bug #80747
If RSA key generation fails, actually report that failure.
2021-02-15 15:34:01 +01:00
Nikita Popov 882862563a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix symtable cache being used while cleaning symtable
2021-02-15 14:58:59 +01:00
Nikita Popov 7b7d99839c Fix symtable cache being used while cleaning symtable
We need to first clean the symtable and then check whether a cache
slot is available for it. Otherwise, it may happen that a destructor
runs while cleaning the table and uses up all the remaining slots
in the cache.

This is particularly insidious because once we overflow the cache,
the first pointer we modify is symtable_cache_ptr, making it hard
to understand what happened after the fact.

Fixes oss-fuzz #30815.
2021-02-15 14:58:38 +01:00
Nikita Popov c70220205e Fix assertion failure in cufa optimization with named args
Fixes oss-fuzz#30764.
2021-02-15 12:43:31 +01:00
Nikita Popov 8b9dd0a301 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78680: mysqlnd pam plugin missing terminating null
2021-02-15 11:32:54 +01:00
Daniel Black 3646604203 Fix #78680: mysqlnd pam plugin missing terminating null
The PAM service requires the terminating null to be part
of the communication.

Tested with MariaDB-10.4(pam) and Percona Server 5.7.32(auth_pam_compat).

Also changed MySQL Enterprise test to the server side plugin, authentication_pam
as opposed to the client plugin mysql_clear_password.

Add additional check for pamtest user and pam service file as
all are required for the test.

More importantly, test result should actually succeed.

Thanks Geoff Montee for bug report.

Closes GH-78680.
2021-02-15 11:32:07 +01:00
Nikita Popov 8e9eeca0b3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix leak when breaking out of FilesystemIterator
2021-02-15 10:38:21 +01:00
Nikita Popov 44a80b64b9 Fix leak when breaking out of FilesystemIterator
We need to always destroy current, not just when iter.data is not
set.

Take this opportunity to clean up the iterator destructor code a
bit, to remove redundant checks and incorrect comments.
2021-02-15 10:37:59 +01:00
Benjamin Eberlei 6ec25f386f Fixed bug #80600 2021-02-12 17:16:48 +01:00
Nikita Popov 5199686873 Fixed bug #80718 2021-02-11 16:49:39 +01:00
Nikita Popov 226395a335 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80719
2021-02-11 16:13:56 +01:00
Nikita Popov c34c523467 Fixed bug #80719 2021-02-11 16:12:06 +01:00
Nikita Popov 7215261349 Update func info after password_get_info() change 2021-02-11 11:44:14 +01:00
Nikita Popov cec5e30889 Don't return null from password_get_info()
The get_info() handler should never fail, but even if it does,
we should still return a proper info array -- it doesn't make
sense that a completely incorrect hash returns an info array,
but a hash that is recognized but for which the options can't
be extracted would return null.
2021-02-11 10:21:31 +01:00
Nikita Popov d80d918547 Don't throw additional Error in require_once if exception already thrown
As pointed out in comments on bug #66216.
2021-02-11 09:41:19 +01:00
Nikita Popov 39c6aaa9cc Make mysqli_ssl_set() arguments nullable
This function internally converts zero length arguments to NULL
argument -- but we should also accept them in the first place.

Null arguments being accepted was actually documented, before
bug #78399 adjusted the docs to match current behavior.
2021-02-10 15:31:27 +01:00
Nikita Popov fd5ff37db7 Make finfo_open() $magic_database nullable
Empty string was interpreted as a special value here, which indicates
that the default magic database should be used. It makes more sense
to use null for this purpose.

The documentation also explicitly mentions that null can be used.
2021-02-10 12:18:42 +01:00
Nikita Popov ce7935e82a Don't pass null action to __doRequest
The parameter is not nullable, so it will be interpreted as
an empty string anyway.

The entire code here is pretty confusing though, and probably
deserves a second loop. The HTTP code only send SOAPAction/action
if soapaction is non-NULL -- but it always is, because it is
accepted through a non-nullable string parameter.

Regarding the SOAPAction header, it appears that always sending
it is actually a requirement of the standard:
> An HTTP client MUST use this header field when issuing a SOAP
> HTTP Request.
Although it does make a distinction between absence of value and
an empty string:
> The header field value of empty string ("") means that the intent
> of the SOAP message is provided by the HTTP Request-URI. No value
> means that there is no indication of the intent of the message.
The empty string interpretation appears to be the desired one.

However, for the action MIME tag the SOAP 1.2 Part 2 specification
says that
> The media type specifies an optional action parameter, which can
> be used to optimize dispatch or routing, among other things.
but also
> The SOAP Action feature defines a single property, which is
> described in Table 14. The value of this property MUST be an
> absolute URI[RFC 3986] and MUST NOT be empty.
which would indicate that we should not be sending an empty
action here.

As I'm not familiar with SOAP and this is long-standing behavior,
I'm just leaving this alone for now...
2021-02-10 12:00:20 +01:00
Nikita Popov 40ba9f6a1a Clarify that location is required in do_request
As far as I can tell, the location is always non-null here,
and the code wouldn't be able to meaningfully work without a
location.
2021-02-10 11:18:20 +01:00
Nikita Popov cff35ca0b2 Regenerate arginfo file
Somehow missed this in the previous commit.
2021-02-10 11:18:06 +01:00
Nikita Popov 788abb8cc8 Accept null $location in SoapClient::__setLocation()
Currently an empty string is used to unset the location. Once
again, it makes more sense to use a null value for this purpose
(though the special behavior of empty strings is retained).

The code comment above the function also explicitly indicates
that null should be accepted, and the function does return null
rather than an empty string for the old location value (if it
is missing).
2021-02-10 10:50:42 +01:00
Nikita Popov 32d128d219 Make SoapVar arguments nullable
$typeName, $typeNamespace, $nodeName and $nodeNamespace all
special-case the empty string and don't set the property entirely
in that case. It makes more sense to use null to indicate absence
here (though of course the empty string behavior is retained).
2021-02-10 10:36:32 +01:00
Máté Kocsis 45fa7596dc Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Nikita Popov 57cb01a927 Properly check imagegd() signature
Unlike imagegd2(), this function only accepts two parameters,
so we should be checking for that.
2021-02-09 15:18:59 +01:00
Nikita Popov 838ae016d7 Make imagegd $file parameter nullable
It is explicitly documented to be nullable, and this matches other
functions like imagepng. It is also documented to accept a stream,
which it currently does not...
2021-02-09 15:15:20 +01:00
Nikita Popov d4aff25473 Use E_ERROR to report arginfo/zpp mismatch
When E_CORE_ERROR is used, we don't get correct file/line information.
2021-02-09 14:36:44 +01:00
Nikita Popov f5768eaa2e Make NumberFormatter ctor $pattern nullable
Whether the pattern is needed depends on the used style. If no
pattern is needed, null is a more sensible value than an empty
string.

fixup
2021-02-09 14:36:41 +01:00
Nikita Popov 186f9bab45 Make IntlDateFormatter ctor $pattern nullable
The implementation already made this argument nullable, but it
was not reflected in the stub.
2021-02-09 14:25:30 +01:00
Nikita Popov 44192ce80b Make Phar $fileNotFoundScript nullable
While "" is already treated the same way as absence, null is the
logically correct default here. Making this one argument non-nullable
is particularly pecular when considering that the preceding $alias
and $index arguments are both nullable.
2021-02-09 12:55:33 +01:00
Nikita Popov 3549f48edc Make createDocument() $namespace nullable
According to the DOM specification, this argument should be
nullable. It's also supposed to be a required argument, but
not changing that at this point.
2021-02-09 12:28:28 +01:00
Nikita Popov ab92ffee22 Make getElementsByTagNameNS $namespace nullable
According to the DOM specification, this argument is supposed to
be nullable.
2021-02-09 12:19:44 +01:00
Christoph M. Becker ff8da0dcff Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid C4090 level 1 warning
2021-02-08 23:12:49 +01:00
Christoph M. Becker 4f508003a9 Avoid C4090 level 1 warning
This breaks the build for PHP 8 by default.
2021-02-08 23:11:37 +01:00
Christoph M. Becker 92f71d9d42 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix locale dependent parsing of PostgreSQL version number
2021-02-08 19:00:37 +01:00
Christoph M. Becker 03713ace23 Fix locale dependent parsing of PostgreSQL version number
Version numbers are not supposed to be localized, so we must not apply
locale dependent parsing with `atof()`.

Using `php_version_compare()` might even be better.

Closes GH-6668.
2021-02-08 18:57:08 +01:00
Christoph M. Becker f731477cd7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80706: mail(): Headers after Bcc headers may be ignored
2021-02-08 18:43:51 +01:00
Christoph M. Becker ca7547c9e2 Fix #80706: mail(): Headers after Bcc headers may be ignored
We need to handle the case where a CRLF after a Bcc header is not the
beginning of a folding marker, because in that case the Bcc header was
not the last "thing".

Closes GH-6666.
2021-02-08 18:42:31 +01:00
Nikita Popov e2c30c6a2e Restore Laravel test workaround
I accidentally dropped this during a merge, making the Laravel
job fail.
2021-02-07 18:02:19 +01:00
Tyson Andre 5e06dad411 Properly render 2+ namespaces functions in build/gen_stub.php
Affects ZEND_NS_FE

Add test cases of the global function

Backported to php 8.0 from GH-6664
2021-02-06 14:17:14 -05:00
Christoph M. Becker f23bfc4b43 Fix test expectation for PHP 8.0
Since float to string conversion is no longer locale dependent, we have
to expect a dot as decimal separator.
2021-02-05 14:55:26 +01:00
Christoph M. Becker 95e405023e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Use ST_Y() instead of the deprecated/removed Y() in test
2021-02-05 14:54:25 +01:00
Christoph M. Becker 4ff2665509 Use ST_Y() instead of the deprecated/removed Y() in test 2021-02-05 14:53:19 +01:00
Christoph M. Becker 4be5b4aa25 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74779: x() and y() truncating floats to integers
2021-02-05 13:12:03 +01:00
Christoph M. Becker 3f8d21b922 Fix #74779: x() and y() truncating floats to integers
We must not use the locale dependent `atof()`, but instead use the
(hopefully) locale independent `zend_strtod()`, when converting string
representations of floating point numbers which are sent by the server.

Closes GH-6665.
2021-02-05 13:09:59 +01:00
Nikita Popov 0c6ff5eafa Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Try SIGTERM before SIGKILL in opcache restart
2021-02-04 17:07:30 +01:00
Nikita Popov 8b7aaad7d6 Try SIGTERM before SIGKILL in opcache restart
SIGTERM is subject to HANDLE_BLOCK_INTERRUPTIONS(), which will
allow code to exit critical sections before it gets terminated.

Closes GH-6493.
2021-02-04 17:07:18 +01:00
Nikita Popov 5cb25a2d32 Fix CLI server worker support
If we create separate listening sockets in each worker using
SO_REUSEADDR, then an incoming connection may be load-balanced
to a process that is already busy, either due to a long-running
request, or because it is a recursive request (in which case we
would deadlock).

Instead, only create one listening socket, and only create worker
forks afterwards. This way the incoming request will be served
by one of the workers that is currently listening for an incoming
connection.
2021-02-04 15:22:34 +01:00
Christoph M. Becker 767ddb1cd5 [ci skip] Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix newly introduced compiler warning
2021-02-03 12:45:31 +01:00
Christoph M. Becker 958e3b93c3 [ci skip] Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix newly introduced compiler warning
2021-02-03 12:43:40 +01:00
Nikita Popov 06c9633b43 Fix newly introduced compiler warning
(cherry picked from commit ab8177de2c)
2021-02-03 12:42:28 +01:00
Christoph M. Becker f4332a36b4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #53467: Phar cannot compress large archives
2021-02-03 11:24:36 +01:00
Christoph M. Becker 1bb2a4f91c Fix #53467: Phar cannot compress large archives
When Phars are flushed, a new temporary file is created for each entry
which should be compressed, and the `compressed_filesize` is retrieved.
Afterwards, the Phar manifest is written, and only after that the files
are copied to the actual Phar.  So for each such entry there is an open
temp file, what easily exceeds the limit.

Therefore, we use a single temporary file for all entries, and store
the start offset in the otherwise unused `header_offset` member.  We
ensure that the `cfp` members are properly set to NULL even if flushing
fails, to avoid use after free scenarios.

This solution is based on a suggestion by @lserni[1].

Closes GH-6643.

[1] <https://github.com/box-project/box2/issues/80#issuecomment-77147371>
2021-02-03 11:22:37 +01:00
Benjamin Eberlei 665e1f324a Fix bug #80600 DOMChildNode::remove does not work on DOMCharacterData.
Closes GH-6660
2021-02-02 20:26:52 +01:00
Christoph M. Becker 37ab72768f [ci skip] Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  7.3.28 is next
2021-02-02 17:11:01 +01:00
Christoph M. Becker 3d09626f0d [ci skip] Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  7.3.28 is next
2021-02-02 17:07:16 +01:00
Christoph M. Becker 039ca4e219 7.3.28 is next 2021-02-02 17:01:55 +01:00
Nikita Popov f1cf553437 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update year to 2021
2021-02-02 16:46:52 +01:00
Peter Kokot 8c04944b66 Update year to 2021
Closes GH-6636.
2021-02-02 16:46:16 +01:00
Nikita Popov b20362c24b Remove unnecessary cast in snmp_set_oid_output_format
This cast isn't needed, and could result in the ValueError being
skipped due to truncation.
2021-02-02 16:43:43 +01:00
Nikita Popov 0ec7bfaa43 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing derefs in CurlFile
2021-02-02 10:32:11 +01:00
Nikita Popov 54fa0a69f8 Add missing derefs in CurlFile
As pointed out on GH-6456.
2021-02-02 10:31:16 +01:00
Nikita Popov f1a988af4b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix persistent leak on load_wsdl_ex failure
2021-02-02 10:07:04 +01:00
Nikita Popov 51d76c346e Fix persistent leak on load_wsdl_ex failure
Move the load_wsdl_ex call into the zend_try that destroys the
docs hash table. The wsdl will be inserted into docs early on,
and will thus be released on subsequent bailout.
2021-02-02 10:05:35 +01:00
Christoph M. Becker efe69168b4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Updated to version 2021.1 (2021a)"
2021-02-01 13:43:57 +01:00
Christoph M. Becker 675a9b2831 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Revert "Updated to version 2021.1 (2021a)"
2021-02-01 13:42:43 +01:00
Christoph M. Becker 57257a4335 Revert "Updated to version 2021.1 (2021a)"
This reverts commit 491488d217, since
PHP-7.3 is in security mode, and this does not look security related.
2021-02-01 13:41:32 +01:00
Christoph M. Becker 766d5846b1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
2021-02-01 13:00:22 +01:00
Christoph M. Becker 7e9479083d Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
We remove the arbitrary restriction to `INT_MAX`; it is superfluous on
32bit systems where `ZEND_LONG_MAX == INT_MAX` anyway, and not useful
on 64bit systems, where larger files should be readable, if the
`memory_limit` is large enough.

Closes GH-6648.
2021-02-01 12:57:40 +01:00
Nikita Popov cab1ea46e7 XFAIL observer_error_05.phpt test 2021-02-01 10:24:00 +01:00
Nikita Popov 9efd7ddd0a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix Laravel build on community job
2021-02-01 09:49:13 +01:00
Nikita Popov 217b9e7b41 Fix Laravel build on community job
Now requires PHP 7.4, so use php7.4 to run composer everywhere.
2021-02-01 09:48:14 +01:00
Nikita Popov c72957b409 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix build
2021-02-01 09:46:27 +01:00
Nikita Popov ab8177de2c Fix build 2021-02-01 09:46:17 +01:00
David CARLIER 12d08db913 crc32 mac build fix
Closes GH-6651.
2021-02-01 09:43:12 +01:00
Stanislav Malyshev d94d0dda29 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80672 - Null Dereference in SoapClient
2021-01-31 21:42:48 -08:00
Stanislav Malyshev 86de4d7af6 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #80672 - Null Dereference in SoapClient
2021-01-31 21:42:41 -08:00
Stanislav Malyshev 3c939e3f69 Fix bug #80672 - Null Dereference in SoapClient 2021-01-31 21:15:23 -08:00
Christoph M. Becker 49ef8bc026 Add missing stub for SodiumException
Closes GH-6649.
2021-01-28 23:25:59 +01:00
Remi Collet b23a4256a6 NEWS 2021-01-28 16:26:46 +01:00
Remi Collet 4a35f4a476 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  NEWS
  Fix #80682 opcache doesn't honour pcre.jit option
2021-01-28 16:26:26 +01:00
Remi Collet aeb4f21549 NEWS 2021-01-28 16:25:35 +01:00
Remi Collet 067f7e4150 Fix #80682 opcache doesn't honour pcre.jit option 2021-01-28 16:24:39 +01:00
Michael Voříšek 27eb81604b Fix stub for Serializable::serialize()
This method may also return null.
2021-01-28 10:15:07 +01:00
Sammy Kaye Powers 17142eab22 Observe fake closures
Closes GH-6607.
2021-01-28 10:03:41 +01:00
Stanislav Malyshev e9b8b085a7 Rm unneeded function 2021-01-27 00:18:49 -08:00
Stanislav Malyshev 66a21e90cb Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Rm unneeded function
2021-01-27 00:15:43 -08:00
Stanislav Malyshev 21f861225a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Rm unneeded function
2021-01-27 00:15:13 -08:00
Stanislav Malyshev 9c673083cd Rm unneeded function 2021-01-27 00:13:43 -08:00
Stanislav Malyshev effa287b35 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Alternative fix for bug 77423
2021-01-26 22:55:16 -08:00
Stanislav Malyshev fbf8c758fe Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Alternative fix for bug 77423
2021-01-26 22:55:10 -08:00
Christoph M. Becker 4a89e726bd Alternative fix for bug 77423
That bug report originally was about `parse_url()` misbehaving, but the
security aspect was actually only regarding `FILTER_VALIDATE_URL`.
Since the changes to `parse_url_ex()` apparently affect userland code
which is relying on the sloppy URL parsing[1], this alternative
restores the old parsing behavior, but ensures that the userinfo is
checked for correctness for `FILTER_VALIDATE_URL`.

[1] <https://github.com/php/php-src/commit/5174de7cd33c3d4fa591c9c93859ff9989b07e8c#commitcomment-45967652>
2021-01-26 22:54:58 -08:00
Dmitry Stogov 64622979f9 Fixed observer API and JIT compatibility 2021-01-26 21:31:15 +03:00
Christoph M. Becker 01a348617f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #70091: Phar does not mark UTF-8 filenames in ZIP archives
2021-01-26 19:15:37 +01:00
Christoph M. Becker 6a0b889f57 Fix #70091: Phar does not mark UTF-8 filenames in ZIP archives
The default encoding of filenames in a ZIP archive is IBM Code Page
437.  Phar, however, only supports UTF-8 filenames.  Therefore we have
to mark filenames as being stored in UTF-8 by setting the general
purpose bit 11 (the language encoding flag).

The effect of not setting this bit for non ASCII filenames can be seen
in popular tools like 7-Zip and UnZip, but not when extracting the
archives via ext/phar (which is agnostic to the filename encoding), or
via ext/zip (which guesses the encoding).  Thus we add a somewhat
brittle low-level test case.

Closes GH-6630.
2021-01-26 19:14:25 +01:00
Christoph M. Becker 372fb75b68 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update version
2021-01-26 19:09:35 +01:00
Christoph M. Becker 94af11d5e1 Update version
That appears to have been forgotten for a while.
2021-01-26 19:08:23 +01:00
Dmitry Stogov b529d02d24 Allow observer handlers disabling optimization in RETURN opcode handler, that may cause loss value of returned local variable. 2021-01-26 19:23:13 +03:00
Dmitry Stogov 094e1a8b2d Skip dummy frames allocated on CPU stack of zend_call_function().
(Usage of "current_observed_frame" varible looks unsafe to me).
2021-01-26 18:41:26 +03:00
Nikita Popov a2dcd44272 Fix VAR return type verification
We should also set retval_ref when de-indirecting. Otherwise the
retval_ref != retval_ptr comparison below may incorrect assume
that we're returning a reference.

I don't have a reliable reproducer for this issue, but it sometimes
appears in certain configurations in arrow_functions/007.phpt in
conjunction with other changes.
2021-01-26 15:15:18 +01:00
Christoph M. Becker 2e580da28e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolon
2021-01-25 18:49:22 +01:00
Christoph M. Becker 61ed904cec Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolon
We add the failure reason to the error message.

Closes GH-6638.
2021-01-25 18:47:15 +01:00
Nikita Popov 18507853cb Improve switch continue warning
Don't suggest "continue N+1" if there is no wrapping loop. The
resulting code would be illegal.
2021-01-25 16:17:50 +01:00
Christoph M. Becker d319098b24 Fix #53251: bindtextdomain with null dir doesn't return old value
Apparently, users expect `bindtextdomain` and `bind_textdomain_codeset`
with `null` as second argument to work like their C counterparts,
namely to return the previously set value.  Thus, we support that.

Closes GH-6631.
2021-01-25 15:44:14 +01:00
Alex Samorukov 527bcb1e2e Fix opcache phpize build on FreeBSD
Closes GH-6589.
2021-01-25 15:10:47 +01:00
Derick Rethans fee80e397d Updated to version 2021.1 (2021a) 2021-01-25 10:44:06 +00:00
Derick Rethans f31538c997 Empty merge 2021-01-25 10:44:06 +00:00
Derick Rethans 3f183bbcf8 Updated to version 2021.1 (2021a) 2021-01-25 10:44:05 +00:00
Derick Rethans 072cfef1d5 Empty merge 2021-01-25 10:44:05 +00:00
Derick Rethans 491488d217 Updated to version 2021.1 (2021a) 2021-01-25 10:44:04 +00:00
Christoph M. Becker a86443f5a3 Add missing stub for SNMPException 2021-01-24 17:58:26 +01:00
Christoph M. Becker bff7761653 Add missing stub for com_exception 2021-01-24 16:06:49 +01:00
Christoph M. Becker 02933f923e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing SKIPIF clause for recently introduced test case
2021-01-21 17:28:41 +01:00
Christoph M. Becker edb389730d Add missing SKIPIF clause for recently introduced test case 2021-01-21 17:27:09 +01:00
Christoph M. Becker c4e63c378c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80648: Fix for bug 79296 should be based on runtime version
2021-01-20 16:24:53 +01:00
Christoph M. Becker 6adfb8c962 Fix #80648: Fix for bug 79296 should be based on runtime version
Instead of checking for actually affected libzip versions, we now always
`ZIP_TRUNCATE` empty files unless `ZIP_RDONLY` is set.

Closes GH-6625.
2021-01-20 16:20:13 +01:00
Christoph M. Becker 0ad78817a3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing SKIPIF clauses to new test cases
2021-01-20 11:04:48 +01:00
Christoph M. Becker 4c1b3e3036 Add missing SKIPIF clauses to new test cases 2021-01-20 11:02:52 +01:00
Nikita Popov 286c13e1e6 Skip preloading test on windows 2021-01-20 10:09:31 +01:00
Dmitry Stogov 6288228b56 Fixed bug #80634 (write_property handler of internal classes is skipped on preloaded JITted code) 2021-01-20 11:03:37 +03:00
Gabriel Caruso 34f0f60db5 Next is 8.0.3 2021-01-19 13:00:48 -03:00
Gabriel Caruso 9ce200f6cb Fix NEWS placeholder for the next version
This aligns with the PHP-7.4 and PHP-7.3 branches, and should
fix the `sgolemon/php-release` script run for releasing 8.0.2.
2021-01-19 12:32:17 -03:00
Derick Rethans b5599a37d7 Merge branch 'PHP-7.4' into PHP-8.0 2021-01-19 14:59:19 +00:00
Derick Rethans a33d0c3aae Update NEWS and version 2021-01-19 14:58:38 +00:00
Derick Rethans e8a89c49db Update NEWS for PHP 7.4.15RC1 2021-01-19 14:44:32 +00:00
Nikita Popov f3415758d1 Fix observer tests on Windows
Use %e instead of a hardcoded forward slash.
2021-01-19 15:27:14 +01:00
Nikita Popov 05d168013a Fixed bug #80644: ResourceBundle::get() doesn't reset error state 2021-01-19 15:20:55 +01:00
Nikita Popov 1bdd8f7ae4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #42560
2021-01-19 11:44:22 +01:00
sj-i 5d31ee302d Fixed bug #42560
Check open_basedir after the fallback to the system's temporary
directory in tempnam().

In order to preserve the current behavior of upload_tmp_dir
(do not check explicitly specified dir, but check fallback),
new flags are added to check open_basedir for explicit dir
and for fallback.

Closes GH-6526.
2021-01-19 11:41:58 +01:00
Christoph M. Becker f33105dcb6 ldap_search() and friends can return array
See the description of <https://www.php.net/ldap-search>, and also the
implementation.

Closes GH-6620.
2021-01-19 10:35:17 +01:00
Christoph M. Becker cfae999f1b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
2021-01-19 10:30:28 +01:00
Christoph M. BeckerandAnna Filina 68f5289e9e Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
When extracting compressed files from an uncompressed Phar, we must not
use the direct file pointer, but rather get an uncompressed file
pointer.

We also add a test to show that deflated and stored entries are
properly extracted.

This also fixes #79912, which appears to be a duplicate of #69279.

Co-authored-by: Anna Filina <afilina@gmail.com>

Closes GH-6599.
2021-01-19 10:28:54 +01:00
Dylan K. Taylor 872f302b8d Keep JIT region executable under ZTS
When one thread tries to compile a script, another thread may
already be executing JITed code. In this case we can't make the
memory non-executable.

This violates the W^X principle, but doesn't seem to be avoidable
for ZTS builds for now. The same problem does not exist for NTS,
as it's a different process executing there, which has it's own
memory protection mapping.

Closes GH-6595.
2021-01-19 10:25:42 +01:00
Nikita Popov fbd8e20ed5 Observe unused return values in JIT
Even if the return value is not used, it should still be available
to the observer.
2021-01-19 10:09:53 +01:00
Nikita Popov dd7d829896 Disable opcache optimizations during some observer tests
Opcache inlines functions that only return a constant. Disable
optimizations to prevent differences in tests where such functions
are used (or rewrite the test to not depend on it).
2021-01-19 10:02:08 +01:00
Nikita Popov f2364f316d SplFileObject::fgets() cannot return false
spl_filesystem_file_read() is called with silent=0, so it will
throw on failure.
2021-01-18 16:47:21 +01:00
Nikita Popov 7290dc4dcf Sync gzgets signature with fgets 2021-01-18 15:47:12 +01:00
Nikita Popov ebf461a025 Sync datefmt_get_calendar_object signature
In this case, it's only a matter of using the same type order
in both cases.
2021-01-18 14:39:32 +01:00
Nikita Popov 39077deea5 Sync intlcal_create_instance() and IntlCalendar::createInstance()
Remove the explicit mention of IntlGregorianCalendar in the latter.
It is a subclass of IntlCalendar, and as such covered if only
IntlCalendar is used as the return type.
2021-01-18 14:39:32 +01:00
Nikita Popov c31f9f7ee4 Sync date_diff and DateTime::diff return type
This function/method cannot return false.
2021-01-18 14:39:32 +01:00
Nikita Popov 48e2e5324e Fix parameter name of PharData::getMetadata()
The name should be the same as for Phar::getMetadata().
2021-01-18 14:09:00 +01:00
Dylan K. Taylor 0aad77418d Fix stub for Phar::setStub()
This fixes multiple issues:
 * The first parameter may be resource|string.
 * It's an overloaded signature. The second parameter cannot be
   passed if the first one is a string. Use UNKNOWN default
   value for that reason.
 * Make parameter names in PharData::setStub() match those in
   Phar.

Closes GH-6596.
2021-01-18 12:59:18 +01:00
Christoph M. Becker c321896a37 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80595: Resetting POSTFIELDS to empty array breaks request
2021-01-18 11:01:01 +01:00
Christoph M. Becker 38ad37ad43 Fix #80595: Resetting POSTFIELDS to empty array breaks request
This is mainly to work around https://github.com/curl/curl/issues/6455,
but not building the mime structure for empty hashtables is a general
performance optimization, so we do not restrict it to affected cURL
versions (7.56.0 to 7.75.0).

The minor change to bug79033.phpt is unexpected, but should not matter
in practice.

Closes GH-6606.
2021-01-18 10:57:56 +01:00
Nikita Popov 880bf62224 Fixed bug #80617: Type narrowing warning in ZEND_TYPE_INIT_CODE 2021-01-14 10:08:22 +01:00
Daniil Gentili f9fbba41b6 Fixed bug #80596: Fix anonymous class union typehint errors
Cut off part after null byte when resolving the class name, to
avoid cutting off a larger part lateron.

Closes GH-6601.
2021-01-14 10:04:27 +01:00
Dmitry Stogov 3edf5c969a Fixed bug #80422 (php_opcache.dll crashes when using Apache 2.4 with JIT) 2021-01-14 08:16:27 +03:00
Christoph M. Becker 41e9a8ebdc socket_create_pair() can no longer return NULL
Closes GH-6592.
2021-01-12 12:08:31 +01:00
David CARLIER 7a049cd6a4 Use arc4random_buf on macOS
macOS uses an AES based arc4random_buf implementation since at least
macOS 10.2.

Closes GH-6591.
2021-01-12 10:42:09 +01:00
Nikita Popov 973138f39d Add support for union types for internal functions
This closes the last hole in the supported types for internal
function arginfo types. It's now possible to represent unions of
multiple classes. This is done by storing them as TypeA|TypeB and
PHP will then convert this into an appropriate union type list.

Closes GH-6581.
2021-01-12 10:14:41 +01:00
Nikita Popov bc0f78a2da Use ephemeral port in socket_create_listen_used.phpt
Avoid parallelism issues.
2021-01-12 10:09:30 +01:00
Jens de Nies 94a151a018 Fixed bug #80545
This converts the remaining "non well-formed" warnings in bcmath
to ValueErrors, in line with the other warning promotions that
have been performed in this extension.

Closes GH-80545.
2021-01-12 09:50:27 +01:00
Christoph M. Becker 95a13ca989 Revert fix for bug 76813 and re2c version bump
CentOS 7 ships with re2c 0.13.5 by default, so we should not have
bumped the required re2c version to 0.13.7.  However, 0.13.5 does not
support default rules, so we cannot use them to fix bug 76813.

This reverts commit 420184ad52 and
5e15c9c41f.

Closes GH-6593.
2021-01-11 17:19:52 +01:00
Christoph M. Becker 52ed45745e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Fix #76813: Access violation near NULL on source operand"
2021-01-11 13:21:56 +01:00
Christoph M. Becker 25103c37aa Revert "Fix #76813: Access violation near NULL on source operand"
This reverts commit 5e15c9c41f, since
re2c default rules are only available as of re2c 0.13.7.
2021-01-11 13:21:12 +01:00
Dmitry Stogov 35e0506a2e Add guard if lvalue of assignment may be a reference, but wasn't a reference during recording 2021-01-11 15:12:27 +03:00
George Peter Banyard f40838eaaa Rename `zip_ent parameter to zip_entry` for consistency
All other functions use ``zip_entry``
2021-01-08 22:26:24 +00:00
Christoph M. Becker 8ae02c8a95 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid modifying the return value of readline_completion_function()
2021-01-07 13:48:17 +01:00
Christoph M. Becker 9450893dc6 Avoid modifying the return value of readline_completion_function()
The internal function `_readline_command_generator()` modifies the
internal array pointer of `readline_completion_function()`'s return
value.  We therefore separate the array, what also avoids failing
assertions regarding the array refcount.

Closes GH-6582.
2021-01-07 13:46:09 +01:00
Dharman 34ef804b04 Make fetch_* OO same as func
Clsoses GH-6580.
2021-01-06 15:02:52 +01:00
Christoph M. Becker f674a3343c Fix #80592: all floats are the same in ODBC parameters
We must not release the strings until we are done with them.

Closes GH-6579.
2021-01-06 13:56:02 +01:00
Dharman 44a311dbbe Fix/improve mysqli stubs
* mysqli_commit $flags default value is 0, not -1.
* A number of functions cannot actually return null.
* mysqli_poll parameter names were incorrect, as this function
  has a different signature from select.
* fetch functions apart from fetch_all can return false on failure.
2021-01-06 11:28:45 +01:00
Christoph M. Becker 90081c5391 Add missing SKIPIF clause for require_hash.phpt 2021-01-06 11:00:10 +01:00
Christoph M. Becker 66a74f2f4a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #77565: Incorrect locator detection in ZIP-based phars
2021-01-05 23:46:05 +01:00
Christoph M. Becker d1b1c04398 Fix #77565: Incorrect locator detection in ZIP-based phars
We must not assume that the first end of central dir signature in a ZIP
archive actually designates the end of central directory record, since
the data in the archive may contain arbitrary byte patterns.  Thus, we
better search from the end of the data, what is also slightly more
efficient.

There is, however, no way to detect the end of central directory
signature by searching from the end of the ZIP archive with absolute
certainty, since the signature could be part of the trailing comment.
To mitigate, we check that the comment length fits to the found
position, but that might still not be the correct position in rare
cases.

Closes GH-6507.
2021-01-05 23:40:24 +01:00
Christoph M. Becker b7689db7ab Prevent double-free of Phar ZIP stream
We must not alias the closed stream to `phar_archive_data.fp`, and use
PHAR_ZIP_FAIL() for consistency with the rest of this function.

Closes GH-6578.
2021-01-05 14:31:43 +01:00
Christoph M. Becker afc69e46b8 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix memory leak in Phar::webPhar() on Windows
2021-01-05 14:25:44 +01:00
Christoph M. Becker 5c963731e2 Fix memory leak in Phar::webPhar() on Windows
Closes GH-6574.
2021-01-05 14:21:35 +01:00
Nikita Popov dd335359e9 Fix infinite recursion in unlinked_instanceof
I suspect this is only a partial fix for the issue, it's probably
possible to recurse through a more complex pathway as well.

Fixes oss-fuzz #28961.
2021-01-05 13:03:41 +01:00
Nikita Popov 5e57f37247 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  gdbinit: use ____print_str to print htable keys
2021-01-05 10:12:43 +01:00
Dylan K. Taylor 6b631f073d gdbinit: use ____print_str to print htable keys
I noticed this problem while dumping the contents of EG(function_table),
where keys for closures start with a null byte. printf interprets this
as a zero-length string and emits nothing. This allows the key to be
rendered properly in readable form.

Closes GH-6577.
2021-01-05 10:11:56 +01:00
Christoph M. Becker 121790eaff [ci skip] Add forgotten NEWS entry (bug 80560) 2021-01-04 18:19:45 +01:00
George Peter Banyard 764b7bf108 Fix bug #80584: 0x and 0X are considered valid hex numbers by filter_var()
Closes GH-6573
2021-01-04 18:07:47 +01:00
Christoph M. Becker 9f96b2bdc8 Fix #76929: zip-based phar does not respect phar.require_hash
Based on the patch provided by david at bamsoftware.

Closes GH-6517.
2021-01-04 17:48:45 +01:00
Nikita Popov 821eaaf0b4 Fix newly added GMP test 2021-01-04 15:27:20 +01:00
George Peter Banyard 1b5c62facd Fix GMP comparison object handler
gmp_cmp() doesn't return false anymore in PHP 8 but will throw
an Error if compared to a non numeric string or another type of object.

Closes GH-6553
2021-01-04 14:47:50 +01:00
Nikita Popov af7445b9ac Try to fix intermittent failures of stream_server_reneg_limit.phpt on macos
Make sure the server has started up before we try to connect to it.
2021-01-04 14:31:42 +01:00
Nikita Popov 65f14b0d6c Throw ValueError instead of TypeError for malformed GMP number
If the passed argument has correct type (string) but does not
have a well-formed value, throw ValueError instead of TypeError.

Closes GH-6572.
2021-01-04 14:30:08 +01:00
Christoph M. Becker abe23bd9a3 SQLite3::query() cannot return null 2021-01-04 12:13:06 +01:00
David CARLIER 6e90c75507 Mac M1 crc32 detection support
Closes GH-6556.
2021-01-04 11:41:52 +01:00
Nikita Popov 151fce1129 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Disable non-cron travis jobs
2021-01-04 10:55:50 +01:00
Stanislav Malyshev bf2bb39eac Fix test name 2021-01-04 01:52:59 -08:00
Nikita Popov 46d6daea7a Disable non-cron travis jobs
This was already done for PHP-8.0 and master, do it for PHP-7.4
as well.
2021-01-04 10:52:37 +01:00
Stanislav Malyshev 4d1c1e4554 [ci skip] Update NEWS 2021-01-04 01:47:47 -08:00
Stanislav Malyshev ced4c0bfe6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  [ci skip] Update NEWS
  [ci skip] Fix order
  [ci skip] Unpdate NEWS
  Fix #77423: parse_url() will deliver a wrong host to user
2021-01-04 01:47:09 -08:00
Stanislav Malyshev e65932060a [ci skip] Update NEWS 2021-01-04 01:46:32 -08:00
Stanislav Malyshev ec589a27da Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  [ci skip] Fix order
2021-01-04 01:46:11 -08:00
Stanislav Malyshev 65d7ade684 [ci skip] Fix order 2021-01-04 01:45:15 -08:00
Stanislav Malyshev 2498385dd9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  [ci skip] Unpdate NEWS
2021-01-04 01:44:18 -08:00
Stanislav Malyshev 8967e66559 [ci skip] Unpdate NEWS 2021-01-04 01:43:45 -08:00
Stanislav Malyshev 8768621149 Fix bug #79405 - gethostbyname() silently truncates after a null byte 2021-01-04 01:19:21 -08:00
Christoph M. Becker b132da7f9d Fix #77423: parse_url() will deliver a wrong host to user
To avoid that `parse_url()` returns an erroneous host, which would be
valid for `FILTER_VALIDATE_URL`, we make sure that only userinfo which
is valid according to RFC 3986 is treated as such.

For consistency with the existing url parsing code, we use ctype
functions, although that is not necessarily correct.
2021-01-04 01:19:18 -08:00
Christoph M. Becker aab23282fc Fix imap stubs
Closes GH-6559.
2021-01-03 16:15:46 +01:00
Christoph M. Becker e470f9b389 ZipArchive methods do not return NULL
Closes GH-6563.
2021-01-03 16:12:10 +01:00
Stanislav Malyshev 434c2b1bdb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77423: parse_url() will deliver a wrong host to user
2021-01-01 21:29:08 -08:00
Stanislav Malyshev 128fca4037 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77423: parse_url() will deliver a wrong host to user
2021-01-01 21:06:07 -08:00
Christoph M. Becker 2d3d72412a Fix #77423: parse_url() will deliver a wrong host to user
To avoid that `parse_url()` returns an erroneous host, which would be
valid for `FILTER_VALIDATE_URL`, we make sure that only userinfo which
is valid according to RFC 3986 is treated as such.

For consistency with the existing url parsing code, we use ctype
functions, although that is not necessarily correct.
2021-01-01 20:08:01 -08:00
Christoph M. Becker cae0bcbab5 Fix parameter name
Levenshtein is about insertion, replacement and deletion.

Closes GH-6560.
2021-01-01 23:04:28 +01:00
Christoph M. Becker b2fba0ef62 Fix build
We cannot `RETURN_THROWS()` here, since `return_value` is not defined.
2021-01-01 17:41:48 +01:00
Máté Kocsis b23c865d15 Use RETURN_THROWS() in a few places 2021-01-01 16:52:48 +01:00
Christoph M. Becker 82f9e004da Fix ReflectionClass::getConstants() stub
If `zval_update_constant_ex()` fails, an exception has already been
thrown, so we clarify that in the implementation as well.

Closes GH-6557.
2021-01-01 14:46:28 +01:00
Christoph M. Becker 2e854791af [ci skip] Fix pgsql constant names in UPGRADING 2020-12-31 00:30:16 +01:00
Máté Kocsis 446ad04524 Fix refentry attribute replacing 2020-12-30 18:26:24 +01:00
George Peter Banyard abecaab09f Fix #80560: Strings containing only a base prefix return 0 object
Closes GH-6549.
2020-12-30 12:50:04 +01:00
Dmitry Stogov da0ca53f39 Initialize EX(call)->func by single instruction 2020-12-29 13:20:10 +03:00
Dmitry Stogov 56fde2a381 Reuse value stored in %r0 instead of immediate operand 2020-12-29 13:18:56 +03:00
Christoph M. Becker 13f898b56a Fix ffi stubs
Closes GH-6543.
2020-12-28 19:04:47 +01:00
Máté Kocsis 46a2c6a8d7 Fix return type of DateTimeImmutable::__set_state() 2020-12-28 14:45:13 +01:00
Máté Kocsis 9cec093b7f Add support for generating methodsynopses from stubs
Closes GH-6367
2020-12-28 14:44:43 +01:00
Christoph M. Becker 420184ad52 Bump minimum re2c version to 0.13.7
Closes GH-6516.
2020-12-28 13:43:31 +01:00
Christoph M. Becker 45b638afe0 php_formatted_print() throws on failure
Closes GH-6542.
2020-12-27 22:40:25 +01:00
Christoph M. Becker 57430e6f1e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Replace sort() function calls with ksort() in basic ksort test
2020-12-27 18:32:03 +01:00
haszi 0db6f5267c Replace sort() function calls with ksort() in basic ksort test
Closes GH-6541.
2020-12-27 18:30:58 +01:00
Christoph M. Becker 269936e680 DateTime*::getOffset() no longer returns false as of PHP 8.0.0
Cf. <https://github.com/php/doc-en/pull/282>.

Closes GH-6539.
2020-12-26 15:13:05 +01:00
Dmitry Stogov 23bbff2b05 Eliminate redundand comparison insructions 2020-12-24 16:58:54 +03:00
Máté Kocsis ab4c5976d7 Fix the signature of FFI::typeof() and FFI::memcmp() 2020-12-24 11:45:32 +01:00
Máté Kocsis c1d766171b Add a few other RETURN_THROWS() 2020-12-24 11:44:15 +01:00
Máté Kocsis ed19cb6518 Fix the signature of FFI::sizeof() and FFI::alignof() 2020-12-24 11:39:09 +01:00
Christopher Jones 34aefa36f4 Fix PDO_OCI test 2020-12-24 17:48:39 +11:00
Semen Dubina 959d3c9636 Add regression test for bug #76770
Closes GH-3514.
2020-12-23 16:47:08 +01:00
Christoph M. Becker 7d9ddd61ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80384: limit read buffer size
2020-12-23 13:52:45 +01:00
Adam SeitzandChristoph M. Becker 70dfbe0068 Fix #80384: limit read buffer size
In the case of a stream with no filters, php_stream_fill_read_buffer
only reads stream->chunk_size into the read buffer. If the stream has
filters attached, it could unnecessarily buffer a large amount of data.

With this change, php_stream_fill_read_buffer only proceeds until either
the requested size or stream->chunk_size is available in the read buffer.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-6444.
2020-12-23 13:49:56 +01:00
Derick Rethans 288332077f Fixed bug #80376 (last day of the month causes runway cpu usage) 2020-12-21 10:31:41 +00:00
Derick Rethans b043759cb4 Fixed bug #80376 (last day of the month causes runway cpu usage) 2020-12-21 10:30:40 +00:00
Nikita Popov 27e250880b Fix bug #80537
This is an unavoidable breaking change to both the type and
parameter name.

The assertion that was supposed to prevent this was overly lax
and accepted any object type for string parameters.
2020-12-21 10:21:50 +01:00
Christopher Jones d6731d69bd Description typo 2020-12-21 15:46:26 +11:00
Christopher Jones 74959b47cd Bundle PECL OCI8 3.0.1 2020-12-21 15:15:16 +11:00
Christopher Jones 2877642037 Retrofit NEWS 2020-12-21 15:07:40 +11:00
Christoph M. Becker 32c6c29d79 Revert "DateTime:: and DateTimeImmutable::getTimestamp() may return false"
This reverts commit b67c232189.
2020-12-20 23:07:02 +01:00
Christoph M. Becker b67c232189 DateTime:: and DateTimeImmutable::getTimestamp() may return false 2020-12-20 19:32:12 +01:00
Christoph M. Becker 3c68f43251 Fix ext/date stubs
Closes GH-6523.
2020-12-20 18:14:20 +01:00
Nikita Popov 51f57e7b81 PDO MySQL: Handle boolean parameter binding with libmysql
Previously boolean parameters were simply silently ignored...
2020-12-18 11:01:26 +01:00
Nikita Popov ab84623108 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  MySQLnd: Support cursors in store/get result
2020-12-18 10:20:13 +01:00
Nikita Popov bc166844e3 MySQLnd: Support cursors in store/get result
This fixes two related issues:

1. When a PS with cursor is used in store_result/get_result,
   perform a COM_FETCH with maximum number of rows rather than
   silently switching to an unbuffered result set (in the case of
   store_result) or erroring (in the case of get_result).
   In the future, we might want to make get_result unbuffered for
   PS with cursors, as using cursors with buffered result sets
   doesn't really make sense. Unlike store_result, get_result
   isn't very explicit about what kind of result set is desired.
2. If the client did not request a cursor, but the server reports
   that a cursor exists, ignore this and treat the PS as if it
   has no cursor (i.e. to not use COM_FETCH). It appears to be a
   server side bug that a cursor used inside an SP will be reported
   to the client, even though the client cannot use the cursor.

Fixes bug #64638, bug #72862, bug #77935.

Closes GH-6518.
2020-12-18 10:19:13 +01:00
Christoph M. Becker 1860ef22eb Fix #80521: Parameters with underscores no longer recognized
We have to use the proper value for the bitmask.
2020-12-16 20:04:52 +01:00
Nikita Popov c56701690a Detect overlarge step for character range()
This was done for int and float ranges, but not char ranges.

Fixes oss-fuzz #28666.
2020-12-16 17:01:15 +01:00
Nikita Popov 205d209de9 PDO MySQL: Use mysqlnd column names
mysqlnd already creates interned zend_strings for us, so let's
make use of them.

This also required updating the PDO case changing code to work
with potentially shared strings. For the lowercasing, use the
optimized zend_string_tolower() implementation.
2020-12-16 15:17:13 +01:00
Nikita Popov 1a66d64717 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #67983
2020-12-16 10:53:48 +01:00
Nikita Popov 315f3f8dc9 Fixed bug #67983
We need to check the BIT case first, otherwise it will get skipped
in INT_AND_FLOAT_NATIVE mode.
2020-12-16 10:52:27 +01:00
Nikita Popov f6bd3dfdbc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80523
2020-12-16 10:20:43 +01:00
Nikita Popov 118ff03335 Fix bug #80523
Don't truncate the file length to unsigned int...

I have no idea whether that fully fixes the problem because the
process gets OOM killed before finishing, but at least the
immediate parse error is gone now.
2020-12-16 10:20:20 +01:00
Derick Rethans e586a35fc7 Merge branch 'PHP-7.4' into PHP-8.0 2020-12-15 14:13:43 +00:00
Derick Rethans 078cdd8f76 Prepare for 7.4.15 2020-12-15 14:13:29 +00:00
Gabriel Caruso 9eea9aae10 Prepare for PHP 8.0.2
This was missing from f1f78ac875.
2020-12-15 11:03:21 -03:00
Gabriel Caruso f1f78ac875 Next is 8.0.2 2020-12-15 10:30:55 -03:00
422 changed files with 32932 additions and 25097 deletions

No files matched your search

+3 -4
View File
@@ -11,9 +11,7 @@ end
define ____executor_globals
if basic_functions_module.zts
if !$tsrm_ls
set $tsrm_ls = ts_resource_ex(0, 0)
end
set $tsrm_ls = _tsrm_ls_cache
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
set $eg_ptr = $eg
@@ -340,7 +338,8 @@ define ____print_ht
end
printf "[%d] ", $i
if $p->key
printf "%s => ", $p->key->val
____print_str $p->key->val $p->key->len
printf " => "
else
printf "%d => ", $p->h
end
+1 -1
View File
@@ -1,6 +1,6 @@
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2019 The PHP Group. All rights reserved.
Copyright (c) 1999 - 2021 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
+223 -2
View File
@@ -1,6 +1,223 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.0.1RC1
29 Apr 2021, PHP 8.0.5
- Core:
. Fixed bug #75776 (Flushing streams with compression filter is broken). (cmb)
. Fixed bug #80811 (Function exec without $output but with $restult_code
parameter crashes). (Nikita)
. Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space
available for static Thread Local Storage). (Dmitry)
. Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
Old registers (r28/r29) might be clobbered by _restgpr routine used for
return from C function compiled with -Os. (Dmitry)
- Dba:
. Fixed bug #80817 (dba_popen() may cause segfault during RSHUTDOWN). (cmb)
- DOM:
. Fixed bug #66783 (UAF when appending DOMDocument to element). (cmb)
- FFI:
. Fixed bug #80847 (CData structs with fields of type struct can't be passed
as C function argument). (Nickolas Daniel da Silva, Dmitry)
- FPM:
. Fixed bug #80024 (Duplication of info about inherited socket after pool
removing). (Jakub Zelenka)
- FTP:
. Fixed bug #80880 (SSL_read on shutdown, ftp/proc_open). (cmb, Jakub
Zelenka)
- IMAP:
. Fixed bug #80800 (imap_open() fails when the flags parameter includes
CL_EXPUNGE). (girgias)
. Fixed bug #80710 (imap_mail_compose() header injection). (cmb, Stas)
- Intl:
. Fixed bug #80763 (msgfmt_format() does not accept DateTime references).
(cmb)
- LibXML:
. Fixed bug #73533 (Invalid memory access in php_libxml_xmlCheckUTF8). (cmb)
. Fixed bug #51903 (simplexml_load_file() doesn't use HTTP headers). (cmb)
- MySQLnd:
. Fixed bug #80837 (Calling stmt_store_result after fetch doesn't throw an
error). (Kamil Tekiela)
- Opcache:
. Fixed bug #80839 (PHP problem with JIT). (Dmitry)
. Fixed bug #80861 (erronous array key overflow in 2D array with JIT).
(Dmitry)
. Fixed bug #80786 (PHP crash using JIT). (Nikita)
. Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1). (Dmitry)
- Pcntl:
. Fixed bug #79812 (Potential integer overflow in pcntl_exec()). (cmb)
- PCRE:
. Fixed bug #80866 (preg_split ignores limit flag when pattern with \K has
0-width fullstring match). (Kamil Tekiela)
- PDO_ODBC:
. Fixed bug #80783 (PDO ODBC truncates BLOB records at every 256th byte).
(cmb)
- PDO_pgsql:
. Fixed bug #80892 (PDO::PARAM_INT is treated the same as PDO::PARAM_STR).
(Matteo)
- Session:
. Fixed bug #80889 (Cannot set save handler when save_handler is invalid).
(cmb)
. Fixed bug #80774 (session_name() problem with backslash). (cmb)
- SOAP:
. Fixed bug #69668 (SOAP special XML characters in namespace URIs not
encoded). (cmb)
- Standard:
. Fixed bug #80915 (Taking a reference to $_SERVER hides its values from
phpinfo()). (Rowan Tommins)
. Fixed bug #80914 ('getdir' accidentally defined as an alias of 'dir').
(Rowan Tommins)
. Fixed bug #80771 (phpinfo(INFO_CREDITS) displays nothing in CLI). (cmb)
. Fixed bug #78719 (http wrapper silently ignores long Location headers).
(cmb)
. Fixed bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101).
(manuelm)
- Zip:
. Fixed bug #80825 (ZipArchive::isCompressionMethodSupported does not exist).
(cmb)
18 Feb 2021, PHP 8.0.3
- Core:
. Fixed #80706 (mail(): Headers after Bcc headers may be ignored). (cmb)
- DOM:
. Fixed bug #80600 (DOMChildNode::remove() doesn't work on CharacterData
nodes). (beberlei)
- Gettext:
. Fixed bug #53251 (bindtextdomain with null dir doesn't return old value).
(cmb)
- MySQLnd:
. Fixed bug #78680 (mysqlnd's mysql_clear_password does not transmit
null-terminated password). (Daniel Black)
. Fixed bug #80713 (SegFault when disabling ATTR_EMULATE_PREPARES and
MySQL 8.0). (Nikita)
- MySQLi:
. Fixed bug #74779 (x() and y() truncating floats to integers). (cmb)
- Opcache:
. Fixed bug #80634 (write_property handler of internal classes is skipped on
preloaded JITted code). (Dmitry)
. Fixed bug #80682 (opcache doesn't honour pcre.jit option). (Remi)
. Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be
true). (Dmitry)
. Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in
code involving bitshifts). (Dmitry)
- OpenSSL:
. Fixed bug #80747 (Providing RSA key size < 512 generates key that crash
PHP). (Nikita)
- Phar:
. Fixed bug #75850 (Unclear error message wrt. __halt_compiler() w/o
semicolon) (cmb)
. Fixed bug #70091 (Phar does not mark UTF-8 filenames in ZIP archives). (cmb)
. Fixed bug #53467 (Phar cannot compress large archives). (cmb, lserni)
- Socket:
. Fixed bug #80723 (Different sockets compare as equal (regression in 8.0)).
(Nikita)
- SPL:
. Fixed bug#80719 (Iterating after failed ArrayObject::setIteratorClass()
causes Segmentation fault). (Nikita)
- Standard:
. Fixed bug #80654 (file_get_contents() maxlen fails above (2**31)-1 bytes).
(cmb)
. Fixed bug #80718 (ext/standard/dl.c fallback code path with syntax error).
(Nikita)
21 Jan 2021, PHP 8.0.2
- Core:
. Fixed bug #80523 (bogus parse error on >4GB source code). (Nikita)
. Fixed bug #80384 (filter buffers entire read until file closed). (Adam
Seitz, cmb)
. Fixed bug #80596 (Invalid union type TypeError in anonymous classes).
(Daniil Gentili)
. Fixed bug #80617 (GCC throws warning about type narrowing in
ZEND_TYPE_INIT_CODE). (Nikita)
- BCMath:
. Fixed bug #80545 (bcadd('a', 'a') doesn't throw an exception).
(Jens de Nies)
- Curl:
. Fixed bug #80595 (Resetting POSTFIELDS to empty array breaks request). (cmb)
- Date:
. Fixed bug #80376 (last day of the month causes runway cpu usage). (Derick)
- DOM:
. Fixed bug #80537 (Wrong parameter type in DOMElement::removeAttributeNode
stub). (Nikita)
- Filter:
. Fixed bug #80584 (0x and 0X are considered valid hex numbers by
filter_var()). (girgias)
- GMP:
. Fixed bug #80560 (Strings containing only a base prefix return 0 object).
(girgias)
- Intl:
. Fixed bug #80644 (Missing resource causes subsequent get() calls to fail).
(Nikita)
- MySQLi:
. Fixed bug #67983 (mysqlnd with MYSQLI_OPT_INT_AND_FLOAT_NATIVE fails to
interpret bit columns). (Nikita)
. Fixed bug #64638 (Fetching resultsets from stored procedure with cursor
fails). (Nikita)
. Fixed bug #72862 (segfault using prepared statements on stored procedures
that use a cursor). (Nikita)
. Fixed bug #77935 (Crash in mysqlnd_fetch_stmt_row_cursor when calling an SP
with a cursor). (Nikita)
- ODBC:
. Fixed bug #80592 (all floats are the same in ODBC parameters). (cmb)
- Opcache:
. Fixed bug #80422 (php_opcache.dll crashes when using Apache 2.4 with JIT).
(Dmitry)
- PDO_Firebird:
. Fixed bug #80521 (Parameters with underscores no longer recognized). (cmb,
Simonov Denis)
- Phar:
. Fixed bug #76929 (zip-based phar does not respect phar.require_hash).
(david at bamsoftware, cmb)
. Fixed bug #77565 (Incorrect locator detection in ZIP-based phars). (cmb)
. Fixed bug #69279 (Compressed ZIP Phar extractTo() creates garbage files).
(cmb)
- Phpdbg:
. Reverted fix for bug #76813 (Access violation near NULL on source operand).
(cmb)
07 Jan 2021, PHP 8.0.1
- Core:
. Fixed bug #80345 (PHPIZE configuration has outdated PHP_RELEASE_VERSION).
@@ -26,6 +243,9 @@ PHP NEWS
- Intl:
. Fixed bug #80425 (MessageFormatAdapter::getArgTypeList redefined). (Nikita)
- OCI8
. Create Windows DLLs for Oracle Client 19c. (cmb)
- Opcache:
. Fixed bug #80404 (Incorrect range inference result when division results
in float). (Nikita)
@@ -81,6 +301,8 @@ PHP NEWS
. Fixed #62004 (SplFileObject: fgets after seek returns wrong line). (cmb)
- Standard:
. Fixed bug #77423 (FILTER_VALIDATE_URL accepts URLs with invalid userinfo).
(CVE-2020-7071) (cmb)
. Fixed bug #80366 (Return Value of zend_fstat() not Checked). (sagpant, cmb)
- Tidy:
@@ -469,4 +691,3 @@ PHP NEWS
. Fixed bug #71417 (fread() does not report zlib.inflate errors). (cmb)
. Fixed bug #78792 (zlib.output_compression disabled by Content-Type: image/).
(cmb)
+2 -2
View File
@@ -729,13 +729,13 @@ TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
#if defined(__APPLE__) && defined(__x86_64__)
// TODO: Implement support for fast JIT ZTS code ???
return 0;
#elif defined(__x86_64__) && defined(__GNUC__)
#elif defined(__x86_64__) && defined(__GNUC__) && !defined(__FreeBSD__)
size_t ret;
asm ("movq _tsrm_ls_cache@gottpoff(%%rip),%0"
: "=r" (ret));
return ret;
#elif defined(__i386__) && defined(__GNUC__)
#elif defined(__i386__) && defined(__GNUC__) && !defined(__FreeBSD__)
size_t ret;
asm ("leal _tsrm_ls_cache@ntpoff,%0"
+1 -1
View File
@@ -147,7 +147,7 @@ TSRM_API const char *tsrm_api_name(void);
# define __has_attribute(x) 0
#endif
#if !__has_attribute(tls_model)
#if !__has_attribute(tls_model) || defined(__FreeBSD__)
# define TSRM_TLS_MODEL_ATTR
#elif __PIC__
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
+2 -2
View File
@@ -888,8 +888,8 @@ PHP 8.0 UPGRADE NOTES
and this function is no longer needed to protect against XXE attacks.
- PGSQL / PDO PGSQL:
. The constant PG_VERSION_STR has now the same value as PG_VERSION, and thus
is deprecated.
. The constant PGSQL_LIBPQ_VERSION_STR has now the same value as
PGSQL_LIBPQ_VERSION, and thus is deprecated.
. Function aliases in the pgsql extension have been deprecated.
- Zip:
@@ -0,0 +1,15 @@
--TEST--
HT iterator should be destroyed if array becomes empty during array_splice
--FILE--
<?php
$a=[4];
$i = 0;
foreach ($a as &$r) {
var_dump($r);
$a = array_splice($a, 0);
if (++$i == 2) break;
}
?>
--EXPECT--
int(4)
int(4)
@@ -8,4 +8,4 @@ class A1 { }
?>
--EXPECTF--
Fatal error: Attribute::__construct(): Argument #1 ($flags) must must be of type int, string given in %s
Fatal error: Attribute::__construct(): Argument #1 ($flags) must be of type int, string given in %s
+31
View File
@@ -0,0 +1,31 @@
--TEST--
Bug #80781: Error handler that throws ErrorException infinite loop
--FILE--
<?php
function handle(int $severity, string $message, string $file, int $line): bool {
if((error_reporting() & $severity) !== 0) {
throw new \ErrorException($message, 0, $severity, $file, $line);
}
return true; // stfu operator
}
set_error_handler('handle');
function getPlugin(string $plugin) : bool{
return false;
}
$data = [];
$array = [];
if (isset($array[$data]) or getPlugin($data)) {
}
?>
--EXPECTF--
Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
+19
View File
@@ -0,0 +1,19 @@
--TEST--
Bug #80811: Function exec without $output but with $restult_code parameter crashes
--FILE--
<?php
echo 'Executing with all params:' . PHP_EOL;
exec('echo Something', output: $output, result_code: $resultCode);
var_dump($resultCode);
echo 'Executing without output param:' . PHP_EOL;
exec('echo Something', result_code: $resultCode);
var_dump($resultCode);
?>
--EXPECT--
Executing with all params:
int(0)
Executing without output param:
int(0)
@@ -0,0 +1,8 @@
--TEST--
call_user_func_array() + array_slice() + named arguments
--FILE--
<?php
call_user_func_array('func', array_slice(array: $a, 1, 2));
?>
--EXPECTF--
Fatal error: Cannot use positional argument after named argument in %s on line %d
@@ -22,6 +22,21 @@ function test() {
}
}
switch ($bar) {
case 0:
while ($xyz) {
continue 2; // INVALID
}
case 1:
while ($xyz) {
continue;
}
case 2:
while ($xyz) {
break 2;
}
}
while ($foo) {
switch ($bar) {
case 0:
@@ -42,8 +57,10 @@ function test() {
?>
--EXPECTF--
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in %s on line 6
Warning: "continue" targeting switch is equivalent to "break" in %s on line 6
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in %s on line 14
Warning: "continue 2" targeting switch is equivalent to "break 2". Did you mean to use "continue 3"? in %s on line 26
Warning: "continue 2" targeting switch is equivalent to "break 2" in %s on line 25
Warning: "continue 2" targeting switch is equivalent to "break 2". Did you mean to use "continue 3"? in %s on line 41
+30
View File
@@ -0,0 +1,30 @@
--TEST--
Dynamic static call of non-static method
--FILE--
<?php
class Foo {
function test1() {
$method = ['Foo', 'bar'];
$method();
}
function test2() {
$method = 'Foo::bar';
$method();
}
function __call($name, $args) {}
}
$x = new Foo;
try {
$x->test1();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
$x->test2();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Non-static method Foo::bar() cannot be called statically
Non-static method Foo::bar() cannot be called statically
@@ -0,0 +1,19 @@
--TEST--
Promoting require_once warning to exception
--FILE--
<?php
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new Exception($errstr);
}
set_error_handler("exception_error_handler");
try {
$results = require_once 'does-not-exist.php';
} catch (Exception $e) {
echo $e->getMessage(), "\n";
};
?>
--EXPECT--
require_once(does-not-exist.php): Failed to open stream: No such file or directory
@@ -0,0 +1,19 @@
--TEST--
Symtable cache slots may be acquired while cleaning symtable
--FILE--
<?php
class A {
// Must be larger than the symtable cache.
static $max = 40;
function __destruct() {
if (self::$max-- < 0) return;
$x = 'y';
$$x = new a;
}
}
new A;
?>
===DONE===
--EXPECT--
===DONE===
@@ -0,0 +1,30 @@
--TEST--
Union with anonymous class type
--FILE--
<?php
$a = new class {
public function testParam(self|string $a)
{
}
public function test(): self|string
{
return new \stdClass;
}
};
try {
$a->testParam(null);
} catch (\Throwable $e) {
echo $e->getMessage()."\n";
}
try {
$a->test();
} catch (\Throwable $e) {
echo $e->getMessage()."\n";
}
?>
--EXPECTF--
class@anonymous(): Argument #1 ($a) must be of type class@anonymous|string, null given, called in %s on line %d
class@anonymous::test(): Return value must be of type class@anonymous|string, stdClass returned
@@ -0,0 +1,17 @@
--TEST--
Infinite recursion in unlinked_instanceof()
--FILE--
<?php
interface I {}
spl_autoload_register(function() {
class X {
function test(): I {}
}
class Y extends X {
function test(): C {}
}
});
class C extends Z implements C {}
?>
--EXPECTF--
Fatal error: Declaration of Y::test(): C must be compatible with X::test(): I in %s on line %d
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "4.0.0"
#define ZEND_VERSION "4.0.5"
#define ZEND_ENGINE_3
+33 -3
View File
@@ -2455,10 +2455,40 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
for (i = 0; i < num_args; i++) {
if (ZEND_TYPE_HAS_CLASS(new_arg_info[i].type)) {
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(new_arg_info[i].type)
&& "Only simple classes are currently supported");
&& "Should be stored as simple name");
const char *class_name = ZEND_TYPE_LITERAL_NAME(new_arg_info[i].type);
ZEND_TYPE_SET_PTR(new_arg_info[i].type,
zend_string_init_interned(class_name, strlen(class_name), 1));
size_t num_types = 1;
const char *p = class_name;
while ((p = strchr(p, '|'))) {
num_types++;
p++;
}
if (num_types == 1) {
/* Simple class type */
ZEND_TYPE_SET_PTR(new_arg_info[i].type,
zend_string_init_interned(class_name, strlen(class_name), 1));
} else {
/* Union type */
zend_type_list *list = malloc(ZEND_TYPE_LIST_SIZE(num_types));
list->num_types = num_types;
ZEND_TYPE_SET_LIST(new_arg_info[i].type, list);
const char *start = class_name;
uint32_t j = 0;
while (true) {
const char *end = strchr(start, '|');
zend_string *str =
zend_string_init(start, end ? end - start : strlen(start), 1);
list->types[j] = (zend_type) ZEND_TYPE_INIT_CLASS(str, 0, 0);
if (!end) {
break;
}
start = end + 1;
j++;
}
}
}
}
}
+1 -1
View File
@@ -1099,7 +1099,7 @@ static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm
/* this setting may be not accurate */
chunk->free_tail = page_num;
}
if (free_chunk && chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE) {
if (free_chunk && chunk != heap->main_chunk && chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE) {
zend_mm_delete_chunk(heap, chunk);
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ void validate_attribute(zend_attribute *attr, uint32_t target, zend_class_entry
if (Z_TYPE(flags) != IS_LONG) {
zend_error_noreturn(E_ERROR,
"Attribute::__construct(): Argument #1 ($flags) must must be of type int, %s given",
"Attribute::__construct(): Argument #1 ($flags) must be of type int, %s given",
zend_zval_type_name(&flags)
);
}
+33 -11
View File
@@ -1167,7 +1167,15 @@ static zend_string *resolve_class_name(zend_string *name, zend_class_entry *scop
name = scope->parent->name;
}
}
return name;
/* The resolved name for anonymous classes contains null bytes. Cut off everything after the
* null byte here, to avoid larger parts of the type being omitted by printing code later. */
size_t len = strlen(ZSTR_VAL(name));
if (len != ZSTR_LEN(name)) {
ZEND_ASSERT(scope && "This should only happen with resolved types");
return zend_string_init(ZSTR_VAL(name), len, 0);
}
return zend_string_copy(name);
}
zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scope) {
@@ -1179,11 +1187,13 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop
if (ZEND_TYPE_HAS_CE(*list_type)) {
str = add_type_string(str, ZEND_TYPE_CE(*list_type)->name);
} else {
str = add_type_string(str, resolve_class_name(ZEND_TYPE_NAME(*list_type), scope));
zend_string *resolved = resolve_class_name(ZEND_TYPE_NAME(*list_type), scope);
str = add_type_string(str, resolved);
zend_string_release(resolved);
}
} ZEND_TYPE_LIST_FOREACH_END();
} else if (ZEND_TYPE_HAS_NAME(type)) {
str = zend_string_copy(resolve_class_name(ZEND_TYPE_NAME(type), scope));
str = resolve_class_name(ZEND_TYPE_NAME(type), scope);
} else if (ZEND_TYPE_HAS_CE(type)) {
str = zend_string_copy(ZEND_TYPE_CE(type)->name);
}
@@ -3868,6 +3878,7 @@ zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_stri
zend_string *name = zend_resolve_function_name(orig_name, args->child[1]->child[0]->attr, &is_fully_qualified);
if (zend_string_equals_literal_ci(name, "array_slice")
&& !zend_args_contain_unpack_or_named(list)
&& list->children == 3
&& list->child[1]->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(list->child[1]);
@@ -4881,15 +4892,26 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
if (CG(context).brk_cont_array[cur].is_switch) {
if (depth == 1) {
zend_error(E_WARNING,
"\"continue\" targeting switch is equivalent to \"break\". " \
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
depth + 1);
if (CG(context).brk_cont_array[cur].parent == -1) {
zend_error(E_WARNING,
"\"continue\" targeting switch is equivalent to \"break\"");
} else {
zend_error(E_WARNING,
"\"continue\" targeting switch is equivalent to \"break\". " \
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
depth + 1);
}
} else {
zend_error(E_WARNING,
"\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
depth, depth, depth + 1);
if (CG(context).brk_cont_array[cur].parent == -1) {
zend_error(E_WARNING,
"\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\"",
depth, depth);
} else {
zend_error(E_WARNING,
"\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
"Did you mean to use \"continue " ZEND_LONG_FMT "\"?",
depth, depth, depth + 1);
}
}
}
}
+3
View File
@@ -531,6 +531,9 @@ struct _zend_execute_data {
#define ZEND_CALL_DYNAMIC (1 << 25)
#define ZEND_CALL_MAY_HAVE_UNDEF (1 << 26)
#define ZEND_CALL_HAS_EXTRA_NAMED_PARAMS (1 << 27)
#define ZEND_CALL_OBSERVED (1 << 28) /* "fcall_begin" observer handler may set this flag */
/* to prevent optimization in RETURN handler and */
/* keep all local variables for "fcall_end" handler */
#define ZEND_CALL_SEND_ARG_BY_REF (1u << 31)
#define ZEND_CALL_NESTED_FUNCTION (ZEND_CALL_FUNCTION | ZEND_CALL_NESTED)
+4
View File
@@ -123,3 +123,7 @@ class ArithmeticError extends Error
class DivisionByZeroError extends ArithmeticError
{
}
class UnhandledMatchError extends Error
{
}
+6 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3699b51b31e509c11435845c7e0d35a2608dd268 */
* Stub hash: 2fa61163fb7db8d87b14f9cf9a42c3cd8093f2a6 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Throwable_getMessage, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -180,3 +180,8 @@ static const zend_function_entry class_ArithmeticError_methods[] = {
static const zend_function_entry class_DivisionByZeroError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_UnhandledMatchError_methods[] = {
ZEND_FE_END
};
+56 -25
View File
@@ -54,11 +54,11 @@
# define ZEND_VM_FP_GLOBAL_REG "%r14"
# define ZEND_VM_IP_GLOBAL_REG "%r15"
# elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__powerpc64__)
# define ZEND_VM_FP_GLOBAL_REG "r28"
# define ZEND_VM_IP_GLOBAL_REG "r29"
# define ZEND_VM_FP_GLOBAL_REG "r14"
# define ZEND_VM_IP_GLOBAL_REG "r15"
# elif defined(__IBMC__) && ZEND_GCC_VERSION >= 4002 && defined(__powerpc64__)
# define ZEND_VM_FP_GLOBAL_REG "r28"
# define ZEND_VM_IP_GLOBAL_REG "r29"
# define ZEND_VM_FP_GLOBAL_REG "r14"
# define ZEND_VM_IP_GLOBAL_REG "r15"
# elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__aarch64__)
# define ZEND_VM_FP_GLOBAL_REG "x27"
# define ZEND_VM_IP_GLOBAL_REG "x28"
@@ -763,6 +763,17 @@ static zend_bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg
}
#if ZEND_DEBUG
static bool can_convert_to_string(zval *zv) {
/* We don't call cast_object here, because this check must be side-effect free. As this
* is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept
* more than actually allowed here. */
if (Z_TYPE_P(zv) == IS_OBJECT) {
return Z_OBJ_HT_P(zv)->cast_object != zend_std_cast_object_tostring
|| Z_OBJCE_P(zv)->__tostring;
}
return Z_TYPE_P(zv) <= IS_STRING;
}
/* Used to sanity-check internal arginfo types without performing any actual type conversions. */
static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, zval *arg)
{
@@ -776,10 +787,7 @@ static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_m
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval)) {
return 1;
}
/* We don't call cast_object here, because this check must be side-effect free. As this
* is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept
* more than actually allowed here. */
if ((type_mask & MAY_BE_STRING) && (Z_TYPE_P(arg) < IS_STRING || Z_TYPE_P(arg) == IS_OBJECT)) {
if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) {
return 1;
}
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval)) {
@@ -943,6 +951,13 @@ ZEND_API zend_bool zend_value_instanceof_static(zval *zv) {
return instanceof_function(Z_OBJCE_P(zv), called_scope);
}
/* The cache_slot may only be NULL in debug builds, where arginfo verification of
* internal functions is enabled. Avoid unnecessary checks in release builds. */
#if ZEND_DEBUG
# define HAVE_CACHE_SLOT (cache_slot != NULL)
#else
# define HAVE_CACHE_SLOT 1
#endif
static zend_always_inline zend_bool zend_check_type_slow(
zend_type type, zval *arg, zend_reference *ref, void **cache_slot, zend_class_entry *scope,
@@ -954,31 +969,39 @@ static zend_always_inline zend_bool zend_check_type_slow(
if (ZEND_TYPE_HAS_LIST(type)) {
zend_type *list_type;
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(type), list_type) {
if (*cache_slot) {
if (HAVE_CACHE_SLOT && *cache_slot) {
ce = *cache_slot;
} else {
ce = zend_fetch_class(ZEND_TYPE_NAME(*list_type),
(ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
if (!ce) {
cache_slot++;
if (HAVE_CACHE_SLOT) {
cache_slot++;
}
continue;
}
*cache_slot = ce;
if (HAVE_CACHE_SLOT) {
*cache_slot = ce;
}
}
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
return 1;
}
cache_slot++;
if (HAVE_CACHE_SLOT) {
cache_slot++;
}
} ZEND_TYPE_LIST_FOREACH_END();
} else {
if (EXPECTED(*cache_slot)) {
if (EXPECTED(HAVE_CACHE_SLOT && *cache_slot)) {
ce = (zend_class_entry *) *cache_slot;
} else {
ce = zend_fetch_class(ZEND_TYPE_NAME(type), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
if (UNEXPECTED(!ce)) {
goto builtin_types;
}
*cache_slot = (void *) ce;
if (HAVE_CACHE_SLOT) {
*cache_slot = (void *) ce;
}
}
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
return 1;
@@ -1071,8 +1094,6 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ
for (i = 0; i < num_args; ++i) {
zend_arg_info *cur_arg_info;
void *dummy_cache_slot = NULL;
if (EXPECTED(i < fbc->common.num_args)) {
cur_arg_info = &fbc->common.arg_info[i];
} else if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
@@ -1082,7 +1103,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ
}
if (ZEND_TYPE_IS_SET(cur_arg_info->type)
&& UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, &dummy_cache_slot, fbc->common.scope, 0, /* is_internal */ 1))) {
&& UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, /* cache_slot */ NULL, fbc->common.scope, 0, /* is_internal */ 1))) {
return 0;
}
arg++;
@@ -1123,7 +1144,7 @@ static zend_always_inline zend_bool zend_internal_call_should_throw(zend_functio
static ZEND_COLD void zend_internal_call_arginfo_violation(zend_function *fbc)
{
zend_error(E_CORE_ERROR, "Arginfo / zpp mismatch during call of %s%s%s()",
zend_error(E_ERROR, "Arginfo / zpp mismatch during call of %s%s%s()",
fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
fbc->common.scope ? "::" : "",
ZSTR_VAL(fbc->common.function_name));
@@ -1207,8 +1228,6 @@ static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, con
static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
{
zend_internal_arg_info *ret_info = zf->internal_function.arg_info - 1;
void *dummy_cache_slot = NULL;
if (ZEND_TYPE_FULL_MASK(ret_info->type) & MAY_BE_VOID) {
if (UNEXPECTED(Z_TYPE_P(ret) != IS_NULL)) {
zend_verify_void_return_error(zf, zend_zval_type_name(ret), "");
@@ -1217,7 +1236,7 @@ static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
return 1;
}
if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &dummy_cache_slot, NULL, 1, /* is_internal */ 1))) {
if (UNEXPECTED(!zend_check_type(ret_info->type, ret, /* cache_slot */ NULL, NULL, 1, /* is_internal */ 1))) {
zend_verify_internal_return_error(zf, ret);
return 0;
}
@@ -3377,12 +3396,13 @@ ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_val
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
{
/* Clean before putting into the cache, since clean could call dtors,
* which could use the cached hash. Also do this before the check for
* available cache slots, as those may be used by a dtor as well. */
zend_symtable_clean(symbol_table);
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
zend_array_destroy(symbol_table);
} else {
/* clean before putting into the cache, since clean
could call dtors, which could use cached hash */
zend_symtable_clean(symbol_table);
*(EG(symtable_cache_ptr)++) = symbol_table;
}
}
@@ -3985,6 +4005,10 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s
if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) {
zend_non_static_method_call(fbc);
if (fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
zend_string_release_ex(fbc->common.function_name, 0);
zend_free_trampoline(fbc);
}
return NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) {
@@ -4109,6 +4133,10 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
}
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
zend_non_static_method_call(fbc);
if (fbc->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
zend_string_release_ex(fbc->common.function_name, 0);
zend_free_trampoline(fbc);
}
return NULL;
}
object_or_called_scope = called_scope;
@@ -4205,7 +4233,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval
already_compiled:
new_op_array = ZEND_FAKE_OP_ARRAY;
}
} else {
} else if (!EG(exception)) {
zend_message_dispatcher(
(type == ZEND_INCLUDE_ONCE) ?
ZMSG_FAILED_INCLUDE_FOPEN : ZMSG_FAILED_REQUIRE_FOPEN,
@@ -4551,6 +4579,9 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal
}
ZVAL_COPY_VALUE(arg, &default_value);
if (ZEND_ARG_SEND_MODE(arg_info) & ZEND_SEND_BY_REF) {
ZVAL_NEW_REF(arg, arg);
}
}
}
+4
View File
@@ -20,3 +20,7 @@ final class Generator implements Iterator
public function getReturn(): mixed {}
}
class ClosedGeneratorException extends Exception
{
}
+6 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 18d2bb68729ff622a5c0c124a8822f7ee882c2ec */
* Stub hash: 50044c6c8d2a162a988906c0b752a5fe28adb933 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Generator_rewind, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
@@ -46,3 +46,8 @@ static const zend_function_entry class_Generator_methods[] = {
ZEND_ME(Generator, getReturn, arginfo_class_Generator_getReturn, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_ClosedGeneratorException_methods[] = {
ZEND_FE_END
};
+1 -1
View File
@@ -1655,10 +1655,10 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
} else if (EXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) {
goto free_ht;
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
efree(HT_GET_DATA_ADDR(ht));
free_ht:
zend_hash_iterators_remove(ht);
FREE_HASHTABLE(ht);
}
+2 -1
View File
@@ -311,7 +311,8 @@ static zend_bool unlinked_instanceof(zend_class_entry *ce1, zend_class_entry *ce
zend_class_entry *ce = zend_lookup_class_ex(
ce1->interface_names[i].name, ce1->interface_names[i].lc_name,
ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (ce && unlinked_instanceof(ce, ce2)) {
/* Avoid recursing if class implements ifself. */
if (ce && ce != ce1 && unlinked_instanceof(ce, ce2)) {
return 1;
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ interface ArrayAccess
interface Serializable
{
/** @return string */
/** @return string|null */
public function serialize();
/** @return void */
+1 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 29a5ed0b859b0732074c81cf9d26047a6eb9059a */
* Stub hash: c6ef101bd3881348a74b60cecd22d1d7f80017c8 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, 0)
ZEND_END_ARG_INFO()
+3 -3
View File
@@ -177,7 +177,7 @@ static void yy_pop_state(void)
zend_stack_del_top(&SCNG(state_stack));
}
static void yy_scan_buffer(char *str, unsigned int len)
static void yy_scan_buffer(char *str, size_t len)
{
YYCURSOR = (YYCTYPE*)str;
YYLIMIT = YYCURSOR + len;
@@ -571,7 +571,7 @@ ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle)
}
}
SCNG(yy_start) = (unsigned char *)buf;
yy_scan_buffer(buf, (unsigned int)size);
yy_scan_buffer(buf, size);
} else {
zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
}
@@ -772,7 +772,7 @@ ZEND_API void zend_prepare_string_for_scanning(zval *str, const char *filename)
}
}
yy_scan_buffer(buf, (unsigned int)size);
yy_scan_buffer(buf, size);
new_compiled_filename = zend_string_init(filename, strlen(filename), 0);
zend_set_compiled_filename(new_compiled_filename);
+5
View File
@@ -1608,6 +1608,11 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
}
/* }}} */
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2)
{
return ZEND_UNCOMPARABLE;
}
ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */
{
int result;
+4
View File
@@ -213,6 +213,10 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2);
ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only);
ZEND_API void rebuild_object_properties(zend_object *zobj);
/* Handler for objects that cannot be meaningfully compared.
* Only objects with the same identity will be considered equal. */
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2);
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic);
+7 -3
View File
@@ -29,7 +29,7 @@
#define ZEND_OBSERVER_NOT_OBSERVED ((void *) 2)
#define ZEND_OBSERVABLE_FN(fn_flags) \
(!(fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE | ZEND_ACC_FAKE_CLOSURE)))
(!(fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
typedef struct _zend_observer_fcall_data {
// points after the last handler
@@ -220,7 +220,11 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_end(
first_observed_frame = NULL;
current_observed_frame = NULL;
} else {
current_observed_frame = execute_data->prev_execute_data;
zend_execute_data *ex = execute_data->prev_execute_data;
while (ex && !ex->func) {
ex = ex->prev_execute_data;
}
current_observed_frame = ex;
}
}
@@ -228,7 +232,7 @@ ZEND_API void zend_observer_fcall_end_all(void)
{
zend_execute_data *ex = current_observed_frame;
while (ex != NULL) {
if (ex->func->type != ZEND_INTERNAL_FUNCTION) {
if (ex->func && ex->func->type != ZEND_INTERNAL_FUNCTION) {
zend_observer_fcall_end(ex, NULL);
}
ex = ex->prev_execute_data;
+13
View File
@@ -195,6 +195,19 @@ static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool pers
}
}
static zend_always_inline zend_string *zend_string_separate(zend_string *s, bool persistent)
{
if (ZSTR_IS_INTERNED(s) || GC_REFCOUNT(s) > 1) {
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return zend_string_init(ZSTR_VAL(s), ZSTR_LEN(s), persistent);
}
zend_string_forget_hash_val(s);
return s;
}
static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent)
{
zend_string *ret;
+1 -1
View File
@@ -150,7 +150,7 @@ typedef struct {
/* Type mask excluding the flags above. */
#define _ZEND_TYPE_MAY_BE_MASK ((1u << 20) - 1)
/* Must have same value as MAY_BE_NULL */
#define _ZEND_TYPE_NULLABLE_BIT 0x2
#define _ZEND_TYPE_NULLABLE_BIT 0x2u
#define ZEND_TYPE_IS_SET(t) \
(((t).type_mask & _ZEND_TYPE_MASK) != 0)
+2 -2
View File
@@ -4185,7 +4185,7 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
retval_ref = retval_ptr = EX_VAR(opline->result.var);
} else if (OP1_TYPE == IS_VAR) {
if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
retval_ptr = Z_INDIRECT_P(retval_ptr);
retval_ref = retval_ptr = Z_INDIRECT_P(retval_ptr);
}
ZVAL_DEREF(retval_ptr);
} else if (OP1_TYPE == IS_CV) {
@@ -4269,7 +4269,7 @@ ZEND_VM_INLINE_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY, SPEC(OBSERVER))
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
+15 -15
View File
@@ -4047,7 +4047,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_CONST_
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -4124,7 +4124,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_OBSER
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -9723,7 +9723,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYP
retval_ref = retval_ptr = EX_VAR(opline->result.var);
} else if (IS_CONST == IS_VAR) {
if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
retval_ptr = Z_INDIRECT_P(retval_ptr);
retval_ref = retval_ptr = Z_INDIRECT_P(retval_ptr);
}
ZVAL_DEREF(retval_ptr);
} else if (IS_CONST == IS_CV) {
@@ -18568,7 +18568,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_TMP_HA
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -20077,7 +20077,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN
retval_ref = retval_ptr = EX_VAR(opline->result.var);
} else if (IS_TMP_VAR == IS_VAR) {
if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
retval_ptr = Z_INDIRECT_P(retval_ptr);
retval_ref = retval_ptr = Z_INDIRECT_P(retval_ptr);
}
ZVAL_DEREF(retval_ptr);
} else if (IS_TMP_VAR == IS_CV) {
@@ -21140,7 +21140,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HA
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -27692,7 +27692,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN
retval_ref = retval_ptr = EX_VAR(opline->result.var);
} else if (IS_VAR == IS_VAR) {
if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
retval_ptr = Z_INDIRECT_P(retval_ptr);
retval_ref = retval_ptr = Z_INDIRECT_P(retval_ptr);
}
ZVAL_DEREF(retval_ptr);
} else if (IS_VAR == IS_CV) {
@@ -34892,7 +34892,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED
retval_ref = retval_ptr = EX_VAR(opline->result.var);
} else if (IS_UNUSED == IS_VAR) {
if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
retval_ptr = Z_INDIRECT_P(retval_ptr);
retval_ref = retval_ptr = Z_INDIRECT_P(retval_ptr);
}
ZVAL_DEREF(retval_ptr);
} else if (IS_UNUSED == IS_CV) {
@@ -37678,7 +37678,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_CV_HAN
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -46594,7 +46594,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU
retval_ref = retval_ptr = EX_VAR(opline->result.var);
} else if (IS_CV == IS_VAR) {
if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
retval_ptr = Z_INDIRECT_P(retval_ptr);
retval_ref = retval_ptr = Z_INDIRECT_P(retval_ptr);
}
ZVAL_DEREF(retval_ptr);
} else if (IS_CV == IS_CV) {
@@ -54770,7 +54770,7 @@ zend_leave_helper_SPEC_LABEL:
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -54848,7 +54848,7 @@ zend_leave_helper_SPEC_LABEL:
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -56385,7 +56385,7 @@ zend_leave_helper_SPEC_LABEL:
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -56686,7 +56686,7 @@ zend_leave_helper_SPEC_LABEL:
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
@@ -57803,7 +57803,7 @@ zend_leave_helper_SPEC_LABEL:
do {
if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
if (EXPECTED(!(EX_CALL_INFO() & (ZEND_CALL_CODE|ZEND_CALL_OBSERVED)))) {
zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
ZVAL_COPY_VALUE(return_value, retval_ptr);
if (GC_MAY_LEAK(ref)) {
+1 -1
View File
@@ -79,7 +79,7 @@ jobs:
CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC'
LDFLAGS='-fsanitize=undefined,address'
runTestsParameters: --asan
timeoutInMinutes: 310
timeoutInMinutes: 360
- template: azure/msan_job.yml
parameters:
configurationName: DEBUG_ZTS_MSAN
+5 -6
View File
@@ -51,8 +51,7 @@ jobs:
- script: |
git clone https://github.com/laravel/framework.git --branch=master --depth=1
cd framework
#php7.3 /usr/bin/composer require "doctrine/dbal:^3.0" --no-interaction
php7.3 /usr/bin/composer install --no-progress
php7.4 /usr/bin/composer install --no-progress
# Hack to disable a test that hangs on azure
sed -i 's/PHP_OS/"Darwin"/' tests/Filesystem/FilesystemTest.php
export USE_ZEND_ALLOC=0
@@ -65,8 +64,8 @@ jobs:
- script: |
git clone https://github.com/symfony/symfony.git --depth=1
cd symfony
php7.3 /usr/bin/composer install --no-progress
php7.3 ./phpunit install
php7.4 /usr/bin/composer install --no-progress
php7.4 ./phpunit install
export USE_ZEND_ALLOC=0
export USE_TRACKED_ALLOC=1
export ASAN_OPTIONS=exitcode=139
@@ -96,14 +95,14 @@ jobs:
export USE_ZEND_ALLOC=0
export USE_TRACKED_ALLOC=1
export ASAN_OPTIONS=exitcode=139
php7.3 /usr/bin/composer install --no-progress
php7.4 /usr/bin/composer install --no-progress
php ./phpunit
if [ $? -gt 128 ]; then
exit 1
fi
displayName: 'Test PHPUnit'
- script: |
php7.3 /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress
php7.4 /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress
cd symfony_demo
export USE_ZEND_ALLOC=0
export USE_TRACKED_ALLOC=1
+1 -1
View File
@@ -116,6 +116,7 @@ clean:
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
rm -f ext/opcache/jit/zend_jit_x86.c
distclean: clean
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h
@@ -124,7 +125,6 @@ distclean: clean
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 sapi/phpdbg/phpdbg.1 ext/phar/phar.1 ext/phar/phar.phar.1
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/phar/phar.phar ext/phar/phar.php
rm -f ext/opcache/jit/zend_jit_x86.c
if test "$(srcdir)" != "$(builddir)"; then \
rm -f ext/phar/phar/phar.inc; \
fi
+597 -73
View File
@@ -111,7 +111,7 @@ class SimpleType {
$this->isBuiltin = $isBuiltin;
}
public static function fromNode(Node $node) {
public static function fromNode(Node $node): SimpleType {
if ($node instanceof Node\Name) {
if ($node->toLowerString() === 'static') {
// PHP internally considers "static" a builtin type.
@@ -127,11 +127,48 @@ class SimpleType {
throw new Exception("Unexpected node type");
}
public function isNull() {
public static function fromPhpDoc(string $type): SimpleType
{
switch (strtolower($type)) {
case "void":
case "null":
case "false":
case "bool":
case "int":
case "float":
case "string":
case "array":
case "iterable":
case "object":
case "resource":
case "mixed":
case "self":
case "static":
return new SimpleType(strtolower($type), true);
}
if (strpos($type, "[]") !== false) {
return new SimpleType("array", true);
}
return new SimpleType($type, false);
}
public static function null(): SimpleType
{
return new SimpleType("null", true);
}
public static function void(): SimpleType
{
return new SimpleType("void", true);
}
public function isNull(): bool {
return $this->isBuiltin && $this->name === 'null';
}
public function toTypeCode() {
public function toTypeCode(): string {
assert($this->isBuiltin);
switch (strtolower($this->name)) {
case "bool":
@@ -209,19 +246,30 @@ class Type {
$this->types = $types;
}
public static function fromNode(Node $node) {
public static function fromNode(Node $node): Type {
if ($node instanceof Node\UnionType) {
return new Type(array_map(['SimpleType', 'fromNode'], $node->types));
}
if ($node instanceof Node\NullableType) {
return new Type([
SimpleType::fromNode($node->type),
new SimpleType('null', true),
SimpleType::null(),
]);
}
return new Type([SimpleType::fromNode($node)]);
}
public static function fromPhpDoc(string $phpDocType) {
$types = explode("|", $phpDocType);
$simpleTypes = [];
foreach ($types as $type) {
$simpleTypes[] = SimpleType::fromPhpDoc($type);
}
return new Type($simpleTypes);
}
public function isNullable(): bool {
foreach ($this->types as $type) {
if ($type->isNull()) {
@@ -245,20 +293,17 @@ class Type {
return null;
}
public function tryToRepresentableType(): ?RepresentableType {
$classType = null;
public function toArginfoType(): ?ArginfoType {
$classTypes = [];
$builtinTypes = [];
foreach ($this->types as $type) {
if ($type->isBuiltin) {
$builtinTypes[] = $type;
} else if ($classType === null) {
$classType = $type;
} else {
// We can only represent a single class type.
return null;
$classTypes[] = $type;
}
}
return new RepresentableType($classType, $builtinTypes);
return new ArginfoType($classTypes, $builtinTypes);
}
public static function equals(?Type $a, ?Type $b): bool {
@@ -278,20 +323,45 @@ class Type {
return true;
}
public function __toString() {
if ($this->types === null) {
return 'mixed';
}
return implode('|', array_map(
function ($type) { return $type->name; },
$this->types)
);
}
}
class RepresentableType {
/** @var ?SimpleType $classType */
public $classType;
/** @var SimpleType[] $builtinTypes */
public $builtinTypes;
class ArginfoType {
/** @var ClassType[] $classTypes */
public $classTypes;
public function __construct(?SimpleType $classType, array $builtinTypes) {
$this->classType = $classType;
/** @var SimpleType[] $builtinTypes */
private $builtinTypes;
public function __construct(array $classTypes, array $builtinTypes) {
$this->classTypes = $classTypes;
$this->builtinTypes = $builtinTypes;
}
public function hasClassType(): bool {
return !empty($this->classTypes);
}
public function toClassTypeString(): string {
return implode('|', array_map(function(SimpleType $type) {
return $type->toEscapedName();
}, $this->classTypes));
}
public function toTypeMask(): string {
if (empty($this->builtinTypes)) {
return '0';
}
return implode('|', array_map(function(SimpleType $type) {
return $type->toTypeMask();
}, $this->builtinTypes));
@@ -311,14 +381,17 @@ class ArgInfo {
public $isVariadic;
/** @var Type|null */
public $type;
/** @var Type|null */
public $phpDocType;
/** @var string|null */
public $defaultValue;
public function __construct(string $name, int $sendBy, bool $isVariadic, ?Type $type, ?string $defaultValue) {
public function __construct(string $name, int $sendBy, bool $isVariadic, ?Type $type, ?Type $phpDocType, ?string $defaultValue) {
$this->name = $name;
$this->sendBy = $sendBy;
$this->isVariadic = $isVariadic;
$this->type = $type;
$this->phpDocType = $phpDocType;
$this->defaultValue = $defaultValue;
}
@@ -342,22 +415,52 @@ class ArgInfo {
throw new Exception("Invalid sendBy value");
}
public function hasDefaultValue(): bool {
public function getMethodSynopsisType(): Type {
if ($this->type) {
return $this->type;
}
if ($this->phpDocType) {
return $this->phpDocType;
}
throw new Exception("A parameter must have a type");
}
public function hasProperDefaultValue(): bool {
return $this->defaultValue !== null && $this->defaultValue !== "UNKNOWN";
}
public function getDefaultValueString(): string {
if ($this->hasDefaultValue()) {
public function getDefaultValueAsArginfoString(): string {
if ($this->hasProperDefaultValue()) {
return '"' . addslashes($this->defaultValue) . '"';
}
return "NULL";
}
public function getDefaultValueAsMethodSynopsisString(): ?string {
if ($this->defaultValue === null) {
return null;
}
switch ($this->defaultValue) {
case 'UNKNOWN':
return null;
case 'false':
case 'true':
case 'null':
return "&{$this->defaultValue};";
}
return $this->defaultValue;
}
}
interface FunctionOrMethodName {
public function getDeclaration(): string;
public function getArgInfoName(): string;
public function getMethodSynopsisFilename(): string;
public function __toString(): string;
public function isMethod(): bool;
public function isConstructor(): bool;
@@ -399,6 +502,10 @@ class FunctionName implements FunctionOrMethodName {
return "arginfo_$underscoreName";
}
public function getMethodSynopsisFilename(): string {
return implode('_', $this->name->parts);
}
public function __toString(): string {
return $this->name->toString();
}
@@ -439,6 +546,10 @@ class MethodName implements FunctionOrMethodName {
return "arginfo_class_{$this->getDeclarationClassName()}_{$this->methodName}";
}
public function getMethodSynopsisFilename(): string {
return $this->getDeclarationClassName() . "_{$this->methodName}";
}
public function __toString(): string {
return "$this->className::$this->methodName";
}
@@ -461,16 +572,23 @@ class ReturnInfo {
public $byRef;
/** @var Type|null */
public $type;
/** @var Type|null */
public $phpDocType;
public function __construct(bool $byRef, ?Type $type) {
public function __construct(bool $byRef, ?Type $type, ?Type $phpDocType) {
$this->byRef = $byRef;
$this->type = $type;
$this->phpDocType = $phpDocType;
}
public function equals(ReturnInfo $other): bool {
return $this->byRef === $other->byRef
&& Type::equals($this->type, $other->type);
}
public function getMethodSynopsisType(): ?Type {
return $this->type ?? $this->phpDocType;
}
}
class FuncInfo {
@@ -538,6 +656,47 @@ class FuncInfo {
return !($this->flags & Class_::MODIFIER_STATIC) && $this->isMethod() && !$this->name->isConstructor();
}
/** @return string[] */
public function getModifierNames(): array
{
if (!$this->isMethod()) {
return [];
}
$result = [];
if ($this->flags & Class_::MODIFIER_FINAL) {
$result[] = "final";
} elseif ($this->flags & Class_::MODIFIER_ABSTRACT && $this->classFlags & ~Class_::MODIFIER_ABSTRACT) {
$result[] = "abstract";
}
if ($this->flags & Class_::MODIFIER_PROTECTED) {
$result[] = "protected";
} elseif ($this->flags & Class_::MODIFIER_PRIVATE) {
$result[] = "private";
} else {
$result[] = "public";
}
if ($this->flags & Class_::MODIFIER_STATIC) {
$result[] = "static";
}
return $result;
}
public function hasParamWithUnknownDefaultValue(): bool
{
foreach ($this->args as $arg) {
if ($arg->defaultValue && !$arg->hasProperDefaultValue()) {
return true;
}
}
return false;
}
public function equalsApartFromName(FuncInfo $other): bool {
if (count($this->args) !== count($other->args)) {
return false;
@@ -583,13 +742,13 @@ class FuncInfo {
return sprintf(
"\tZEND_MALIAS(%s, %s, %s, %s, %s)\n",
$this->alias->getDeclarationClassName(), $this->name->methodName,
$this->alias->methodName, $this->getArgInfoName(), $this->getFlagsAsString()
$this->alias->methodName, $this->getArgInfoName(), $this->getFlagsAsArginfoString()
);
} else if ($this->alias instanceof FunctionName) {
return sprintf(
"\tZEND_ME_MAPPING(%s, %s, %s, %s)\n",
$this->name->methodName, $this->alias->getNonNamespacedName(),
$this->getArgInfoName(), $this->getFlagsAsString()
$this->getArgInfoName(), $this->getFlagsAsArginfoString()
);
} else {
throw new Error("Cannot happen");
@@ -600,14 +759,14 @@ class FuncInfo {
return sprintf(
"\tZEND_ABSTRACT_ME_WITH_FLAGS(%s, %s, %s, %s)\n",
$declarationClassName, $this->name->methodName, $this->getArgInfoName(),
$this->getFlagsAsString()
$this->getFlagsAsArginfoString()
);
}
return sprintf(
"\tZEND_ME(%s, %s, %s, %s)\n",
$declarationClassName, $this->name->methodName, $this->getArgInfoName(),
$this->getFlagsAsString()
$this->getFlagsAsArginfoString()
);
}
} else if ($this->name instanceof FunctionName) {
@@ -634,9 +793,10 @@ class FuncInfo {
}
if ($namespace) {
// Render A\B as "A\\B" in C strings for namespaces
return sprintf(
"\tZEND_NS_FE(\"%s\", %s, %s)\n",
$namespace, $declarationName, $this->getArgInfoName());
addslashes($namespace), $declarationName, $this->getArgInfoName());
} else {
return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
}
@@ -645,7 +805,7 @@ class FuncInfo {
}
}
private function getFlagsAsString(): string
private function getFlagsAsArginfoString(): string
{
$flags = "ZEND_ACC_PUBLIC";
if ($this->flags & Class_::MODIFIER_PROTECTED) {
@@ -673,6 +833,114 @@ class FuncInfo {
return $flags;
}
/**
* @param FuncInfo[] $funcMap
* @param FuncInfo[] $aliasMap
* @throws Exception
*/
public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?string {
$doc = new DOMDocument();
$doc->formatOutput = true;
$methodSynopsis = $this->getMethodSynopsisElement($funcMap, $aliasMap, $doc);
if (!$methodSynopsis) {
return null;
}
$doc->appendChild($methodSynopsis);
return $doc->saveXML();
}
/**
* @param FuncInfo[] $funcMap
* @param FuncInfo[] $aliasMap
* @throws Exception
*/
public function getMethodSynopsisElement(array $funcMap, array $aliasMap, DOMDocument $doc): ?DOMElement {
if ($this->hasParamWithUnknownDefaultValue()) {
return null;
}
if ($this->name->isConstructor()) {
$synopsisType = "constructorsynopsis";
} elseif ($this->name->isDestructor()) {
$synopsisType = "destructorsynopsis";
} else {
$synopsisType = "methodsynopsis";
}
$methodSynopsis = $doc->createElement($synopsisType);
$aliasedFunc = $this->aliasType === "alias" && isset($funcMap[$this->alias->__toString()]) ? $funcMap[$this->alias->__toString()] : null;
$aliasFunc = $aliasMap[$this->name->__toString()] ?? null;
if (($this->aliasType === "alias" && $aliasedFunc !== null && $aliasedFunc->isMethod() !== $this->isMethod()) ||
($aliasFunc !== null && $aliasFunc->isMethod() !== $this->isMethod())
) {
$role = $doc->createAttribute("role");
$role->value = $this->isMethod() ? "oop" : "procedural";
$methodSynopsis->appendChild($role);
}
$methodSynopsis->appendChild(new DOMText("\n "));
foreach ($this->getModifierNames() as $modifierString) {
$modifierElement = $doc->createElement('modifier', $modifierString);
$methodSynopsis->appendChild($modifierElement);
$methodSynopsis->appendChild(new DOMText(" "));
}
$returnType = $this->return->getMethodSynopsisType();
if ($returnType) {
$this->appendMethodSynopsisTypeToElement($doc, $methodSynopsis, $returnType);
}
$methodname = $doc->createElement('methodname', $this->name->__toString());
$methodSynopsis->appendChild($methodname);
if (empty($this->args)) {
$methodSynopsis->appendChild(new DOMText("\n "));
$void = $doc->createElement('void');
$methodSynopsis->appendChild($void);
} else {
foreach ($this->args as $arg) {
$methodSynopsis->appendChild(new DOMText("\n "));
$methodparam = $doc->createElement('methodparam');
if ($arg->defaultValue !== null) {
$methodparam->setAttribute("choice", "opt");
}
if ($arg->isVariadic) {
$methodparam->setAttribute("rep", "repeat");
}
$methodSynopsis->appendChild($methodparam);
$this->appendMethodSynopsisTypeToElement($doc, $methodparam, $arg->getMethodSynopsisType());
$parameter = $doc->createElement('parameter', $arg->name);
if ($arg->sendBy !== ArgInfo::SEND_BY_VAL) {
$parameter->setAttribute("role", "reference");
}
$methodparam->appendChild($parameter);
$defaultValue = $arg->getDefaultValueAsMethodSynopsisString();
if ($defaultValue !== null) {
$initializer = $doc->createElement('initializer');
if (preg_match('/^[a-zA-Z_][a-zA-Z_0-9]*$/', $defaultValue)) {
$constant = $doc->createElement('constant', $defaultValue);
$initializer->appendChild($constant);
} else {
$initializer->nodeValue = $defaultValue;
}
$methodparam->appendChild($initializer);
}
}
}
$methodSynopsis->appendChild(new DOMText("\n "));
return $methodSynopsis;
}
public function discardInfoForOldPhpVersions(): void {
$this->return->type = null;
foreach ($this->args as $arg) {
@@ -680,6 +948,22 @@ class FuncInfo {
$arg->defaultValue = null;
}
}
private function appendMethodSynopsisTypeToElement(DOMDocument $doc, DOMElement $elementToAppend, Type $type) {
if (count($type->types) > 1) {
$typeElement = $doc->createElement('type');
$typeElement->setAttribute("class", "union");
foreach ($type->types as $type) {
$unionTypeElement = $doc->createElement('type', $type->name);
$typeElement->appendChild($unionTypeElement);
}
} else {
$typeElement = $doc->createElement('type', $type->types[0]->name);
}
$elementToAppend->appendChild($typeElement);
}
}
class ClassInfo {
@@ -736,8 +1020,26 @@ class DocCommentTag {
return $this->value;
}
public function getVariableName(): string {
public function getType(): string {
$value = $this->getValue();
$matches = [];
if ($this->name === "param") {
preg_match('/^\s*([\w\|\\\\\[\]]+)\s*\$\w+.*$/', $value, $matches);
} elseif ($this->name === "return") {
preg_match('/^\s*([\w\|\\\\\[\]]+)\s*$/', $value, $matches);
}
if (isset($matches[1]) === false) {
throw new Exception("@$this->name doesn't contain a type or has an invalid format \"$value\"");
}
return $matches[1];
}
public function getVariableName(): string {
$value = $this->value;
if ($value === null || strlen($value) === 0) {
throw new Exception("@$this->name doesn't have any value");
}
@@ -745,13 +1047,13 @@ class DocCommentTag {
$matches = [];
if ($this->name === "param") {
preg_match('/^\s*[\w\|\\\\]+\s*\$(\w+).*$/', $value, $matches);
preg_match('/^\s*[\w\|\\\\\[\]]+\s*\$(\w+).*$/', $value, $matches);
} elseif ($this->name === "prefer-ref") {
preg_match('/^\s*\$(\w+).*$/', $value, $matches);
}
if (isset($matches[1]) === false) {
throw new Exception("@$this->name doesn't contain variable name or has an invalid format \"$value\"");
throw new Exception("@$this->name doesn't contain a variable name or has an invalid format \"$value\"");
}
return $matches[1];
@@ -786,7 +1088,7 @@ function parseFunctionLike(
$alias = null;
$isDeprecated = false;
$verify = true;
$haveDocReturnType = false;
$docReturnType = null;
$docParamTypes = [];
if ($comment) {
@@ -811,9 +1113,9 @@ function parseFunctionLike(
} else if ($tag->name === 'no-verify') {
$verify = false;
} else if ($tag->name === 'return') {
$haveDocReturnType = true;
$docReturnType = $tag->getType();
} else if ($tag->name === 'param') {
$docParamTypes[$tag->getVariableName()] = true;
$docParamTypes[$tag->getVariableName()] = $tag->getType();
}
}
}
@@ -867,6 +1169,7 @@ function parseFunctionLike(
$sendBy,
$param->variadic,
$type,
isset($docParamTypes[$varName]) ? Type::fromPhpDoc($docParamTypes[$varName]) : null,
$param->default ? $prettyPrinter->prettyPrintExpr($param->default) : null
);
if (!$param->default && !$param->variadic) {
@@ -879,13 +1182,14 @@ function parseFunctionLike(
}
$returnType = $func->getReturnType();
if ($returnType === null && !$haveDocReturnType && !$name->isConstructor() && !$name->isDestructor()) {
if ($returnType === null && $docReturnType === null && !$name->isConstructor() && !$name->isDestructor()) {
throw new Exception("Missing return type for function $name()");
}
$return = new ReturnInfo(
$func->returnsByRef(),
$returnType ? Type::fromNode($returnType) : null
$returnType ? Type::fromNode($returnType) : null,
$docReturnType ? Type::fromPhpDoc($docReturnType) : null
);
return new FuncInfo(
@@ -1070,24 +1374,23 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
$simpleReturnType->toEscapedName(), $returnType->isNullable()
);
}
} else if (null !== $representableType = $returnType->tryToRepresentableType()) {
if ($representableType->classType !== null) {
} else {
$arginfoType = $returnType->toArginfoType();
if ($arginfoType->hasClassType()) {
$code .= sprintf(
"ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(%s, %d, %d, %s, %s)\n",
$funcInfo->getArgInfoName(), $funcInfo->return->byRef,
$funcInfo->numRequiredArgs,
$representableType->classType->toEscapedName(), $representableType->toTypeMask()
$arginfoType->toClassTypeString(), $arginfoType->toTypeMask()
);
} else {
$code .= sprintf(
"ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(%s, %d, %d, %s)\n",
$funcInfo->getArgInfoName(), $funcInfo->return->byRef,
$funcInfo->numRequiredArgs,
$representableType->toTypeMask()
$arginfoType->toTypeMask()
);
}
} else {
throw new Exception('Unimplemented');
}
} else {
$code .= sprintf(
@@ -1098,7 +1401,7 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
foreach ($funcInfo->args as $argInfo) {
$argKind = $argInfo->isVariadic ? "ARG_VARIADIC" : "ARG";
$argDefaultKind = $argInfo->hasDefaultValue() ? "_WITH_DEFAULT_VALUE" : "";
$argDefaultKind = $argInfo->hasProperDefaultValue() ? "_WITH_DEFAULT_VALUE" : "";
$argType = $argInfo->type;
if ($argType !== null) {
if (null !== $simpleArgType = $argType->tryToSimpleType()) {
@@ -1107,41 +1410,39 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
"\tZEND_%s_TYPE_INFO%s(%s, %s, %s, %d%s)\n",
$argKind, $argDefaultKind, $argInfo->getSendByString(), $argInfo->name,
$simpleArgType->toTypeCode(), $argType->isNullable(),
$argInfo->hasDefaultValue() ? ", " . $argInfo->getDefaultValueString() : ""
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
);
} else {
$code .= sprintf(
"\tZEND_%s_OBJ_INFO%s(%s, %s, %s, %d%s)\n",
$argKind,$argDefaultKind, $argInfo->getSendByString(), $argInfo->name,
$simpleArgType->toEscapedName(), $argType->isNullable(),
$argInfo->hasDefaultValue() ? ", " . $argInfo->getDefaultValueString() : ""
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
);
}
} else if (null !== $representableType = $argType->tryToRepresentableType()) {
if ($representableType->classType !== null) {
} else {
$arginfoType = $argType->toArginfoType();
if ($arginfoType->hasClassType()) {
$code .= sprintf(
"\tZEND_%s_OBJ_TYPE_MASK(%s, %s, %s, %s, %s)\n",
$argKind, $argInfo->getSendByString(), $argInfo->name,
$representableType->classType->toEscapedName(),
$representableType->toTypeMask(),
$argInfo->getDefaultValueString()
$arginfoType->toClassTypeString(), $arginfoType->toTypeMask(),
$argInfo->getDefaultValueAsArginfoString()
);
} else {
$code .= sprintf(
"\tZEND_%s_TYPE_MASK(%s, %s, %s, %s)\n",
$argKind, $argInfo->getSendByString(), $argInfo->name,
$representableType->toTypeMask(),
$argInfo->getDefaultValueString()
$arginfoType->toTypeMask(),
$argInfo->getDefaultValueAsArginfoString()
);
}
} else {
throw new Exception('Unimplemented');
}
} else {
$code .= sprintf(
"\tZEND_%s_INFO%s(%s, %s%s)\n",
$argKind, $argDefaultKind, $argInfo->getSendByString(), $argInfo->name,
$argInfo->hasDefaultValue() ? ", " . $argInfo->getDefaultValueString() : ""
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
);
}
}
@@ -1253,6 +1554,194 @@ function generateFunctionEntries(?Name $className, array $funcInfos): string {
return $code;
}
/**
* @param FuncInfo[] $funcMap
* @param FuncInfo[] $aliasMap
* @return array<string, string>
*/
function generateMethodSynopses(array $funcMap, array $aliasMap): array {
$result = [];
foreach ($funcMap as $funcInfo) {
$methodSynopsis = $funcInfo->getMethodSynopsisDocument($funcMap, $aliasMap);
if ($methodSynopsis !== null) {
$result[$funcInfo->name->getMethodSynopsisFilename() . ".xml"] = $methodSynopsis;
}
}
return $result;
}
/**
* @param FuncInfo[] $funcMap
* @param FuncInfo[] $aliasMap
* @return array<string, string>
*/
function replaceMethodSynopses(string $targetDirectory, array $funcMap, array $aliasMap): array {
$methodSynopses = [];
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($targetDirectory),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($it as $file) {
$pathName = $file->getPathName();
if (!preg_match('/\.xml$/i', $pathName)) {
continue;
}
$xml = file_get_contents($pathName);
if ($xml === false) {
continue;
}
if (stripos($xml, "<methodsynopsis") === false && stripos($xml, "<constructorsynopsis") === false && stripos($xml, "<destructorsynopsis") === false) {
continue;
}
$replacedXml = preg_replace("/&([A-Za-z0-9._{}%-]+?;)/", "REPLACED-ENTITY-$1", $xml);
$doc = new DOMDocument();
$doc->formatOutput = false;
$doc->preserveWhiteSpace = true;
$doc->validateOnParse = true;
$success = $doc->loadXML($replacedXml);
if (!$success) {
echo "Failed opening $pathName\n";
continue;
}
$docComparator = new DOMDocument();
$docComparator->preserveWhiteSpace = false;
$docComparator->formatOutput = true;
$methodSynopsisElements = [];
foreach ($doc->getElementsByTagName("constructorsynopsis") as $element) {
$methodSynopsisElements[] = $element;
}
foreach ($doc->getElementsByTagName("destructorsynopsis") as $element) {
$methodSynopsisElements[] = $element;
}
foreach ($doc->getElementsByTagName("methodsynopsis") as $element) {
$methodSynopsisElements[] = $element;
}
foreach ($methodSynopsisElements as $methodSynopsis) {
if (!$methodSynopsis instanceof DOMElement) {
continue;
}
$list = $methodSynopsis->getElementsByTagName("methodname");
$item = $list->item(0);
if (!$item instanceof DOMElement) {
continue;
}
$funcName = $item->textContent;
if (!isset($funcMap[$funcName])) {
continue;
}
$funcInfo = $funcMap[$funcName];
$newMethodSynopsis = $funcInfo->getMethodSynopsisElement($funcMap, $aliasMap, $doc);
if ($newMethodSynopsis === null) {
continue;
}
// Retrieve current signature
$params = [];
$list = $methodSynopsis->getElementsByTagName("methodparam");
foreach ($list as $i => $item) {
if (!$item instanceof DOMElement) {
continue;
}
$paramList = $item->getElementsByTagName("parameter");
if ($paramList->count() !== 1) {
continue;
}
$paramName = $paramList->item(0)->textContent;
$paramTypes = [];
$paramList = $item->getElementsByTagName("type");
foreach ($paramList as $type) {
if (!$type instanceof DOMElement) {
continue;
}
$paramTypes[] = $type->textContent;
}
$params[$paramName] = ["index" => $i, "type" => $paramTypes];
}
// Check if there is any change - short circuit if there is not any.
$xml1 = $doc->saveXML($methodSynopsis);
$xml1 = preg_replace("/&([A-Za-z0-9._{}%-]+?;)/", "REPLACED-ENTITY-$1", $xml1);
$docComparator->loadXML($xml1);
$xml1 = $docComparator->saveXML();
$methodSynopsis->parentNode->replaceChild($newMethodSynopsis, $methodSynopsis);
$xml2 = $doc->saveXML($newMethodSynopsis);
$xml2 = preg_replace("/&([A-Za-z0-9._{}%-]+?;)/", "REPLACED-ENTITY-$1", $xml2);
$docComparator->loadXML($xml2);
$xml2 = $docComparator->saveXML();
if ($xml1 === $xml2) {
continue;
}
// Update parameter references
$paramList = $doc->getElementsByTagName("parameter");
/** @var DOMElement $paramElement */
foreach ($paramList as $paramElement) {
if ($paramElement->parentNode && $paramElement->parentNode->nodeName === "methodparam") {
continue;
}
$name = $paramElement->textContent;
if (!isset($params[$name])) {
continue;
}
$index = $params[$name]["index"];
if (!isset($funcInfo->args[$index])) {
continue;
}
$paramElement->textContent = $funcInfo->args[$index]->name;
}
// Return the updated XML
$replacedXml = $doc->saveXML();
$replacedXml = preg_replace(
[
"/REPLACED-ENTITY-([A-Za-z0-9._{}%-]+?;)/",
"/<refentry\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
"/<refentry\s+xmlns=\"([a-z0-9.:\/]+)\"\s+xmlns:xlink=\"([a-z0-9.:\/]+)\"\s+xml:id=\"([a-z0-9._-]+)\"\s*>/i",
],
[
"&$1",
"<refentry xml:id=\"$2\" xmlns=\"$1\">",
"<refentry xml:id=\"$3\" xmlns=\"$1\" xmlns:xlink=\"$2\">",
],
$replacedXml
);
$methodSynopses[$pathName] = $replacedXml;
}
}
return $methodSynopses;
}
function installPhpParser(string $version, string $phpParserDir) {
$lockFile = __DIR__ . "/PHP-Parser-install-lock";
$lockFd = fopen($lockFile, 'w+');
@@ -1318,16 +1807,22 @@ function initPhpParser() {
}
$optind = null;
$options = getopt("fh", ["force-regeneration", "parameter-stats", "help", "verify"], $optind);
$options = getopt("fh", ["force-regeneration", "parameter-stats", "help", "verify", "generate-methodsynopses", "replace-methodsynopses"], $optind);
$context = new Context;
$printParameterStats = isset($options["parameter-stats"]);
$verify = isset($options["verify"]);
$generateMethodSynopses = isset($options["generate-methodsynopses"]);
$replaceMethodSynopses = isset($options["replace-methodsynopses"]);
$context->forceRegeneration = isset($options["f"]) || isset($options["force-regeneration"]);
$context->forceParse = $context->forceRegeneration || $printParameterStats || $verify;
$context->forceParse = $context->forceRegeneration || $printParameterStats || $verify || $generateMethodSynopses || $replaceMethodSynopses;
$targetMethodSynopses = $argv[$optind + 1] ?? null;
if ($replaceMethodSynopses && $targetMethodSynopses === null) {
die("A target directory must be provided.\n");
}
if (isset($options["h"]) || isset($options["help"])) {
die("\nusage: gen-stub.php [ -f | --force-regeneration ] [ --parameter-stats ] [ --verify ] [ -h | --help ] [ name.stub.php | directory ]\n\n");
die("\nusage: gen-stub.php [ -f | --force-regeneration ] [ --generate-methodsynopses ] [ --replace-methodsynopses ] [ --parameter-stats ] [ --verify ] [ -h | --help ] [ name.stub.php | directory ] [ directory ]\n\n");
}
$fileInfos = [];
@@ -1363,23 +1858,26 @@ if ($printParameterStats) {
echo json_encode($parameterStats, JSON_PRETTY_PRINT), "\n";
}
if ($verify) {
$errors = [];
$funcMap = [];
$aliases = [];
/** @var FuncInfo[] $funcMap */
$funcMap = [];
/** @var FuncInfo[] $aliasMap */
$aliasMap = [];
foreach ($fileInfos as $fileInfo) {
foreach ($fileInfo->getAllFuncInfos() as $funcInfo) {
/** @var FuncInfo $funcInfo */
$funcMap[$funcInfo->name->__toString()] = $funcInfo;
foreach ($fileInfos as $fileInfo) {
foreach ($fileInfo->getAllFuncInfos() as $funcInfo) {
/** @var FuncInfo $funcInfo */
$funcMap[$funcInfo->name->__toString()] = $funcInfo;
if ($funcInfo->aliasType === "alias") {
$aliases[] = $funcInfo;
}
if ($funcInfo->aliasType === "alias") {
$aliasMap[$funcInfo->alias->__toString()] = $funcInfo;
}
}
}
foreach ($aliases as $aliasFunc) {
if ($verify) {
$errors = [];
foreach ($aliasMap as $aliasFunc) {
if (!isset($funcMap[$aliasFunc->alias->__toString()])) {
$errors[] = "Aliased function {$aliasFunc->alias}() cannot be found";
continue;
@@ -1412,7 +1910,6 @@ if ($verify) {
}
if ($aliasedArg === null) {
assert($aliasArg !== null);
$errors[] = "{$aliasedFunc->name}(): Argument \$$aliasArg->name of alias function {$aliasFunc->name}() is missing";
return null;
}
@@ -1447,3 +1944,30 @@ if ($verify) {
exit(1);
}
}
if ($generateMethodSynopses) {
$methodSynopsesDirectory = getcwd() . "/methodsynopses";
$methodSynopses = generateMethodSynopses($funcMap, $aliasMap);
if (!empty($methodSynopses)) {
if (!file_exists($methodSynopsesDirectory)) {
mkdir($methodSynopsesDirectory);
}
foreach ($methodSynopses as $filename => $content) {
if (file_put_contents("$methodSynopsesDirectory/$filename", $content)) {
echo "Saved $filename\n";
}
}
}
}
if ($replaceMethodSynopses) {
$methodSynopses = replaceMethodSynopses($targetMethodSynopses, $funcMap, $aliasMap);
foreach ($methodSynopses as $filename => $content) {
if (file_put_contents($filename, $content)) {
echo "Saved $filename\n";
}
}
}
+2 -2
View File
@@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice.
dnl ----------------------------------------------------------------------------
AC_PREREQ([2.68])
AC_INIT([PHP],[8.0.1-dev],[https://bugs.php.net],[php],[https://www.php.net])
AC_INIT([PHP],[8.0.5],[https://bugs.php.net],[php],[https://www.php.net])
AC_CONFIG_SRCDIR([main/php_version.h])
AC_CONFIG_AUX_DIR([build])
AC_PRESERVE_HELP_ORDER
@@ -524,7 +524,7 @@ dnl Fix for these systems is already included in GCC 7, but not on GCC 6.
dnl
dnl At least some versions of FreeBSD seem to have buggy ifunc support, see
dnl bug #77284. Conservatively don't use ifuncs on FreeBSD.
AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*freebsd*], [true], [
AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*freebsd*|*openbsd*], [true], [
AX_GCC_FUNC_ATTRIBUTE([ifunc])
AX_GCC_FUNC_ATTRIBUTE([target])
])
+144 -53
View File
@@ -129,20 +129,23 @@ PHP_MINFO_FUNCTION(bcmath)
/* {{{ php_str2num
Convert to bc_num detecting scale */
static void php_str2num(bc_num *num, char *str)
static zend_result php_str2num(bc_num *num, char *str)
{
char *p;
if (!(p = strchr(str, '.'))) {
if (!bc_str2num(num, str, 0)) {
php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed");
return FAILURE;
}
return;
return SUCCESS;
}
if (!bc_str2num(num, str, strlen(p+1))) {
php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed");
return FAILURE;
}
return SUCCESS;
}
/* }}} */
@@ -174,15 +177,26 @@ PHP_FUNCTION(bcadd)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
bc_add (first, second, &result, scale);
RETVAL_STR(bc_num2str_ex(result, scale));
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
return;
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
};
}
/* }}} */
@@ -214,15 +228,26 @@ PHP_FUNCTION(bcsub)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
bc_sub (first, second, &result, scale);
RETVAL_STR(bc_num2str_ex(result, scale));
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
return;
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
};
}
/* }}} */
@@ -254,15 +279,26 @@ PHP_FUNCTION(bcmul)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
bc_multiply (first, second, &result, scale);
RETVAL_STR(bc_num2str_ex(result, scale));
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
return;
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
};
}
/* }}} */
@@ -294,8 +330,16 @@ PHP_FUNCTION(bcdiv)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
switch (bc_divide(first, second, &result, scale)) {
case 0: /* OK */
@@ -306,10 +350,11 @@ PHP_FUNCTION(bcdiv)
break;
}
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
return;
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
};
}
/* }}} */
@@ -341,8 +386,16 @@ PHP_FUNCTION(bcmod)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
switch (bc_modulo(first, second, &result, scale)) {
case 0:
@@ -353,9 +406,11 @@ PHP_FUNCTION(bcmod)
break;
}
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
};
}
/* }}} */
@@ -389,18 +444,32 @@ PHP_FUNCTION(bcpowmod)
bc_init_num(&second);
bc_init_num(&mod);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
php_str2num(&mod, ZSTR_VAL(modulus));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
if (php_str2num(&mod, ZSTR_VAL(modulus)) == FAILURE) {
zend_argument_value_error(3, "is not well-formed");
goto cleanup;
}
if (bc_raisemod(first, second, mod, &result, scale) == SUCCESS) {
RETVAL_STR(bc_num2str_ex(result, scale));
}
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&mod);
bc_free_num(&result);
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&mod);
bc_free_num(&result);
};
}
/* }}} */
@@ -432,14 +501,26 @@ PHP_FUNCTION(bcpow)
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, ZSTR_VAL(left));
php_str2num(&second, ZSTR_VAL(right));
if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) {
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
bc_raise (first, second, &result, scale);
RETVAL_STR(bc_num2str_ex(result, scale));
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
};
}
/* }}} */
@@ -468,7 +549,11 @@ PHP_FUNCTION(bcsqrt)
}
bc_init_num(&result);
php_str2num(&result, ZSTR_VAL(left));
if (php_str2num(&result, ZSTR_VAL(left)) == FAILURE) {
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (bc_sqrt (&result, scale) != 0) {
RETVAL_STR(bc_num2str_ex(result, scale));
@@ -476,8 +561,9 @@ PHP_FUNCTION(bcsqrt)
zend_argument_value_error(1, "must be greater than or equal to 0");
}
bc_free_num(&result);
return;
cleanup: {
bc_free_num(&result);
};
}
/* }}} */
@@ -510,16 +596,21 @@ PHP_FUNCTION(bccomp)
bc_init_num(&second);
if (!bc_str2num(&first, ZSTR_VAL(left), scale)) {
php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed");
zend_argument_value_error(1, "is not well-formed");
goto cleanup;
}
if (!bc_str2num(&second, ZSTR_VAL(right), scale)) {
php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed");
zend_argument_value_error(2, "is not well-formed");
goto cleanup;
}
RETVAL_LONG(bc_compare(first, second));
bc_free_num(&first);
bc_free_num(&second);
return;
cleanup: {
bc_free_num(&first);
bc_free_num(&second);
};
}
/* }}} */
+25
View File
@@ -0,0 +1,25 @@
--TEST--
Bug #80545 (bcadd('a', 'a') and bcadd('1', 'a') doesn't throw an exception)
--SKIPIF--
<?php
if (!extension_loaded('bcmath')) die('skip bcmath extension not available');
?>
--FILE--
<?php
try {
bcadd('a', 'a');
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
bcadd('1', 'a');
} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
--EXPECT--
bcadd(): Argument #1 ($num1) is not well-formed
bcadd(): Argument #2 ($num2) is not well-formed
+75 -31
View File
@@ -14,12 +14,39 @@ echo bcadd("", "2", 2),"\n";
echo bcadd("+0", "2"), "\n";
echo bcadd("-0", "2"), "\n";
echo bcadd(" 0", "2");
echo bcadd("1e1", "2");
echo bcadd("1,1", "2");
echo bcadd("Hello", "2");
echo bcadd("1 1", "2");
echo "\n", "\n";
echo "\n";
try {
echo bcadd(" 0", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bcadd("1e1", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bcadd("1,1", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bcadd("Hello", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bcadd("1 1", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
echo "\n";
echo bccomp("1", "2"),"\n";
echo bccomp("1.1", "2", 2),"\n";
@@ -27,11 +54,38 @@ echo bccomp("", "2"),"\n";
echo bccomp("+0", "2"), "\n";
echo bccomp("-0", "2"), "\n";
echo bccomp(" 0", "2");
echo bccomp("1e1", "2");
echo bccomp("1,1", "2");
echo bccomp("Hello", "2");
echo bccomp("1 1", "2");
echo "\n";
try {
echo bccomp(" 0", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bccomp("1e1", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bccomp("1,1", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bccomp("Hello", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo bccomp("1 1", "2");
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}
?>
--EXPECTF--
3
@@ -40,16 +94,11 @@ echo bccomp("1 1", "2");
2
2
Warning: bcadd(): bcmath function argument is not well-formed in %s on line %d
2
Warning: bcadd(): bcmath function argument is not well-formed in %s on line %d
2
Warning: bcadd(): bcmath function argument is not well-formed in %s on line %d
2
Warning: bcadd(): bcmath function argument is not well-formed in %s on line %d
2
Warning: bcadd(): bcmath function argument is not well-formed in %s on line %d
2
bcadd(): Argument #1 ($num1) is not well-formed
bcadd(): Argument #1 ($num1) is not well-formed
bcadd(): Argument #1 ($num1) is not well-formed
bcadd(): Argument #1 ($num1) is not well-formed
bcadd(): Argument #1 ($num1) is not well-formed
-1
-1
@@ -57,13 +106,8 @@ Warning: bcadd(): bcmath function argument is not well-formed in %s on line %d
-1
-1
Warning: bccomp(): bcmath function argument is not well-formed in %s on line %d
-1
Warning: bccomp(): bcmath function argument is not well-formed in %s on line %d
-1
Warning: bccomp(): bcmath function argument is not well-formed in %s on line %d
-1
Warning: bccomp(): bcmath function argument is not well-formed in %s on line %d
-1
Warning: bccomp(): bcmath function argument is not well-formed in %s on line %d
-1
bccomp(): Argument #1 ($num1) is not well-formed
bccomp(): Argument #1 ($num1) is not well-formed
bccomp(): Argument #1 ($num1) is not well-formed
bccomp(): Argument #1 ($num1) is not well-formed
bccomp(): Argument #1 ($num1) is not well-formed
+10 -3
View File
@@ -39,6 +39,7 @@ typedef struct _php_bz2_filter_data {
enum strm_status status; /* Decompress option */
unsigned int small_footprint : 1; /* Decompress option */
unsigned int expect_concatenated : 1; /* Decompress option */
unsigned int is_flushed : 1; /* only for compression */
int persistent;
} php_bz2_filter_data;
@@ -227,6 +228,8 @@ static php_stream_filter_status_t php_bz2_compress_filter(
bucket = php_stream_bucket_make_writeable(buckets_in->head);
while (bin < bucket->buflen) {
int flush_mode;
desired = bucket->buflen - bin;
if (desired > data->inbuf_len) {
desired = data->inbuf_len;
@@ -234,7 +237,9 @@ static php_stream_filter_status_t php_bz2_compress_filter(
memcpy(data->strm.next_in, bucket->buf + bin, desired);
data->strm.avail_in = desired;
status = BZ2_bzCompress(&(data->strm), flags & PSFS_FLAG_FLUSH_CLOSE ? BZ_FINISH : (flags & PSFS_FLAG_FLUSH_INC ? BZ_FLUSH : BZ_RUN));
flush_mode = flags & PSFS_FLAG_FLUSH_CLOSE ? BZ_FINISH : (flags & PSFS_FLAG_FLUSH_INC ? BZ_FLUSH : BZ_RUN);
data->is_flushed = flush_mode != BZ_RUN;
status = BZ2_bzCompress(&(data->strm), flush_mode);
if (status != BZ_RUN_OK && status != BZ_FLUSH_OK && status != BZ_FINISH_OK) {
/* Something bad happened */
php_stream_bucket_delref(bucket);
@@ -260,11 +265,12 @@ static php_stream_filter_status_t php_bz2_compress_filter(
php_stream_bucket_delref(bucket);
}
if (flags & PSFS_FLAG_FLUSH_CLOSE) {
if (flags & PSFS_FLAG_FLUSH_CLOSE || ((flags & PSFS_FLAG_FLUSH_INC) && !data->is_flushed)) {
/* Spit it out! */
status = BZ_FINISH_OK;
while (status == BZ_FINISH_OK) {
status = BZ2_bzCompress(&(data->strm), BZ_FINISH);
status = BZ2_bzCompress(&(data->strm), (flags & PSFS_FLAG_FLUSH_CLOSE ? BZ_FINISH : BZ_FLUSH));
data->is_flushed = 1;
if (data->strm.avail_out < data->outbuf_len) {
size_t bucketlen = data->outbuf_len - data->strm.avail_out;
@@ -380,6 +386,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
}
status = BZ2_bzCompressInit(&(data->strm), blockSize100k, 0, workFactor);
data->is_flushed = 1;
fops = &php_bz2_compress_ops;
} else {
status = BZ_DATA_ERROR;
+24
View File
@@ -0,0 +1,24 @@
--TEST--
Bug #75776 (Flushing streams with compression filter is broken)
--SKIPIF--
<?php
if (!extension_loaded('bz2')) die('skip bz2 extension not available');
?>
--FILE--
<?php
$text = str_repeat('0123456789abcdef', 1000);
$temp = fopen('php://temp', 'r+');
stream_filter_append($temp, 'bzip2.compress', STREAM_FILTER_WRITE);
fwrite($temp, $text);
rewind($temp);
var_dump(bin2hex(stream_get_contents($temp)));
var_dump(ftell($temp));
fclose($temp);
?>
--EXPECT--
string(144) "425a68343141592653599fe7bbbf0001f389007fe03f002000902980026826aa80003ea9061520c6a41954833a9069520d6a41b54837a9071520e6a41d5483ba9079520f6a41f548"
int(72)
+4
View File
@@ -82,3 +82,7 @@ class dotnet
public function __construct(string $assembly_name, string $datatype_name, int $codepage = CP_ACP) {}
}
#endif
final class com_exception extends exception
{
}
+6 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: da1da8fcfe8a04d08d354ad2cc5a3658d16c3076 */
* Stub hash: 6b162963bcceb90144fdd3165137fb567f916812 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_set, 0, 2, IS_VOID, 0)
ZEND_ARG_OBJ_INFO(0, variant, variant, 0)
@@ -226,3 +226,8 @@ static const zend_function_entry class_dotnet_methods[] = {
#endif
ZEND_FE_END
};
static const zend_function_entry class_com_exception_methods[] = {
ZEND_FE_END
};
+12 -1
View File
@@ -1200,6 +1200,7 @@ PHP_MINIT_FUNCTION(curl)
curl_object_handlers.get_constructor = curl_get_constructor;
curl_object_handlers.clone_obj = curl_clone_obj;
curl_object_handlers.cast_object = curl_cast_object;
curl_object_handlers.compare = zend_objects_not_comparable;
curl_multi_register_class(class_CurlMultiHandle_methods);
curl_share_register_class(class_CurlShareHandle_methods);
@@ -2046,6 +2047,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
#endif
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "name", sizeof("name")-1, 0, &rv);
ZVAL_DEREF(prop);
if (Z_TYPE_P(prop) != IS_STRING) {
php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));
} else {
@@ -2056,10 +2058,12 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
}
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "mime", sizeof("mime")-1, 0, &rv);
ZVAL_DEREF(prop);
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
type = Z_STRVAL_P(prop);
}
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "postname", sizeof("postname")-1, 0, &rv);
ZVAL_DEREF(prop);
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
filename = Z_STRVAL_P(prop);
}
@@ -2722,7 +2726,14 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
case CURLOPT_POSTFIELDS:
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
return build_mime_structure_from_hash(ch, zvalue);
if (zend_hash_num_elements(HASH_OF(zvalue)) == 0) {
/* no need to build the mime structure for empty hashtables;
also works around https://github.com/curl/curl/issues/6455 */
curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, "");
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0);
} else {
return build_mime_structure_from_hash(ch, zvalue);
}
} else {
zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
+1
View File
@@ -603,4 +603,5 @@ void curl_multi_register_class(const zend_function_entry *method_entries) {
curl_multi_handlers.get_constructor = curl_multi_get_constructor;
curl_multi_handlers.clone_obj = NULL;
curl_multi_handlers.cast_object = curl_cast_object;
curl_multi_handlers.compare = zend_objects_not_comparable;
}
+1
View File
@@ -176,4 +176,5 @@ void curl_share_register_class(const zend_function_entry *method_entries) {
curl_share_handlers.free_obj = curl_share_free_obj;
curl_share_handlers.get_constructor = curl_share_get_constructor;
curl_share_handlers.clone_obj = NULL;
curl_share_handlers.compare = zend_objects_not_comparable;
}
+1
View File
@@ -25,5 +25,6 @@ string(%d) "POST /get.inc?test=post HTTP/1.1
Host: localhost:%d
Accept: */*
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
"
+30
View File
@@ -0,0 +1,30 @@
--TEST--
Bug #80595 (Resetting POSTFIELDS to empty array breaks request)
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_URL => "{$host}/get.inc?test=post",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['foo' => 'bar']);
var_dump(curl_exec($ch));
curl_setopt($ch, CURLOPT_POSTFIELDS, []);
var_dump(curl_exec($ch));
?>
--EXPECT--
string(43) "array(1) {
["foo"]=>
string(3) "bar"
}
"
string(13) "array(0) {
}
"
+1 -1
View File
@@ -48,7 +48,7 @@ PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => %s
BROTLI => %s
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, %r(mqtt, )?%rpop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Protocols => dict, file, ftp, ftps, gopher, %r(gophers, )?%rhttp, https, imap, imaps, ldap, ldaps, %r(mqtt, )?%rpop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => %s-pc-win32
SSL Version => OpenSSL/%s
ZLib Version => %s
+23303 -20532
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+2681 -2482
View File
File diff suppressed because it is too large. Load diff
+10 -10
View File
@@ -57,7 +57,7 @@ function date_sub(DateTime $object, DateInterval $interval): DateTime {}
function date_timezone_get(DateTimeInterface $object): DateTimeZone|false {}
function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone): DateTime {}
function date_timezone_set(DateTime $object, DateTimeZone $timezone): DateTime {}
function date_offset_get(DateTimeInterface $object): int {}
@@ -105,12 +105,12 @@ function date_default_timezone_get(): string {}
function date_sunrise(
int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
float $utcOffset = 0): string|int|float|false {}
?float $utcOffset = null): string|int|float|false {}
function date_sunset(
int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
float $utcOffset = 0): string|int|float|false {}
?float $utcOffset = null): string|int|float|false {}
function date_sun_info(int $timestamp, float $latitude, float $longitude): array {}
@@ -125,7 +125,7 @@ interface DateTimeInterface
/** @return DateTimeZone|false */
public function getTimezone();
/** @return int|false */
/** @return int */
public function getOffset();
/** @return int|false */
@@ -202,7 +202,7 @@ class DateTime implements DateTimeInterface
public function setTimezone(DateTimeZone $timezone) {}
/**
* @return int|false
* @return int
* @alias date_offset_get
*/
public function getOffset() {}
@@ -238,7 +238,7 @@ class DateTime implements DateTimeInterface
public function getTimestamp() {}
/**
* @return DateInterval|false
* @return DateInterval
* @alias date_diff
*/
public function diff(DateTimeInterface $targetObject, bool $absolute = false) {}
@@ -251,7 +251,7 @@ class DateTimeImmutable implements DateTimeInterface
/** @return void */
public function __wakeup() {}
/** @return DateTimeZone */
/** @return DateTimeImmutable */
public static function __set_state(array $array) {}
/**
@@ -279,7 +279,7 @@ class DateTimeImmutable implements DateTimeInterface
public function getTimezone() {}
/**
* @return int|false
* @return int
* @alias date_offset_get
*/
public function getOffset() {}
@@ -291,7 +291,7 @@ class DateTimeImmutable implements DateTimeInterface
public function getTimestamp() {}
/**
* @return DateInterval|false
* @return DateInterval
* @alias date_diff
*/
public function diff(DateTimeInterface $targetObject, bool $absolute = false) {}
@@ -361,7 +361,7 @@ class DateTimeZone
public static function listAbbreviations() {}
/**
* @return array|false
* @return array
* @alias timezone_identifiers_list
*/
public static function listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) {}
+3 -3
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 07d0e6179d838847d4a5d454f8b56438f8df19c0 */
* Stub hash: 880a93d8a3461635447318317869fa7d3d7762dd */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
@@ -110,7 +110,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_date_timezone_get, 0, 1, Dat
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_timezone_set, 0, 2, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 0)
ZEND_END_ARG_INFO()
@@ -214,7 +214,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_date_sunrise, 0, 1, MAY_BE_STRIN
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, latitude, IS_DOUBLE, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, longitude, IS_DOUBLE, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, zenith, IS_DOUBLE, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, utcOffset, IS_DOUBLE, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, utcOffset, IS_DOUBLE, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_date_sunset arginfo_date_sunrise
+8
View File
@@ -0,0 +1,8 @@
--TEST--
Bug #76770 'U' modifier in 'datetime::createFromFormat' adds seconds to other specifiers
--FILE--
<?php
var_dump(datetime::createFromFormat('U H', '3600 01')->getTimestamp());
?>
--EXPECT--
int(3600)
+2 -2
View File
@@ -863,9 +863,9 @@ restart:
zend_bool close_both;
close_both = (info->fp != info->lock.fp);
php_stream_close(info->lock.fp);
php_stream_free(info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
if (close_both) {
php_stream_close(info->fp);
php_stream_free(info->fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
}
info->fp = NULL;
info->lock.fp = NULL;
+2 -34
View File
@@ -349,9 +349,8 @@ PHP_METHOD(DOMCharacterData, replaceData)
PHP_METHOD(DOMCharacterData, remove)
{
zval *id = ZEND_THIS;
xmlNodePtr children, child;
xmlNodePtr child;
dom_object *intern;
int stricterror;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
@@ -359,38 +358,7 @@ PHP_METHOD(DOMCharacterData, remove)
DOM_GET_OBJ(child, id, xmlNodePtr, intern);
if (dom_node_children_valid(child) == FAILURE) {
RETURN_NULL();
}
stricterror = dom_get_strict_error(intern->document);
if (dom_node_is_read_only(child) == SUCCESS ||
(child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) {
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror);
RETURN_NULL();
}
if (!child->parent) {
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
RETURN_NULL();
}
children = child->parent->children;
if (!children) {
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
RETURN_NULL();
}
while (children) {
if (children == child) {
xmlUnlinkNode(child);
RETURN_NULL();
}
children = children->next;
}
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
dom_child_node_remove(intern);
RETURN_NULL();
}
+2 -2
View File
@@ -986,7 +986,7 @@ PHP_METHOD(DOMDocument, getElementsByTagNameNS)
xmlChar *local, *nsuri;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &uri, &uri_len, &name, &name_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) {
RETURN_THROWS();
}
@@ -995,7 +995,7 @@ PHP_METHOD(DOMDocument, getElementsByTagNameNS)
php_dom_create_iterator(return_value, DOM_NODELIST);
namednode = Z_DOMOBJ_P(return_value);
local = xmlCharStrndup(name, name_len);
nsuri = xmlCharStrndup(uri, uri_len);
nsuri = xmlCharStrndup(uri ? uri : "", uri_len);
dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri);
}
/* }}} end dom_document_get_elements_by_tag_name_ns */
+1 -1
View File
@@ -127,7 +127,7 @@ PHP_METHOD(DOMImplementation, createDocument)
char *prefix = NULL, *localname = NULL;
dom_object *doctobj;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ssO!", &uri, &uri_len, &name, &name_len, &node, dom_documenttype_class_entry) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!sO!", &uri, &uri_len, &name, &name_len, &node, dom_documenttype_class_entry) == FAILURE) {
RETURN_THROWS();
}
+2 -2
View File
@@ -933,7 +933,7 @@ PHP_METHOD(DOMElement, getElementsByTagNameNS)
xmlChar *local, *nsuri;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &uri, &uri_len, &name, &name_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) {
RETURN_THROWS();
}
@@ -942,7 +942,7 @@ PHP_METHOD(DOMElement, getElementsByTagNameNS)
php_dom_create_iterator(return_value, DOM_NODELIST);
namednode = Z_DOMOBJ_P(return_value);
local = xmlCharStrndup(name, name_len);
nsuri = xmlCharStrndup(uri, uri_len);
nsuri = xmlCharStrndup(uri ? uri : "", uri_len);
dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri);
}
+4 -4
View File
@@ -374,10 +374,6 @@ void dom_child_node_remove(dom_object *context)
xmlNodePtr children;
int stricterror;
if (dom_node_children_valid(child) == FAILURE) {
return;
}
stricterror = dom_get_strict_error(context->document);
if (dom_node_is_read_only(child) == SUCCESS ||
@@ -391,6 +387,10 @@ void dom_child_node_remove(dom_object *context)
return;
}
if (dom_node_children_valid(child->parent) == FAILURE) {
return;
}
children = child->parent->children;
if (!children) {
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
+7 -3
View File
@@ -1243,9 +1243,13 @@ int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child)
{
xmlNodePtr nodep;
if (parent == NULL || child == NULL || child->doc != parent->doc) {
return SUCCESS;
}
if (parent == NULL || child == NULL || child->doc != parent->doc) {
return SUCCESS;
}
if (child->type == XML_DOCUMENT_NODE) {
return FAILURE;
}
nodep = parent;
+20 -16
View File
@@ -2,16 +2,16 @@
/** @generate-function-entries */
class DOMDocumentType
class DOMDocumentType extends DOMNode
{
}
class DOMCdataSection
class DOMCdataSection extends DOMText
{
public function __construct(string $data) {}
}
class DOMComment
class DOMComment extends DOMCharacterData
{
public function __construct(string $data = "") {}
}
@@ -93,6 +93,10 @@ class DOMNode
public function replaceChild(DOMNode $node, DOMNode $child) {}
}
class DOMNameSpaceNode
{
}
class DOMImplementation
{
/** @return void */
@@ -105,10 +109,10 @@ class DOMImplementation
public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
/** @return DOMDocument|false */
public function createDocument(string $namespace = "", string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
}
class DOMDocumentFragment implements DOMParentNode
class DOMDocumentFragment extends DOMNode implements DOMParentNode
{
public function __construct() {}
@@ -129,11 +133,11 @@ class DOMNodeList implements IteratorAggregate, Countable
public function getIterator(): Iterator {}
/** @return ?DOMNode */
/** @return DOMNode|null */
public function item(int $index) {}
}
class DOMCharacterData implements DOMChildNode
class DOMCharacterData extends DOMNode implements DOMChildNode
{
/** @return bool */
public function appendData(string $data) {}
@@ -162,7 +166,7 @@ class DOMCharacterData implements DOMChildNode
public function after(...$nodes): void {}
}
class DOMAttr
class DOMAttr extends DOMNode
{
public function __construct(string $name, string $value = "") {}
@@ -170,7 +174,7 @@ class DOMAttr
public function isId() {}
}
class DOMElement implements DOMParentNode, DOMChildNode
class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode
{
public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}
@@ -190,7 +194,7 @@ class DOMElement implements DOMParentNode, DOMChildNode
public function getElementsByTagName(string $qualifiedName) {}
/** @return DOMNodeList */
public function getElementsByTagNameNS(string $namespace, string $localName) {}
public function getElementsByTagNameNS(?string $namespace, string $localName) {}
/** @return bool */
public function hasAttribute(string $qualifiedName) {}
@@ -205,7 +209,7 @@ class DOMElement implements DOMParentNode, DOMChildNode
public function removeAttributeNS(?string $namespace, string $localName) {}
/** @return DOMAttr|false */
public function removeAttributeNode(string $qualifiedName) {}
public function removeAttributeNode(DOMAttr $attr) {}
/** @return DOMAttr|bool */
public function setAttribute(string $qualifiedName, string $value) {}
@@ -246,7 +250,7 @@ class DOMElement implements DOMParentNode, DOMChildNode
public function prepend(...$nodes): void {}
}
class DOMDocument implements DOMParentNode
class DOMDocument extends DOMNode implements DOMParentNode
{
public function __construct(string $version = "1.0", string $encoding = "") {}
@@ -287,7 +291,7 @@ class DOMDocument implements DOMParentNode
public function getElementsByTagName(string $qualifiedName) {}
/** @return DOMNodeList */
public function getElementsByTagNameNS(string $namespace, string $localName) {}
public function getElementsByTagNameNS(?string $namespace, string $localName) {}
/** @return DOMNode|false */
public function importNode(DOMNode $node, bool $deep = false) {}
@@ -358,7 +362,7 @@ final class DOMException extends Exception
{
}
class DOMText
class DOMText extends DOMCharacterData
{
public function __construct(string $data = "") {}
@@ -396,7 +400,7 @@ class DOMEntity extends DOMNode
{
}
class DOMEntityReference
class DOMEntityReference extends DOMNode
{
public function __construct(string $name) {}
}
@@ -405,7 +409,7 @@ class DOMNotation extends DOMNode
{
}
class DOMProcessingInstruction
class DOMProcessingInstruction extends DOMNode
{
public function __construct(string $name, string $value = "") {}
}
+14 -12
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 128108b08807ce0b125fc7b963bf3c5b77e6987a */
* Stub hash: a4767d6ea60859c8897f681fb69d6f73b1f50471 */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
@@ -106,7 +106,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMImplementation_createDocumentType, 0, 0,
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMImplementation_createDocument, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, namespace, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, namespace, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, qualifiedName, IS_STRING, 0, "\"\"")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, doctype, DOMDocumentType, 1, "null")
ZEND_END_ARG_INFO()
@@ -184,10 +184,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DOMElement_getElementsByTagName arginfo_class_DOMElement_getAttribute
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_getElementsByTagNameNS, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_DOMElement_getElementsByTagNameNS arginfo_class_DOMElement_getAttributeNS
#define arginfo_class_DOMElement_hasAttribute arginfo_class_DOMElement_getAttribute
@@ -197,7 +194,9 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DOMElement_removeAttributeNS arginfo_class_DOMElement_getAttributeNS
#define arginfo_class_DOMElement_removeAttributeNode arginfo_class_DOMElement_getAttribute
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_removeAttributeNode, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, attr, DOMAttr, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setAttribute, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0)
@@ -210,11 +209,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setAttributeNS, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setAttributeNode, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, attr, DOMAttr, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_DOMElement_setAttributeNode arginfo_class_DOMElement_removeAttributeNode
#define arginfo_class_DOMElement_setAttributeNodeNS arginfo_class_DOMElement_setAttributeNode
#define arginfo_class_DOMElement_setAttributeNodeNS arginfo_class_DOMElement_removeAttributeNode
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setIdAttribute, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0)
@@ -292,7 +289,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DOMDocument_getElementsByTagName arginfo_class_DOMElement_getAttribute
#define arginfo_class_DOMDocument_getElementsByTagNameNS arginfo_class_DOMElement_getElementsByTagNameNS
#define arginfo_class_DOMDocument_getElementsByTagNameNS arginfo_class_DOMElement_getAttributeNS
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMDocument_importNode, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, node, DOMNode, 0)
@@ -649,6 +646,11 @@ static const zend_function_entry class_DOMNode_methods[] = {
};
static const zend_function_entry class_DOMNameSpaceNode_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_DOMImplementation_methods[] = {
ZEND_ME(DOMImplementation, getFeature, arginfo_class_DOMImplementation_getFeature, ZEND_ACC_PUBLIC)
ZEND_ME(DOMImplementation, hasFeature, arginfo_class_DOMImplementation_hasFeature, ZEND_ACC_PUBLIC)
@@ -9,7 +9,7 @@ require_once __DIR__ .'/skipif.inc';
?>
--FILE--
<?php
$filename = __DIR__."/tmp_savehtmlfile".time().".html";
$filename = __DIR__."/DOMDocument_saveHTMLFile_basic.html";
$doc = new DOMDocument('1.0');
$root = $doc->createElement('html');
$root = $doc->appendChild($root);
@@ -9,7 +9,7 @@ require_once __DIR__ .'/skipif.inc';
?>
--FILE--
<?php
$filename = __DIR__."/tmp_savehtmlfile".time().".html";
$filename = __DIR__."/DOMDocument_saveHTMLFile_formatOutput.html";
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$root = $doc->createElement('html');
@@ -6,6 +6,7 @@ include('skipif.inc');
?>
--FILE--
<?php
declare(strict_types=1);
$x = new DOMImplementation();
$doc = $x->createDocument(null, 'html');
echo $doc->saveHTML();
+19
View File
@@ -0,0 +1,19 @@
--TEST--
Bug #66783 (UAF when appending DOMDocument to element)
--SKIPIF--
<?php
if (!extension_loaded('dom')) die('skip dom extension not available');
?>
--FILE--
<?php
$doc = new DomDocument;
$doc->loadXML('<root></root>');
$e = $doc->createElement('e');
try {
$e->appendChild($doc);
} catch (DOMException $ex) {
echo $ex->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Hierarchy Request Error
+11
View File
@@ -6,13 +6,24 @@ require_once('skipif.inc');
?>
--FILE--
<?php
declare(strict_types=1);
$doc = new DOMDocument();
$doc->loadXML('<root xmlns:x="x"><a/><x:a/></root>');
$list = $doc->getElementsByTagNameNS('', 'a');
var_dump($list->length);
$list = $doc->getElementsByTagNameNS(null, 'a');
var_dump($list->length);
$elem = $doc->documentElement;
$list = $elem->getElementsByTagNameNS('', 'a');
var_dump($list->length);
$list = $elem->getElementsByTagNameNS(null, 'a');
var_dump($list->length);
?>
--EXPECT--
int(1)
int(1)
int(1)
int(1)
+2
View File
@@ -1,5 +1,7 @@
--TEST--
Bug #79852: count(DOMNodeList) doesn't match count(IteratorIterator(DOMNodeList))
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
+13
View File
@@ -0,0 +1,13 @@
--TEST--
dom: DOMChildNode::remove does not work on character data
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$doc = new \DOMDocument();
$doc->loadXML('<a><!-- foo --></a>');
$doc->documentElement->firstChild->remove();
echo $doc->saveXML($doc->documentElement);
--EXPECTF--
<a/>
+2
View File
@@ -199,6 +199,7 @@ PHP_MINIT_FUNCTION(enchant)
enchant_broker_handlers.offset = XtOffsetOf(enchant_broker, std);
enchant_broker_handlers.free_obj = php_enchant_broker_free;
enchant_broker_handlers.clone_obj = NULL;
enchant_broker_handlers.compare = zend_objects_not_comparable;
INIT_CLASS_ENTRY(dce, "EnchantDictionary", class_EnchantDictionary_methods);
enchant_dict_ce = zend_register_internal_class(&dce);
@@ -211,6 +212,7 @@ PHP_MINIT_FUNCTION(enchant)
enchant_dict_handlers.offset = XtOffsetOf(enchant_dict, std);
enchant_dict_handlers.free_obj = php_enchant_dict_free;
enchant_dict_handlers.clone_obj = NULL;
enchant_dict_handlers.compare = zend_objects_not_comparable;
REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
+62 -43
View File
@@ -293,57 +293,85 @@ static int zend_ffi_is_compatible_type(zend_ffi_type *dst_type, zend_ffi_type *s
}
/* }}} */
static ffi_type *zend_ffi_make_fake_struct_type(zend_ffi_type *type) /* {{{ */
static ffi_type* zend_ffi_face_struct_add_fields(ffi_type* t, zend_ffi_type *type, int *i, size_t size)
{
ffi_type *t = emalloc(sizeof(ffi_type) + sizeof(ffi_type*) * (zend_hash_num_elements(&type->record.fields) + 1));
int i;
zend_ffi_field *field;
t->size = type->size;
t->alignment = type->align;
t->type = FFI_TYPE_STRUCT;
t->elements = (ffi_type**)(t + 1);
i = 0;
ZEND_HASH_FOREACH_PTR(&type->record.fields, field) {
switch (ZEND_FFI_TYPE(field->type)->kind) {
case ZEND_FFI_TYPE_FLOAT:
t->elements[i] = &ffi_type_float;
t->elements[(*i)++] = &ffi_type_float;
break;
case ZEND_FFI_TYPE_DOUBLE:
t->elements[i] = &ffi_type_double;
t->elements[(*i)++] = &ffi_type_double;
break;
#ifdef HAVE_LONG_DOUBLE
case ZEND_FFI_TYPE_LONGDOUBLE:
t->elements[i] = &ffi_type_longdouble;
t->elements[(*i)++] = &ffi_type_longdouble;
break;
#endif
case ZEND_FFI_TYPE_SINT8:
case ZEND_FFI_TYPE_UINT8:
case ZEND_FFI_TYPE_BOOL:
case ZEND_FFI_TYPE_CHAR:
t->elements[i] = &ffi_type_uint8;
t->elements[(*i)++] = &ffi_type_uint8;
break;
case ZEND_FFI_TYPE_SINT16:
case ZEND_FFI_TYPE_UINT16:
t->elements[i] = &ffi_type_uint16;
t->elements[(*i)++] = &ffi_type_uint16;
break;
case ZEND_FFI_TYPE_SINT32:
case ZEND_FFI_TYPE_UINT32:
t->elements[i] = &ffi_type_uint32;
t->elements[(*i)++] = &ffi_type_uint32;
break;
case ZEND_FFI_TYPE_SINT64:
case ZEND_FFI_TYPE_UINT64:
t->elements[i] = &ffi_type_uint64;
t->elements[(*i)++] = &ffi_type_uint64;
break;
case ZEND_FFI_TYPE_POINTER:
t->elements[i] = &ffi_type_pointer;
t->elements[(*i)++] = &ffi_type_pointer;
break;
case ZEND_FFI_TYPE_STRUCT: {
zend_ffi_type *field_type = ZEND_FFI_TYPE(field->type);
/* for unions we use only the first field */
int num_fields = !(field_type->attr & ZEND_FFI_ATTR_UNION) ?
zend_hash_num_elements(&field_type->record.fields) : 1;
if (num_fields > 1) {
size += sizeof(ffi_type*) * (num_fields - 1);
t = erealloc(t, size);
t->elements = (ffi_type**)(t + 1);
}
t = zend_ffi_face_struct_add_fields(t, field_type, i, size);
break;
default:
efree(t);
return NULL;
}
i++;
default:
t->elements[(*i)++] = &ffi_type_void;
break;
}
if (type->attr & ZEND_FFI_ATTR_UNION) {
/* for unions we use only the first field */
break;
}
} ZEND_HASH_FOREACH_END();
return t;
}
static ffi_type *zend_ffi_make_fake_struct_type(zend_ffi_type *type) /* {{{ */
{
/* for unions we use only the first field */
int num_fields = !(type->attr & ZEND_FFI_ATTR_UNION) ?
zend_hash_num_elements(&type->record.fields) : 1;
size_t size = sizeof(ffi_type) + sizeof(ffi_type*) * (num_fields + 1);
ffi_type *t = emalloc(size);
int i;
t->size = type->size;
t->alignment = type->align;
t->type = FFI_TYPE_STRUCT;
t->elements = (ffi_type**)(t + 1);
i = 0;
t = zend_ffi_face_struct_add_fields(t, type, &i, size);
t->elements[i] = NULL;
return t;
}
@@ -391,11 +419,7 @@ again:
kind = type->enumeration.kind;
goto again;
case ZEND_FFI_TYPE_STRUCT:
if (!(type->attr & ZEND_FFI_ATTR_UNION)) {
ffi_type *t = zend_ffi_make_fake_struct_type(type);
return t;
}
break;
return zend_ffi_make_fake_struct_type(type);
default:
break;
}
@@ -2534,18 +2558,13 @@ again:
kind = type->enumeration.kind;
goto again;
case ZEND_FFI_TYPE_STRUCT:
if (!(type->attr & ZEND_FFI_ATTR_UNION)
&& Z_TYPE_P(arg) == IS_OBJECT && Z_OBJCE_P(arg) == zend_ffi_cdata_ce) {
if (Z_TYPE_P(arg) == IS_OBJECT && Z_OBJCE_P(arg) == zend_ffi_cdata_ce) {
zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(arg);
if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type))) {
/* Create a fake structure type */
ffi_type *t = zend_ffi_make_fake_struct_type(type);
if (t) {
*pass_type = t;
arg_values[n] = cdata->ptr;
break;
}
*pass_type = zend_ffi_make_fake_struct_type(type);;
arg_values[n] = cdata->ptr;
break;
}
}
zend_ffi_pass_incompatible(arg, type, n, execute_data);
@@ -3865,7 +3884,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */
RETURN_OBJ(&cdata->std);
} else {
zend_wrong_parameter_class_error(2, "FFI\\CData", zv);
return;
RETURN_THROWS();
}
}
@@ -4006,7 +4025,7 @@ ZEND_METHOD(FFI, typeof) /* {{{ */
}
} else {
zend_wrong_parameter_class_error(1, "FFI\\CData", zv);
return;
RETURN_THROWS();
}
ctype = (zend_ffi_ctype*)zend_ffi_ctype_new(zend_ffi_ctype_ce);
@@ -4110,7 +4129,7 @@ ZEND_METHOD(FFI, addr) /* {{{ */
ZVAL_DEREF(zv);
if (Z_TYPE_P(zv) != IS_OBJECT || Z_OBJCE_P(zv) != zend_ffi_cdata_ce) {
zend_wrong_parameter_class_error(1, "FFI\\CData", zv);
return;
RETURN_THROWS();
}
cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
@@ -4165,7 +4184,7 @@ ZEND_METHOD(FFI, sizeof) /* {{{ */
type = ZEND_FFI_TYPE(ctype->type);
} else {
zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv);
return;
RETURN_THROWS();
}
RETURN_LONG(type->size);
@@ -4191,7 +4210,7 @@ ZEND_METHOD(FFI, alignof) /* {{{ */
type = ZEND_FFI_TYPE(ctype->type);
} else {
zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv);
return;
RETURN_THROWS();
}
RETURN_LONG(type->align);
@@ -4246,7 +4265,7 @@ ZEND_METHOD(FFI, memcpy) /* {{{ */
}
} else {
zend_wrong_parameter_class_error(2, "FFI\\CData or string", zv2);
return;
RETURN_THROWS();
}
memcpy(ptr1, ptr2, size);
@@ -4290,7 +4309,7 @@ ZEND_METHOD(FFI, memcmp) /* {{{ */
}
} else {
zend_wrong_parameter_class_error(1, "FFI\\CData or string", zv1);
return;
RETURN_THROWS();
}
ZVAL_DEREF(zv2);
@@ -4314,7 +4333,7 @@ ZEND_METHOD(FFI, memcmp) /* {{{ */
}
} else {
zend_wrong_parameter_class_error(2, "FFI\\CData or string", zv2);
return;
RETURN_THROWS();
}
ret = memcmp(ptr1, ptr2, size);
@@ -4416,7 +4435,7 @@ ZEND_METHOD(FFI, isNull) /* {{{ */
ZVAL_DEREF(zv);
if (Z_TYPE_P(zv) != IS_OBJECT || Z_OBJCE_P(zv) != zend_ffi_cdata_ce) {
zend_wrong_parameter_class_error(1, "FFI\\CData", zv);
return;
RETURN_THROWS();
}
cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
+17 -8
View File
@@ -10,7 +10,7 @@ final class FFI
public static function load(string $filename): ?FFI {}
public static function scope(string $name): ?FFI {}
public static function scope(string $name): FFI {}
public static function new(FFI\CType|string $type, bool $owned = true, bool $persistent = false): ?FFI\CData {}
@@ -18,7 +18,7 @@ final class FFI
public static function free(FFI\CData $ptr): void {}
/**
* @param FFI\CData|string|int|null $ptr
* @param FFI\CData|int|float|bool|null $ptr
* @prefer-ref $ptr
*/
public static function cast(FFI\CType|string $type, $ptr): ?FFI\CData {}
@@ -26,18 +26,18 @@ final class FFI
public static function type(string $type): ?FFI\CType {}
/** @prefer-ref $ptr */
public static function typeof(FFI\CData $ptr): ?FFI\CType {}
public static function typeof(FFI\CData $ptr): FFI\CType {}
public static function arrayType(FFI\CType $type, array $dimensions): ?FFI\CType {}
public static function arrayType(FFI\CType $type, array $dimensions): FFI\CType {}
/** @prefer-ref $ptr */
public static function addr(FFI\CData $ptr): FFI\CData {}
/** @prefer-ref $ptr */
public static function sizeof(object $ptr): ?int {}
public static function sizeof(FFI\CData|FFI\CType $ptr): int {}
/** @prefer-ref $ptr */
public static function alignof(object $ptr): ?int {}
public static function alignof(FFI\CData|FFI\CType $ptr): int {}
/**
* @param FFI\CData|string $from
@@ -52,13 +52,13 @@ final class FFI
* @prefer-ref $ptr2
* @param string|FFI\CData $ptr2
*/
public static function memcmp($ptr1, $ptr2, int $size): ?int {}
public static function memcmp($ptr1, $ptr2, int $size): int {}
/** @prefer-ref $ptr */
public static function memset(FFI\CData $ptr, int $value, int $size): void {}
/** @prefer-ref $ptr */
public static function string(FFI\CData $ptr, ?int $size = null): ?string {}
public static function string(FFI\CData $ptr, ?int $size = null): string {}
/** @prefer-ref $ptr */
public static function isNull(FFI\CData $ptr): bool {}
@@ -68,8 +68,17 @@ final class FFI
namespace FFI {
final class CData {
}
final class CType {
public function getName() : string {}
}
class Exception extends \Error {
}
final class ParserException extends Exception {
}
}
+23 -8
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: abd3bc186ae3f71f2b7eb1d47f3b6bab84fb2bda */
* Stub hash: b01d17eaac68e56d3f2c2c2bc86d44bcc8ea7c26 */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"")
@@ -10,7 +10,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_load, 0, 1, FFI, 1)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_scope, 0, 1, FFI, 1)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_scope, 0, 1, FFI, 0)
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -33,11 +33,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_type, 0, 1, FFI\\CType,
ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_typeof, 0, 1, FFI\\CType, 1)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_typeof, 0, 1, FFI\\CType, 0)
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_arrayType, 0, 2, FFI\\CType, 1)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_arrayType, 0, 2, FFI\\CType, 0)
ZEND_ARG_OBJ_INFO(0, type, FFI\\CType, 0)
ZEND_ARG_TYPE_INFO(0, dimensions, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
@@ -46,8 +46,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_addr, 0, 1, FFI\\CData,
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 1)
ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, ptr, IS_OBJECT, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 0)
ZEND_ARG_OBJ_TYPE_MASK(ZEND_SEND_PREFER_REF, ptr, FFI\\CData|FFI\\CType, 0, NULL)
ZEND_END_ARG_INFO()
#define arginfo_class_FFI_alignof arginfo_class_FFI_sizeof
@@ -58,7 +58,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_memcpy, 0, 3, IS_VOID,
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_memcmp, 0, 3, IS_LONG, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_memcmp, 0, 3, IS_LONG, 0)
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr1)
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr2)
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
@@ -70,7 +70,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_memset, 0, 3, IS_VOID,
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_string, 0, 1, IS_STRING, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_string, 0, 1, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, size, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
@@ -125,7 +125,22 @@ static const zend_function_entry class_FFI_methods[] = {
};
static const zend_function_entry class_FFI_CData_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_FFI_CType_methods[] = {
ZEND_ME(FFI_CType, getName, arginfo_class_FFI_CType_getName, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_FFI_Exception_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_FFI_ParserException_methods[] = {
ZEND_FE_END
};
+68
View File
@@ -0,0 +1,68 @@
--TEST--
Bug #80847 (Nested structs)
--SKIPIF--
<?php
if (!extension_loaded('ffi')) die('skip ffi extension not available');
if (!extension_loaded('zend-test')) die('skip zend-test extension not available');
if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big strctures by value on Windows/64');
?>
--FILE--
<?php
require_once('utils.inc');
$header = <<<HEADER
typedef struct bug80847_01 {
uint64_t b;
double c;
} bug80847_01;
typedef struct bug80847_02 {
bug80847_01 a;
} bug80847_02;
bug80847_02 ffi_bug80847(bug80847_02 s);
HEADER;
if (PHP_OS_FAMILY !== 'Windows') {
$ffi = FFI::cdef($header);
} else {
try {
$ffi = FFI::cdef($header, 'php_zend_test.dll');
} catch (FFI\Exception $ex) {
$ffi = FFI::cdef($header, ffi_get_php_dll_name());
}
}
$x = $ffi->new('bug80847_02');
$x->a->b = 42;
$x->a->c = 42.5;
var_dump($x);
$y = $ffi->ffi_bug80847($x);
var_dump($x, $y);
?>
--EXPECTF--
object(FFI\CData:struct bug80847_02)#%d (1) {
["a"]=>
object(FFI\CData:struct bug80847_01)#%d (2) {
["b"]=>
int(42)
["c"]=>
float(42.5)
}
}
object(FFI\CData:struct bug80847_02)#%d (1) {
["a"]=>
object(FFI\CData:struct bug80847_01)#%d (2) {
["b"]=>
int(42)
["c"]=>
float(42.5)
}
}
object(FFI\CData:struct bug80847_02)#%d (1) {
["a"]=>
object(FFI\CData:struct bug80847_01)#%d (2) {
["b"]=>
int(52)
["c"]=>
float(32.5)
}
}
+1 -1
View File
@@ -215,7 +215,7 @@ PHP_FUNCTION(finfo_open)
char resolved_path[MAXPATHLEN];
zend_error_handling zeh;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp!", &options, &file, &file_len) == FAILURE) {
RETURN_THROWS();
}
+2 -2
View File
@@ -5,7 +5,7 @@
class finfo
{
/** @alias finfo_open */
public function __construct(int $flags = FILEINFO_NONE, string $magic_database = "") {}
public function __construct(int $flags = FILEINFO_NONE, ?string $magic_database = null) {}
/**
* @param resource|null $context
@@ -29,7 +29,7 @@ class finfo
}
/** @return resource|false */
function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = "") {}
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null) {}
/**
* @param resource $finfo
+2 -2
View File
@@ -1,9 +1,9 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: be858509df27550b51d8a7a51a3629eceb6d0aa6 */
* Stub hash: 648085986695281bd5a8fb536d5ec6c2a9f8c6e8 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_open, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FILEINFO_NONE")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, magic_database, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, magic_database, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_finfo_close, 0, 1, _IS_BOOL, 0)
+26
View File
@@ -233,6 +233,9 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
p++; len--;
if (allow_hex && (*p == 'x' || *p == 'X')) {
p++; len--;
if (len == 0) {
RETURN_VALIDATION_FAILED
}
if (php_filter_parse_hex(p, len, &ctx_value) < 0) {
error = 1;
}
@@ -553,6 +556,22 @@ void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
}
/* }}} */
static int is_userinfo_valid(zend_string *str)
{
const char *valid = "-._~!$&'()*+,;=:";
const char *p = ZSTR_VAL(str);
while (p - ZSTR_VAL(str) < ZSTR_LEN(str)) {
if (isalpha(*p) || isdigit(*p) || strchr(valid, *p)) {
p++;
} else if (*p == '%' && p - ZSTR_VAL(str) <= ZSTR_LEN(str) - 3 && isdigit(*(p+1)) && isxdigit(*(p+2))) {
p += 3;
} else {
return 0;
}
}
return 1;
}
void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
php_url *url;
@@ -608,6 +627,13 @@ bad_url:
php_url_free(url);
RETURN_VALIDATION_FAILED
}
if (url->user != NULL && !is_userinfo_valid(url->user)) {
php_url_free(url);
RETURN_VALIDATION_FAILED
}
php_url_free(url);
}
/* }}} */
+15
View File
@@ -0,0 +1,15 @@
--TEST--
Bug #77423 (parse_url() will deliver a wrong host to user)
--FILE--
<?php
$urls = array(
"http://php.net\@aliyun.com/aaa.do",
"https://example.com\uFF03@bing.com",
);
foreach ($urls as $url) {
var_dump(filter_var($url, FILTER_VALIDATE_URL));
}
?>
--EXPECT--
bool(false)
bool(false)
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug #80584: "0x" and "0X" are considered valid hex numbers by filter_var()
--SKIPIF--
<?php
if (!extension_loaded('filter')) die('skip filter extension not available');
?>
--FILE--
<?php
var_dump(filter_var('0x', FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX));
var_dump(filter_var('0X', FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX));
var_dump(filter_var('', FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX));
var_dump(filter_var('0', FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX));
?>
--EXPECT--
bool(false)
bool(false)
bool(false)
int(0)
+6
View File
@@ -1886,6 +1886,12 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
/* SSL wants a write. Really odd. Let's bail out. */
done = 1;
break;
case SSL_ERROR_SYSCALL:
/* most likely the peer closed the connection without
sending a close_notify shutdown alert;
bail out to avoid raising a spurious warning */
done = 1;
break;
default:
if ((sslerror = ERR_get_error())) {
ERR_error_string_n(sslerror, buf, sizeof(buf));
+22 -15
View File
@@ -232,6 +232,7 @@ static void php_gd_object_minit_helper()
php_gd_image_object_handlers.clone_obj = NULL;
php_gd_image_object_handlers.free_obj = php_gd_image_object_free;
php_gd_image_object_handlers.get_constructor = php_gd_image_object_get_constructor;
php_gd_image_object_handlers.compare = zend_objects_not_comparable;
php_gd_image_object_handlers.offset = XtOffsetOf(php_gd_image_object, std);
}
@@ -1778,7 +1779,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
char *file = NULL;
zend_long quality = 0, type = 0;
gdImagePtr im;
char *fn = NULL;
FILE *fp;
size_t file_len = 0;
int argc = ZEND_NUM_ARGS();
@@ -1786,28 +1786,35 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
/* The quality parameter for gd2 stands for chunk size */
if (zend_parse_parameters(argc, "O|pll", &imgind, gd_image_ce, &file, &file_len, &quality, &type) == FAILURE) {
RETURN_THROWS();
switch (image_type) {
case PHP_GDIMG_TYPE_GD:
if (zend_parse_parameters(argc, "O|p!", &imgind, gd_image_ce, &file, &file_len) == FAILURE) {
RETURN_THROWS();
}
break;
case PHP_GDIMG_TYPE_GD2:
if (zend_parse_parameters(argc, "O|p!ll", &imgind, gd_image_ce, &file, &file_len, &quality, &type) == FAILURE) {
RETURN_THROWS();
}
break;
EMPTY_SWITCH_DEFAULT_CASE()
}
im = php_gd_libgdimageptr_from_zval_p(imgind);
if (argc > 1) {
fn = file;
if (argc >= 3) {
q = quality;
if (argc == 4) {
t = type;
}
if (argc >= 3) {
q = quality;
if (argc == 4) {
t = type;
}
}
if (argc >= 2 && file_len) {
PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename");
if (file_len) {
PHP_GD_CHECK_OPEN_BASEDIR(file, "Invalid filename");
fp = VCWD_FOPEN(fn, "wb");
fp = VCWD_FOPEN(file, "wb");
if (!fp) {
php_error_docref(NULL, E_WARNING, "Unable to open \"%s\" for writing", fn);
php_error_docref(NULL, E_WARNING, "Unable to open \"%s\" for writing", file);
RETURN_FALSE;
}
@@ -2594,7 +2601,7 @@ PHP_FUNCTION(imageinterlace)
gdImageInterlace(im, INT);
}
RETURN_LONG(gdImageGetInterlaced(im));
RETURN_BOOL(gdImageGetInterlaced(im));
}
/* }}} */
+4 -4
View File
@@ -124,9 +124,9 @@ function imagejpeg(GdImage $image, $file = null, int $quality = -1): bool {}
/** @param resource|string|null $file */
function imagewbmp(GdImage $image, $file = null, ?int $foreground_color = null): bool {}
function imagegd(GdImage $image, string $file = UNKNOWN): bool {}
function imagegd(GdImage $image, ?string $file = null): bool {}
function imagegd2(GdImage $image, string $file = UNKNOWN, int $chunk_size = UNKNOWN, int $mode = UNKNOWN): bool {}
function imagegd2(GdImage $image, ?string $file = null, int $chunk_size = UNKNOWN, int $mode = UNKNOWN): bool {}
#ifdef HAVE_GD_BMP
/** @param resource|string|null $file */
@@ -177,9 +177,9 @@ function imagefill(GdImage $image, int $x, int $y, int $color): bool {}
function imagecolorstotal(GdImage $image): int {}
function imagecolortransparent(GdImage $image, ?int $color = null): ?int {}
function imagecolortransparent(GdImage $image, ?int $color = null): int {}
function imageinterlace(GdImage $image, ?bool $enable = null): ?int {}
function imageinterlace(GdImage $image, ?bool $enable = null): bool {}
function imagepolygon(GdImage $image, array $points, int $num_points_or_color, ?int $color = null): bool {}
+5 -5
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 59256d0de105f1a2f5d5fc1e20f8090031b42a76 */
* Stub hash: 012a149dba5332fcb73544771b881fc7e6d53925 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
@@ -238,12 +238,12 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegd, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
ZEND_ARG_TYPE_INFO(0, file, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegd2, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
ZEND_ARG_TYPE_INFO(0, file, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO(0, chunk_size, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -358,12 +358,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolorstotal, 0, 1, IS_LONG,
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolortransparent, 0, 1, IS_LONG, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolortransparent, 0, 1, IS_LONG, 0)
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, color, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageinterlace, 0, 1, IS_LONG, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageinterlace, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enable, _IS_BOOL, 1, "null")
ZEND_END_ARG_INFO()
+2 -2
View File
@@ -8,14 +8,14 @@ if (!extension_loaded('gd')) die('skip gd extension not available');
<?php
$im = imagecreatetruecolor(10, 10);
imagefilledrectangle($im, 0, 0, 9, 9, imagecolorallocate($im, 255, 255, 255));
imageinterlace($im, 1);
imageinterlace($im, true);
imagegif($im, __DIR__ . 'bug77700.gif');
$im = imagecreatefromgif(__DIR__ . 'bug77700.gif');
var_dump(imageinterlace($im));
?>
--EXPECT--
int(1)
bool(true)
--CLEAN--
<?php
unlink(__DIR__ . 'bug77700.gif');
+1 -1
View File
@@ -14,4 +14,4 @@ $image = imagecreatetruecolor(100, 100);
var_dump(imageinterlace($image));
?>
--EXPECT--
int(0)
bool(false)
+3 -3
View File
@@ -12,9 +12,9 @@ if (!extension_loaded("gd")) die("skip GD not present");
$image = imagecreatetruecolor(100, 100);
var_dump(imageinterlace($image, 1));
var_dump(imageinterlace($image, true));
var_dump(imageinterlace($image));
?>
--EXPECT--
int(1)
int(1)
bool(true)
bool(true)
+4 -4
View File
@@ -13,12 +13,12 @@ if (!extension_loaded("gd")) die("skip GD not present");
$image = imagecreatetruecolor(100, 100);
//setting the interlace bit to on
imageinterlace($image, 1);
imageinterlace($image, true);
//setting de interlace bit to off
var_dump(imageinterlace($image, 0));
var_dump(imageinterlace($image, false));
var_dump(imageinterlace($image));
?>
--EXPECT--
int(0)
int(0)
bool(false)
bool(false)
+8 -4
View File
@@ -163,11 +163,11 @@ PHP_FUNCTION(dcgettext)
/* {{{ Bind to the text domain domain_name, looking for translations in dir. Returns the current domain */
PHP_FUNCTION(bindtextdomain)
{
char *domain, *dir;
char *domain, *dir = NULL;
size_t domain_len, dir_len;
char *retval, dir_name[MAXPATHLEN];
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &domain, &domain_len, &dir, &dir_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss!", &domain, &domain_len, &dir, &dir_len) == FAILURE) {
RETURN_THROWS();
}
@@ -178,6 +178,10 @@ PHP_FUNCTION(bindtextdomain)
RETURN_THROWS();
}
if (dir == NULL) {
RETURN_STRING(bindtextdomain(domain, NULL));
}
if (dir[0] != '\0' && strcmp(dir, "0")) {
if (!VCWD_REALPATH(dir, dir_name)) {
RETURN_FALSE;
@@ -272,10 +276,10 @@ PHP_FUNCTION(dcngettext)
/* {{{ Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. */
PHP_FUNCTION(bind_textdomain_codeset)
{
char *domain, *codeset, *retval = NULL;
char *domain, *codeset = NULL, *retval = NULL;
size_t domain_len, codeset_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &domain, &domain_len, &codeset, &codeset_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss!", &domain, &domain_len, &codeset, &codeset_len) == FAILURE) {
RETURN_THROWS();
}
Loaded 100 of 422 files, more files were not shown because too many files have changed in this diff. Show more