Nikita Popov [Fri, 14 Aug 2020 08:22:42 +0000 (10:22 +0200)]
Fix bug #78770
Refactor the zend_is_callable implementation to check callability
at a particular frame (this is an implementation detail for now,
but could be exposed in the API if useful). Pick the first parent
user frame as the one to check.
Nikita Popov [Wed, 24 Jun 2020 15:00:32 +0000 (17:00 +0200)]
Switch to mime-db as source of extension => MIME map
The Apache MIME type map is not actively maintained anymore, so
this switches to jshttp/mime-db, which seems to be the de-facto
standard in this area now. This avoid the need to patch in our
own MIME types over time.
Nikita Popov [Wed, 12 Aug 2020 15:06:02 +0000 (17:06 +0200)]
Make strftime tests musl compatible
* Remove usage of strftime() in favor of date() in cases where
we are not specifically testing strftime(). We implement
date() ourselves, and as such are insulated from implementation-
defined behavior.
* Add skipif for broken strftime() %Z support. We have decided
not to work around the issue for musl using manual expansion,
as people should not be using this function anyway, and it is
slated for future deprecation.
* Don't test strftime() with invalid format specifier. The
behavior is implementation-dependent.
Tyson Andre [Sun, 9 Aug 2020 15:26:51 +0000 (11:26 -0400)]
Support NO_COLOR environment variable in run-tests.php
And add a --color option for run-tests.php
See https://no-color.org/
> an informal standard is hereby proposed:
>
> All command-line software which outputs text with ANSI color added should check
> for the presence of a `NO_COLOR` environment variable that, when present
> (regardless of its value), prevents the addition of ANSI color.
Nikita Popov [Wed, 12 Aug 2020 08:32:05 +0000 (10:32 +0200)]
Disable report_zend_debug by default
We might just want to drop this completely, but at least don't
enable it by default. It already gets disabled by a number of
SAPIs, but we should make that the default state.
Tyson Andre [Mon, 10 Aug 2020 23:48:41 +0000 (19:48 -0400)]
Rename standard array function parameters to $array
This is targeting 8.0.
`$arg` seems like a poor choice of a name,
especially if the function were to have arguments added.
In many cases, the php.net documentation already has $array for these functions.
E.g. https://www.php.net/manual/en/function.array-intersect.php
I'd assume that since named arguments was added to 8.0 near the feature freeze,
PHP's maintainers had planned to make the names consistent
and gradually use the same name for docs and implementation.
Ahmed Abdou [Sun, 17 Feb 2019 21:59:00 +0000 (22:59 +0100)]
Fix #64705 errorInfo property of PDOException is null when PDO::__construct() fails
PDO driver constructors are throwing PdoException without setting
errorInfo, so create a new reusable function that throws exceptions
for PDO and will also set the errorInfo. Use this function in
pdo_mysql, pdo_sqlite, and pdo_pgsql.
Fix bug #75785 by attempt switching endianness on Maker's Note
Different manufacturer models may come with a
different endianness (motorola/intel) format. In
order to avoid a big refactor and a gigantic lookup
table, this commit simply attempts to switch the
endianness and proceed when values are acceptable.
Nikita Popov [Tue, 11 Aug 2020 12:42:13 +0000 (14:42 +0200)]
Fixed bug #79917
op_arrays can be shared on two levels: Either the op_array is
completely shared, or it is distinct but shares all members
(apart from static_variables).
The the op_array is distinct, we need to make sure to properly
initialize the MAP_PTR structures.
The `cached` out parameter of `php_com_load_typelib_via_cache()` was
meant to signal whether a particular typelib actually has been cached.
This is not really relevant, though, for the imagined purposes, and
since the parameter is no longer really used, we removed it altohether.
Fix #48585: com_load_typelib holds reference, fails on second call
Whether the type library is cached is actually irrelevant here; what
matters is that the symbols are imported, and since these are not
cached, we have to import them for every request. And we cannot cache
the symbols, because the import depends on the current codepage, but
the codepage is a `PHP_INI_ALL` setting.
Nikita Popov [Mon, 10 Aug 2020 10:54:02 +0000 (12:54 +0200)]
Fixed bug #62294
The primary issue was already resolved in 7c3e487289ec41e560cf7a77e36eb43da2234f33,
but the particular example used in this bug report ran into an
additional issue on PHP 8, because I forgot to drop a number of
zend_bailout calls when switch require failure to throw.
Fix #79922: Crash after multiple calls to xml_parser_free()
We must not call `zend_list_delete()` in resource closer functions
exposed to userland, because decreasing the refcount there leads to
use-after-free scenarios. In this case, commit 4a42fbb worked for
typical use-cases where `xml_parser_free()` has been called exactly
once for the resource, because there is an internal zval (`->index`)
referencing the same resource which already increased the refcount by
one. However, when `xml_parser_free()` is called multiple times on the
same XML parser resource, the resource would be freed prematurely.
Instead we forcefully close the resource in `xml_parser_free()`. We
also could decrease the refcount of the resource there, but that would
require to call `xml_parser_free()` which is somewhat uncommon, and
would be particularly bad wrt. PHP 8 where that function is a NOP, and
as such doesn't have to be called. So we do no longer increase the
refcount of the resource when copying it to the internal zval, and let
the usualy refcounting semantics take care of the resource destruction.
Nikita Popov [Thu, 6 Aug 2020 11:18:29 +0000 (13:18 +0200)]
Improve X509_PKEY management in OpenSSL
Remove the free_pkey argument from php_openssl_pkey_from_zval,
instead return an EVP_PKEY that always needs to be freed
(by incrementing refcount if necessary).
This makes the code simpler and fixes a number of bugs in the
existing handling.
Nikita Popov [Mon, 10 Aug 2020 08:28:13 +0000 (10:28 +0200)]
Fixed bug #79948
Make sure we don't execute further scripts if one of them encountered
an exit exception.
Also make sure that we free file handles that end up unused due to
an early abort in php_execute_scripts(), which turned up as an
issue in the added test case.
Finally, make use of EG(exit_status) in the places where we
zend_eval_string_ex, instead of unconditionally assigning exit
code 254. If an error occurs, the error handler will already set
exit status 255.
Nikita Popov [Mon, 10 Aug 2020 08:38:33 +0000 (10:38 +0200)]
Fixed bug #77561
Unconditionally strip shebang lines when using the CLI SAPI,
independently of whether they occur in the primary or non-primary
script. It's unlikely that someone intentionally wants to print
that shebang line when including a script, and this regularly
causes issues when scripts are used in multiple contexts, e.g.
for direct invocation and as a phar bootstrap.
Nikita Popov [Mon, 10 Aug 2020 08:08:31 +0000 (10:08 +0200)]
Fixed bug #79947
Move the FREE_OP for op_data out of the zend_binary_assign_op_dim_slow()
slow path, so it can be used by the other error path as well. This
makes ASSIGN_DIM_OP structurally more similar to ASSIGN_DIM.
Nikita Popov [Mon, 10 Aug 2020 07:50:55 +0000 (09:50 +0200)]
Fixed bug #79946
Declare __STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS via -D
to make sure they are declared before the first stdint.h include.
We also define these in php_stdint.h, but don't always include that
file first.
This is necessary for old compilers that use C99 rather than C11
semantics for stdint.h.
Nikita Popov [Fri, 7 Aug 2020 14:05:24 +0000 (16:05 +0200)]
Remove giconv support
The best information I was able to find about this is this mail
from 2009 which indicates that giconv is an old FreeBSD iconv
implementation that has long since been superseded by libiconv.