]> granicus.if.org Git - php/log
php
4 years agocURL: make possible to send file from buffer string
Alexander Moskalev [Thu, 26 Nov 2020 07:30:02 +0000 (10:30 +0300)]
cURL: make possible to send file from buffer string

Add CURLStringFile class which works similarly to CURLFile, but
uploads a file from a string rather than a file. This avoids the
need to create a temporary file, or use of a data:// stream.

Basic usage:

    $file = new CURLStringFile($data, 'filename.txt', 'text/plain');
    curl_setopt($curl, CURLOPT_POSTFIELDS, ['file' => $file]);

Closes GH-6456.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 16 Feb 2021 09:16:13 +0000 (10:16 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Increase timeout on asan job

4 years agoIncrease timeout on asan job
Nikita Popov [Tue, 16 Feb 2021 09:15:08 +0000 (10:15 +0100)]
Increase timeout on asan job

Regularly runs against the 5:10 hour limit on master. Increase it
to 6:00 hours.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 16 Feb 2021 09:12:59 +0000 (10:12 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Suppress OpenSSL error on missing optional config

4 years agoMerge branch 'PHP-7.4' into PHP-8.0
Nikita Popov [Tue, 16 Feb 2021 09:12:42 +0000 (10:12 +0100)]
Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Suppress OpenSSL error on missing optional config

4 years agoSuppress OpenSSL error on missing optional config
Nikita Popov [Mon, 15 Feb 2021 14:54:49 +0000 (15:54 +0100)]
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.

4 years agoDelref only after successful allocation
Nikita Popov [Tue, 16 Feb 2021 08:55:02 +0000 (09:55 +0100)]
Delref only after successful allocation

Otherwise we may have inconsistent refcounts after OOM.

I expect this problem is much more prevalent, but this at least
fixes some string/array separation cases.

Fixes oss-fuzz #30999.

4 years agoMerge branch 'PHP-8.0'
Christoph M. Becker [Mon, 15 Feb 2021 23:30:03 +0000 (00:30 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Adapt test case for libcurl 7.75.0+

4 years agoAdapt test case for libcurl 7.75.0+
Christoph M. Becker [Mon, 15 Feb 2021 23:17:13 +0000 (00:17 +0100)]
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.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Mon, 15 Feb 2021 14:34:54 +0000 (15:34 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fixed bug #80747

4 years agoMerge branch 'PHP-7.4' into PHP-8.0
Nikita Popov [Mon, 15 Feb 2021 14:34:11 +0000 (15:34 +0100)]
Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fixed bug #80747

4 years agoFixed bug #80747
Nikita Popov [Mon, 15 Feb 2021 14:33:42 +0000 (15:33 +0100)]
Fixed bug #80747

If RSA key generation fails, actually report that failure.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Mon, 15 Feb 2021 13:59:07 +0000 (14:59 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix symtable cache being used while cleaning symtable

4 years agoMerge branch 'PHP-7.4' into PHP-8.0
Nikita Popov [Mon, 15 Feb 2021 13:58:59 +0000 (14:58 +0100)]
Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix symtable cache being used while cleaning symtable

4 years agoFix symtable cache being used while cleaning symtable
Nikita Popov [Mon, 15 Feb 2021 13:52:38 +0000 (14:52 +0100)]
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.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Mon, 15 Feb 2021 11:43:50 +0000 (12:43 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix assertion failure in cufa optimization with named args

4 years agoFix assertion failure in cufa optimization with named args
Nikita Popov [Mon, 15 Feb 2021 11:42:48 +0000 (12:42 +0100)]
Fix assertion failure in cufa optimization with named args

Fixes oss-fuzz#30764.

4 years agoUse typed proprety for Transliterator::$id
Nikita Popov [Mon, 15 Feb 2021 11:25:55 +0000 (12:25 +0100)]
Use typed proprety for Transliterator::$id

This is a read-only property for which Transliterator internally
assigns a string value.

Also clean up the code handling this property a bit.

4 years agoUsed typed properties for reflection $name and $class
Nikita Popov [Mon, 15 Feb 2021 11:08:15 +0000 (12:08 +0100)]
Used typed properties for reflection $name and $class

These are read-only properties, and Reflection makes sure to assign
only strings.

4 years agoGenerate class entries for snmp, soap, sockets, sodium, sqlite3, sysv*, tidy
Máté Kocsis [Mon, 15 Feb 2021 09:00:46 +0000 (10:00 +0100)]
Generate class entries for snmp, soap, sockets, sodium, sqlite3, sysv*, tidy

Closes GH-6696

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Mon, 15 Feb 2021 10:33:01 +0000 (11:33 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix #78680: mysqlnd pam plugin missing terminating null

4 years agoMerge branch 'PHP-7.4' into PHP-8.0
Nikita Popov [Mon, 15 Feb 2021 10:32:41 +0000 (11:32 +0100)]
Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix #78680: mysqlnd pam plugin missing terminating null

4 years agoFix #78680: mysqlnd pam plugin missing terminating null
Daniel Black [Fri, 5 Feb 2021 05:54:08 +0000 (16:54 +1100)]
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.

4 years agoAvoid repeatedly calling strlen in FPM setproctitle implementation
David Carlier [Sat, 13 Feb 2021 10:26:43 +0000 (10:26 +0000)]
Avoid repeatedly calling strlen in FPM setproctitle implementation

Closes GH-6689.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Mon, 15 Feb 2021 09:38:32 +0000 (10:38 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix leak when breaking out of FilesystemIterator
  Fixed bug #80600

4 years agoMerge branch 'PHP-7.4' into PHP-8.0
Nikita Popov [Mon, 15 Feb 2021 09:38:21 +0000 (10:38 +0100)]
Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix leak when breaking out of FilesystemIterator

4 years agoFix leak when breaking out of FilesystemIterator
Nikita Popov [Mon, 15 Feb 2021 09:36:48 +0000 (10:36 +0100)]
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.

4 years agoPersist class name before methods, because it may be used insted of "self"
Dmitry Stogov [Mon, 15 Feb 2021 09:33:53 +0000 (12:33 +0300)]
Persist class name before methods, because it may be used insted of "self"

4 years agoCI: add --depth 1 to git clone for speed
Max Semenik [Sat, 13 Feb 2021 17:22:26 +0000 (20:22 +0300)]
CI: add --depth 1 to git clone for speed

Closes GH-6690.

4 years agoUse VM_MAKE_TAG for macos memory tag
David CARLIER [Sat, 13 Feb 2021 07:58:48 +0000 (07:58 +0000)]
Use VM_MAKE_TAG for macos memory tag

In case Apple changes the meaning of the macro in the future.

Closes GH-6687.

4 years agoRemove stray mentions of mbstring.func_overload
Max Semenik [Sat, 13 Feb 2021 09:24:54 +0000 (12:24 +0300)]
Remove stray mentions of mbstring.func_overload

This feature has been completely removed.

Closes GH-6688.

4 years agoFix failures due to new deprecations
Christopher Jones [Mon, 15 Feb 2021 01:15:44 +0000 (12:15 +1100)]
Fix failures due to new deprecations

4 years agoGenerate class entries from stubs for phar, posix, pspell, readline, reflection,...
Máté Kocsis [Sun, 14 Feb 2021 14:21:24 +0000 (15:21 +0100)]
Generate class entries from stubs for phar, posix, pspell, readline, reflection, session, shmop

Closes GH-6692

4 years agoGenerate class entries from stubs for oci8, odbc, openssl, pcntl, pdo, pgsql
Máté Kocsis [Sun, 14 Feb 2021 11:00:03 +0000 (12:00 +0100)]
Generate class entries from stubs for oci8, odbc, openssl, pcntl, pdo, pgsql

Closes GH-6691

4 years agoGenerate zend class entries based on stubs
Máté Kocsis [Fri, 12 Feb 2021 22:33:09 +0000 (23:33 +0100)]
Generate zend class entries based on stubs

Closes GH-6685

4 years agoEnable class entry generation for sapi extensions
Máté Kocsis [Sun, 14 Feb 2021 11:03:48 +0000 (12:03 +0100)]
Enable class entry generation for sapi extensions

4 years agoOptimize Traversable unpacking in zend_vm_def.h
Tyson Andre [Sat, 13 Feb 2021 00:42:03 +0000 (19:42 -0500)]
Optimize Traversable unpacking in zend_vm_def.h

The C compiler sees that a dynamic function is being called, so it cannot infer
that iter->funcs has not changed.

This results in more assembly instructions and slightly more time to execute that code
path.

Unpacking traversables to arrays(`ZEND_ADD_ARRAY_UNPACK`),
starting foreach loops (`ZEND_FE_FETCH*`), etc. are affected.

```
<?php
/*
 * Before: 1.576 seconds
 * After:  1.474 seconds
 */
function example() {
    $start = hrtime(true);
    $it = new SplFixedArray(1000);
    $total = 0;
    for ($i = 0; $i < 100000; $i++) {
        $total += count([...$it]);
    }
    $end = hrtime(true);
    printf("Elapsed: %.6f\n", ($end - $start) / 1_000_000_000);
}
example();
```

4 years agoFixed bug #80600
Benjamin Eberlei [Fri, 12 Feb 2021 16:16:48 +0000 (17:16 +0100)]
Fixed bug #80600

4 years agoRevert "Implement fetching TLS TCB offset on MacOS"
Nikita Popov [Fri, 12 Feb 2021 14:16:05 +0000 (15:16 +0100)]
Revert "Implement fetching TLS TCB offset on MacOS"

This reverts commit 1106ff9a0e420e043c2e56c8ca00db85f1b85ee6.

Looks like this sauses segfaults on MacOs ZTS with JIT.

4 years agoDeprecate passing null to non-nullable arg of internal function
Nikita Popov [Mon, 30 Nov 2020 15:45:48 +0000 (16:45 +0100)]
Deprecate passing null to non-nullable arg of internal function

This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Thu, 11 Feb 2021 15:50:14 +0000 (16:50 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fixed bug #80718

4 years agoFixed bug #80718
Nikita Popov [Thu, 11 Feb 2021 15:49:39 +0000 (16:49 +0100)]
Fixed bug #80718

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Thu, 11 Feb 2021 15:14:12 +0000 (16:14 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Fixed bug #80719

4 years agoMerge branch 'PHP-7.4' into PHP-8.0
Nikita Popov [Thu, 11 Feb 2021 15:13:56 +0000 (16:13 +0100)]
Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fixed bug #80719

4 years agoFixed bug #80719
Nikita Popov [Thu, 11 Feb 2021 15:12:06 +0000 (16:12 +0100)]
Fixed bug #80719

4 years agoImplement fetching TLS TCB offset on MacOS
David Carlier [Mon, 1 Feb 2021 17:26:39 +0000 (17:26 +0000)]
Implement fetching TLS TCB offset on MacOS

Tested with php-cgi and wordpress and 1255 for jit settings.

Closes GH-6659.

4 years agoAllow all scalar types in ini_set()
Nikita Popov [Thu, 11 Feb 2021 09:42:55 +0000 (10:42 +0100)]
Allow all scalar types in ini_set()

This changes ini_set() to accept all scalar types
(string|int|float|bool|null) for the new value. The idea here is
that while the INI system ultimately works with strings, its value
interpretation is designed to be consistent with PHP's casting rules,
e.g. "1" and "" are interpreted as boolean true and false respectively.

I personally believe that writing ini_set('precision', 10) makes more
sense than ini_set('precision', '10'), and find strict_types to be
unnecessarily pedantic here.

Closes GH-6680.

4 years agoAvoid useless SHM data duplication
Dmitry Stogov [Thu, 11 Feb 2021 13:51:08 +0000 (16:51 +0300)]
Avoid useless SHM data duplication

4 years agoFix typo in warnings_during_sccp
Tyson Andre [Thu, 11 Feb 2021 13:23:01 +0000 (08:23 -0500)]
Fix typo in warnings_during_sccp

Should be capture_warnings_during_sccp

Related to 4c088c5da7fb96380a4cfc420d272075b40b6141

4 years agoSort some decls in spl_iterators.h
Levi Morrison [Thu, 11 Feb 2021 12:11:11 +0000 (05:11 -0700)]
Sort some decls in spl_iterators.h

There are enough of them that sorting makes it a bit nicer.

4 years agoHandle warnings during sccp function evaluation
Nikita Popov [Thu, 11 Feb 2021 11:31:36 +0000 (12:31 +0100)]
Handle warnings during sccp function evaluation

Some upcoming changes like https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
will make it somewhat inconvenient to determine whether a given
function invocation will generate a diagnostic. Rather than trying
to exclude this in advance, call the function with diagnostics
suppressed, and check whether anything was thrown.

This adds a new EG flag that is kept specific to the SCCP use-case.
This does not use the error_cb hook as it is a (non-TLS) global,
and doesn't fully suppress error handling besides.

Test this by removing the in advance checks for implode and array_flip.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Thu, 11 Feb 2021 10:44:36 +0000 (11:44 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Update func info after password_get_info() change

4 years agoUpdate func info after password_get_info() change
Nikita Popov [Thu, 11 Feb 2021 10:44:14 +0000 (11:44 +0100)]
Update func info after password_get_info() change

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Thu, 11 Feb 2021 09:23:09 +0000 (10:23 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Don't return null from password_get_info()

4 years agoDon't return null from password_get_info()
Nikita Popov [Thu, 11 Feb 2021 09:21:31 +0000 (10:21 +0100)]
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.

4 years agorun-tests: fix JUnit counts
Max Semenik [Wed, 10 Feb 2021 22:56:59 +0000 (01:56 +0300)]
run-tests: fix JUnit counts

In 19680f886f, I forgot about my own TODO. At least, now I understand what
this line was about :P

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Thu, 11 Feb 2021 08:42:05 +0000 (09:42 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Don't throw additional Error in require_once if exception already thrown

4 years agoDon't throw additional Error in require_once if exception already thrown
Nikita Popov [Thu, 11 Feb 2021 08:40:19 +0000 (09:40 +0100)]
Don't throw additional Error in require_once if exception already thrown

As pointed out in comments on bug #66216.

4 years agoLink unbound simple classes (without parent/intefaces/traits) in first place.
Dmitry Stogov [Wed, 10 Feb 2021 20:57:50 +0000 (23:57 +0300)]
Link unbound simple classes (without parent/intefaces/traits) in first place.

4 years agoUnserialize op_array->scope before passing to zend_file_cache_unserialize_type().
Dmitry Stogov [Wed, 10 Feb 2021 20:55:59 +0000 (23:55 +0300)]
Unserialize op_array->scope before passing to zend_file_cache_unserialize_type().
Don't use scope of closures.

4 years agoUse zend_type.ce_cache__ptr for caching class resulution during argument/result type...
Dmitry Stogov [Wed, 10 Feb 2021 15:00:00 +0000 (18:00 +0300)]
Use zend_type.ce_cache__ptr for caching class resulution during argument/result type checks

4 years agoFixed map_ptr slot sharing for trait/self
Dmitry Stogov [Wed, 10 Feb 2021 14:59:11 +0000 (17:59 +0300)]
Fixed map_ptr slot sharing for trait/self

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Wed, 10 Feb 2021 14:33:25 +0000 (15:33 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Make mysqli_ssl_set() arguments nullable

4 years agoMake mysqli_ssl_set() arguments nullable
Nikita Popov [Wed, 10 Feb 2021 14:31:27 +0000 (15:31 +0100)]
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.

4 years agoReuse single map_ptr slot for indentical class names
Dmitry Stogov [Wed, 10 Feb 2021 12:22:09 +0000 (15:22 +0300)]
Reuse single map_ptr slot for indentical class names

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Wed, 10 Feb 2021 11:21:15 +0000 (12:21 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Make finfo_open() $magic_database nullable

4 years agoMake finfo_open() $magic_database nullable
Nikita Popov [Wed, 10 Feb 2021 11:18:42 +0000 (12:18 +0100)]
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.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Wed, 10 Feb 2021 11:04:05 +0000 (12:04 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Don't pass null action to __doRequest

4 years agoDon't pass null action to __doRequest
Nikita Popov [Wed, 10 Feb 2021 11:00:20 +0000 (12:00 +0100)]
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...

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Wed, 10 Feb 2021 10:19:15 +0000 (11:19 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Clarify that location is required in do_request
  Regenerate arginfo file

4 years agoClarify that location is required in do_request
Nikita Popov [Wed, 10 Feb 2021 10:18:20 +0000 (11:18 +0100)]
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.

4 years agoRegenerate arginfo file
Nikita Popov [Wed, 10 Feb 2021 10:18:06 +0000 (11:18 +0100)]
Regenerate arginfo file

Somehow missed this in the previous commit.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Wed, 10 Feb 2021 09:52:28 +0000 (10:52 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Accept null $location in SoapClient::__setLocation()

4 years agoAccept null $location in SoapClient::__setLocation()
Nikita Popov [Wed, 10 Feb 2021 09:50:42 +0000 (10:50 +0100)]
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).

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Wed, 10 Feb 2021 09:37:53 +0000 (10:37 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Make SoapVar arguments nullable

4 years agoMake SoapVar arguments nullable
Nikita Popov [Wed, 10 Feb 2021 09:36:32 +0000 (10:36 +0100)]
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).

4 years agoMerge branch 'PHP-8.0'
Máté Kocsis [Tue, 9 Feb 2021 21:42:48 +0000 (22:42 +0100)]
Merge branch 'PHP-8.0'

4 years agoAdd missing classes to stubs
Máté Kocsis [Tue, 9 Feb 2021 21:38:06 +0000 (22:38 +0100)]
Add missing classes to stubs

4 years agoOptimize ZEND_COUNT opcodes on arrays in the jit
Tyson Andre [Sat, 16 May 2020 21:32:16 +0000 (17:32 -0400)]
Optimize ZEND_COUNT opcodes on arrays in the jit

Avoid the overhead of a call and checking types
when the argument is definitely an array.
Avoid the overhead of gc when `__destruct` won't get called.

This seemed cheap enough to check for in the jit.

Because of https://wiki.php.net/rfc/restrict_globals_usage
we can be sure in the ZEND_COUNT handler that the array count does not have to
be recomputed in php 8.1.

The below example took 0.854 seconds before the optimization,
and 0.564 seconds after the optimization, giving the same result

```php
<?php
/** @jit */
function bench_count(int $n): int {
    $total = 0;
    $arr = [];
    for ($i = 0; $i < $n; $i++) {
        $arr[] = $i;
        $total += count($arr);
    }
    return $total;
}

function main() {
    $n = 1000;
    $iterations = 50000;
    $start = microtime(true);
    $result = 0;
    for ($i = 0; $i < $iterations; $i++) {
        $result += bench_count($n);
    }
    $elapsed = microtime(true) - $start;

    printf("Total for n=%d, iterations=%d = %d, elapsed=%.3f\n", $n, $iterations, $result, $elapsed);
}
main();
```

Before

```asm
mov $0x7feb8cf8a858, %r15
mov $ZEND_COUNT_SPEC_CV_UNUSED_HANDLER, %rax
call *%rax
```

After

```asm
mov 0x70(%r14), %rdi - Copy the count from the `zend_array*` pointer
mov %rdi, (%rax)     - Store the count in the destination's value
mov $0x4, 0x8(%rax)  - Store IS_LONG(4) in the destination's type
```

And add tracing jit support

Closes GH-5584

4 years agoUse IS_ALIAS_PTR to make distinct between aliasses and real classes
Dmitry Stogov [Tue, 9 Feb 2021 21:00:55 +0000 (00:00 +0300)]
Use IS_ALIAS_PTR to make distinct between aliasses and real classes

4 years agoAdded Inheritance Cache.
Dmitry Stogov [Tue, 9 Feb 2021 19:53:57 +0000 (22:53 +0300)]
Added Inheritance Cache.

This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 9 Feb 2021 14:19:56 +0000 (15:19 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Properly check imagegd() signature
  Make imagegd $file parameter nullable

4 years agoProperly check imagegd() signature
Nikita Popov [Tue, 9 Feb 2021 14:18:59 +0000 (15:18 +0100)]
Properly check imagegd() signature

Unlike imagegd2(), this function only accepts two parameters,
so we should be checking for that.

4 years agoMake imagegd $file parameter nullable
Nikita Popov [Tue, 9 Feb 2021 14:15:20 +0000 (15:15 +0100)]
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...

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 9 Feb 2021 13:37:41 +0000 (14:37 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Use E_ERROR to report arginfo/zpp mismatch
  Make NumberFormatter ctor $pattern nullable
  Make IntlDateFormatter ctor $pattern nullable

4 years agoUse E_ERROR to report arginfo/zpp mismatch
Nikita Popov [Tue, 9 Feb 2021 13:32:17 +0000 (14:32 +0100)]
Use E_ERROR to report arginfo/zpp mismatch

When E_CORE_ERROR is used, we don't get correct file/line information.

4 years agoMake NumberFormatter ctor $pattern nullable
Nikita Popov [Tue, 9 Feb 2021 13:18:18 +0000 (14:18 +0100)]
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

4 years agoMake IntlDateFormatter ctor $pattern nullable
Nikita Popov [Tue, 9 Feb 2021 13:23:42 +0000 (14:23 +0100)]
Make IntlDateFormatter ctor $pattern nullable

The implementation already made this argument nullable, but it
was not reflected in the stub.

4 years agoRemove a few more unnecessary @generate-function-entries annotations
Máté Kocsis [Tue, 9 Feb 2021 12:34:25 +0000 (13:34 +0100)]
Remove a few more unnecessary @generate-function-entries annotations

4 years agoGenerate ext/intl class entries from stubs
Máté Kocsis [Fri, 5 Feb 2021 19:57:57 +0000 (20:57 +0100)]
Generate ext/intl class entries from stubs

Closes GH-6670

4 years agoImplicitly enable function entry generation when class entry generation is enabled
Máté Kocsis [Mon, 8 Feb 2021 19:08:11 +0000 (20:08 +0100)]
Implicitly enable function entry generation when class entry generation is enabled

Closes GH-6675

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 9 Feb 2021 11:57:58 +0000 (12:57 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Make Phar $fileNotFoundScript nullable

4 years agoMake Phar $fileNotFoundScript nullable
Nikita Popov [Tue, 9 Feb 2021 11:55:33 +0000 (12:55 +0100)]
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.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 9 Feb 2021 11:29:50 +0000 (12:29 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Make createDocument() $namespace nullable

4 years agoMake createDocument() $namespace nullable
Nikita Popov [Tue, 9 Feb 2021 11:28:28 +0000 (12:28 +0100)]
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.

4 years agoMerge branch 'PHP-8.0'
Nikita Popov [Tue, 9 Feb 2021 11:20:56 +0000 (12:20 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Make getElementsByTagNameNS $namespace nullable

4 years agoMake getElementsByTagNameNS $namespace nullable
Nikita Popov [Tue, 9 Feb 2021 11:19:44 +0000 (12:19 +0100)]
Make getElementsByTagNameNS $namespace nullable

According to the DOM specification, this argument is supposed to
be nullable.

4 years agoAdd support for string keys in array unpacking
Nikita Popov [Thu, 7 Jan 2021 09:49:50 +0000 (10:49 +0100)]
Add support for string keys in array unpacking

This adds support for:

    $array1 = ['a' => 1, 'b' => 2];
    $array2 = ['b' => 3, 'c' => 4];
    $array = [...$array1, ...$array2];
    // => ['a' => 1, 'b' => 3, 'c' => 4]

RFC: https://wiki.php.net/rfc/array_unpacking_string_keys

Closes GH-6584.

4 years agoRemove usage of float keys in arrays
George Peter Banyard [Wed, 3 Feb 2021 01:02:13 +0000 (01:02 +0000)]
Remove usage of float keys in arrays

Also make test output not produce trailling whitespaces

Closes GH-6662

4 years agoMerge branch 'PHP-8.0'
Christoph M. Becker [Mon, 8 Feb 2021 22:13:19 +0000 (23:13 +0100)]
Merge branch 'PHP-8.0'

* PHP-8.0:
  Avoid C4090 level 1 warning