Fix #79986: str_ireplace bug with diacritics characters
`tolower()` returns an `int`, so we must not convert to `char` which
may be `signed` and as such may be subject to overflow (actually,
implementation defined behavior).
Nikita Popov [Mon, 24 Aug 2020 08:15:57 +0000 (10:15 +0200)]
Check variadic parameter for type and duplicate name
Set HAS_TYPE_HINTS flag if the variadic parameter is types as well,
and make sure it has a distinct name. This was previously missed,
because the variadic parameter is not part of num_args.
Kees Cook [Sun, 23 Aug 2020 15:39:53 +0000 (08:39 -0700)]
sapi/fpm/config.m4: check for libapparmor's aa_change_profile()
The fpm code actually uses aa_change_profile(), not change_hat(). Test
for the correct function. (libapparmor always has both, so this is just
a correctness fix.)
Tyson Andre [Sun, 23 Aug 2020 15:12:44 +0000 (11:12 -0400)]
Update PHP-Parser from 4.3.0 to 4.9.0
PHP-Parser 4.3.0 failed to recognize that the `match` keyword could be
used as a class constant name.
4.9.0 also adds support for keywords in namespaced names.
See https://github.com/nikic/PHP-Parser/releases
So forcing regeneration of spl_iterators.stub.php failed.
PECL extensions using gen_stub.php would also be affected
by the same issue.
```
ext/spl/spl_iterators.stub.php
public function __construct(Iterator $iterator, string $regex,
int $mode = self::MATCH, int $flags = 0, int $preg_flags = 0) {}
```
Testing: I successfully regenerated stubs by setting forceRegeneration to true
and running `touch **/*.stub.php; make`.
The stubs did not change, as expected.
If we do not specify the exact version of the .NET framework to use,
the default CLR is loaded, which is typically CLR 2, which is very old.
Therefore, we introduce a `PHP_INI_SYSTEM` setting, which allows users
to choose the desired .NET framework version. The value of the setting
are the first three parts of the framework's version number, separated
by dots, and prefixed with "v", e.g. "v4.0.30319". If the value of the
INI setting is `NULL` (the default) or an empty string, the default CLR
is used.
Internally, we switch from the most generic `CoCreateInstance()` to
`CorBindToRuntime()` which is implemented in mscoree.dll. To avoid the
hard dependency to that library, we load dynamically.
So this fix is supposed to be fully backwards compatible.
Tyson Andre [Mon, 10 Aug 2020 02:07:33 +0000 (22:07 -0400)]
Add `run-tests.php --context [n]` option.
Mentioned in https://github.com/php/php-src/pull/5965#discussion_r467621123
This PR proposes 3 lines of context so the impact can be seen in tests.
Other `diff` programs show around 3 lines of context.
(This helps indicate exactly which position a test should be updated
to add a new expected line at)
Use the mapping for choosing order to display diffs
Properly include context in cases where the expected output had more lines than
the actual output, e.g.
```
--FILE--
A
A1
A
C
NEARBY
--EXPECTF--
A
B
A1
B
A
B
A
B
NEARBY
```
We have to ensure that the attempted connection to the MySQL server
fails, and do that by passing an unknown host instead of falling back
to localhost.
Nikita Popov [Fri, 14 Aug 2020 13:07:55 +0000 (15:07 +0200)]
Use variadic signature for PDOStatement::fetchAll()
The current signature is incorrect, because the $ctor_args parameter
is not required to be an array (it can at least also be null, and
isn't enforced by an exception anyway).
I'm going for the variadic signature here, because we already use
the same variadic signature in PDO::query() and
PDOStatement::setFetchMode(), all of them accepting essentially the
same arguments.
Nikita Popov [Fri, 14 Aug 2020 10:44:13 +0000 (12:44 +0200)]
Don't assert mysql->mysql is non-null
There is an edge case in constructor behavior where we can end up
with mysql->mysql being NULL (rather than mysql itself already being
NULL). I think that ultimately that's a bug in the constructor code,
and we should probably be destroying the outer structure on
construction failure as well. However it's pretty hard to unravel
with when considering all the construction permutations.
Nikita Popov [Fri, 14 Aug 2020 08:52:34 +0000 (10:52 +0200)]
Return empty string from SplFileInfo::getPathname()
Instead of false. This is consistent with how other methods like
SplFileInfo::getPath() behave. It's also a requirement before
SplFileInfo::__toString() calls SplFileInfo::getPathname() and
needs to return a string.
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.