1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 16:52:18 +01:00
Commit Graph

13286 Commits

Author SHA1 Message Date
Nikita Popov
de2d38d531 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #80137
  Fix bug #80138
2020-09-29 10:59:46 +02:00
Nikita Popov
1fafcd2b28 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #80137
  Fix bug #80138
2020-09-29 10:59:32 +02:00
Matthias Karbe
f5afd0a827 Fix bug #80137
Skip getprotobyname() and getprotobynumber() tests on *nix if there
is no /etc/protocols file.

Closes GH-6193.
2020-09-29 10:58:00 +02:00
Matthias Karbe
2899137391 Fix bug #80138
Skip getservbyname() and getservbyport() tests on *nix if there is
no /etc/services file.

Closes GH-6191.
2020-09-29 10:57:20 +02:00
Nikita Popov
cafceea742 Update mbstring parameter names
Closes GH-6207.
2020-09-28 09:51:58 +02:00
Nikita Popov
8067cf4752 Use callable type in register_shutdown_function()
To make things a bit less weird, split off the function name into
a zval stored separately from the arguments. This allows us to
use normal zpp and get standard behavior.
2020-09-25 14:48:33 +02:00
Nikita Popov
43ce18f837 Add proper count() parameter type
We can make this Countable|array now.
2020-09-25 12:31:05 +02:00
Nikita Popov
56fb6864c6 Unify 32-bit/64-bit str_split tests
The 32-bit tests work on both 32-bit and 64-bit. I dropped the
64-bit variants as they only test one additional case that I don't
think adds particular value.
2020-09-25 10:03:41 +02:00
Nikita Popov
13b791c79c Normalize substr() behavior
Make the behavior of substr(), mb_substr(), iconv_substr() and
grapheme_substr() consistent when it comes to the handling of
out of bounds offsets. substr() will now always clamp out of
bounds offsets to the string boundary. Cases that previously
returned false will now return an empty string. This means that
substr() itself *always* returns a string now (like mb_substr()
already did before.)

Closes GH-6182.
2020-09-25 09:58:21 +02:00
Christoph M. Becker
1fcd6cdbb8 Fix #80139: copy_variation5.phpt fails when run on bind mount
This test case is not supposed to run on case-insensitive file system;
just checking for macOS/Windows doesn't cut it.
2020-09-23 12:14:40 +02:00
Christoph M. Becker
821f6bb511 Clean up file created during testing 2020-09-23 11:45:47 +02:00
Christoph M. Becker
05edf64436 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #76735: Incorrect message in fopen on invalid mode
2020-09-23 11:14:06 +02:00
Christoph M. Becker
a89ac98f15 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #76735: Incorrect message in fopen on invalid mode
2020-09-23 10:54:59 +02:00
Christoph M. Becker
2576c57a51 Fix #76735: Incorrect message in fopen on invalid mode
We have to log errors in `stream_opener` callbacks to the wrapper's
error log, because otherwise we may pick up an unrelated `errno` or a
most generic message.

Closes GH-6187.
2020-09-23 10:54:06 +02:00
Nikita Popov
625d8463a4 Consistent error handling for fgetcsv/fputcsv
Normalize the behavior between the file functions and those on
SplFileObject.

Be consistent about throwing regardless of whether the delimiter etc
is empty or has too many characters. I don't think it's worthwhile
to distinguish these cases.

Back when we looked into this originally, there was some hope that
we might want to add support for multiple-character delimiter etc,
but after a cursory look, I really don't think this is going to
happen (for fputcsv maybe, but for fgetcsv this just makes an already
broken function much more complicated.)

Closes GH-6188.
2020-09-23 10:11:04 +02:00
Máté Kocsis
72e8719ed0 Fix a few ZEND_UNREACHABLE() calls 2020-09-23 10:07:58 +02:00
George Peter Banyard
1e9db80d72 Tweak some macro definition on Windows
Closes GH-5606
2020-09-22 23:05:12 +01:00
Nikita Popov
c2a2d2438a Fix double free on unpack error 2020-09-22 23:31:56 +02:00
Christoph M. Becker
544dbe8ef9 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #76943: Inconsistent stream_wrapper_restore() errors
2020-09-22 16:14:03 +02:00
Christoph M. Becker
ff0f6c26c2 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #76943: Inconsistent stream_wrapper_restore() errors
2020-09-22 16:12:37 +02:00
Christoph M. Becker
5ed0602ec6 Fix #76943: Inconsistent stream_wrapper_restore() errors
If restoring of any not registered built-in wrapper is requested, the
function is supposed to fail with a warning, so we have to check this
condition first.

Furthermore, to be able to detect whether a built-in wrapper has been
changed, it is not sufficient to check whether *any* userland wrapper
has been registered, but rather whether the specific wrapper has been
modified.

Closes GH-6183.
2020-09-22 16:11:35 +02:00
Nikita Popov
de77344de2 Promote pack/unpack format errors
Errors related to invalid format strings (unlike data mismatch
errors) should throw ValueError.

Closes GH-6185.
2020-09-22 15:12:05 +02:00
Nikita Popov
048cc9ba78 Convert unpack offset warning to ValueError 2020-09-22 14:13:26 +02:00
Nikita Popov
fdd9018bdf Support uuencoding empty string
Cross checking implementations from other languages, empty strings
are always allowed. PHP's output is peculiar due to it's insistence
to encode a trailing \0, but otherwise sensible and does round-trip
as expected.
2020-09-22 12:39:39 +02:00
Nikita Popov
e60f927f05 stream_bucket_new() cannot return false
php_stream_bucket_new() is infallible.
2020-09-22 12:07:53 +02:00
Nikita Popov
9ef2c5c303 stream_get_transports/wrappers cannot return false
These may return an empty array, but not false.
2020-09-22 12:02:39 +02:00
Nikita Popov
aba0ee71b2 Don't return false for empty string in soundex()
Return "0000" instead of false to have a consistent return type.
"0000" is already a possible return value if the string doesn't
contain any letters, such as with soundex(" "). We can treat the
case of soundex("") exactly the same.
2020-09-22 11:44:35 +02:00
Levi Morrison
f26d855e29 Skip if https wrapper isn't present 2020-09-22 03:36:54 -06:00
Nikita Popov
e547ea43c1 http_build_query() cannot fail
Assert that ht is not null and make php_url_encode_hash_ex() return
void to clarify that this is an infallible function.
2020-09-22 11:30:02 +02:00
Nikita Popov
0fbebfd1ae html_entity_decode() cannot fail
php_unescape_html_entities() never returns null, so this function
can never return false.

php_unescape_html_entities() probably should be failing with OOM
for the "overflow" case, but even if it did, it would not be
signalled through a false return value.
2020-09-22 11:23:01 +02:00
Nikita Popov
84be22f1f5 Validate phonemes parameter of metaphone()
And thus avoid the false return value.
2020-09-22 11:19:02 +02:00
Nikita Popov
d0fb2f409e substr_compare() cannot return false 2020-09-22 10:54:44 +02:00
Nikita Popov
5d9ab53a5d Check string bounds in strspn/strcspn
strspn/strcspn are string search functions, and as such should throw
ValueError on out-of-bounds offsets, just like strpos etc do.
2020-09-22 10:46:50 +02:00
Nikita Popov
12e772f18d Promote substr_replace warnings
The implementation here was pretty confused. In reality the only
error condition it has right now is that for a string input,
from & length cannot be arrays.

The fact that the array lengths are the same was probably supposed
to be checked for the case of array input, as it wouldn't matter
otherwise.
2020-09-22 10:22:43 +02:00
Nikita Popov
ade57e691b substr_replace() cannot return false 2020-09-22 09:59:35 +02:00
Ikko Ashimine
8f3a38d927 Fixed minor typo in comment
Initiailize -> Initialize

Closes GH-6181.
2020-09-22 09:10:23 +02:00
George Peter Banyard
2ee7e2982f Promote count() warning to TypeError
Closes GH-6180
2020-09-21 21:29:15 +01:00
Nikita Popov
fb4554e431 Throw warning for failed object to int/float conversion
We previously couldn't increase the error level here because it
was coupled to comparison handling. This is no longer the case
in PHP 8.
2020-09-21 17:04:39 +02:00
Christoph M. Becker
3e33e1e86d Check linker compatibility directly from HMODULE
Checking the linker compatibility with extranous `ImageLoad()` calls is
possible, but unnecessary, since the modules are either already loaded
or loaded shortly afterwards, so that we can get the required
information directly from the module handles.  And actually, doing
`ImageLoad()` as well as `LoadLibrary()` leaves a tiny room for a race
condition, because both functions will lookup the module in the search
path, so there is no *guarantee* that both are dealing with the same
module.  Dropping the `ImageLoad()` calls also has the advantage to no
longer face the issue reported in bug #79557.  A very minor additional
advantage is that we no longer have to link against Imagehlp.dll.

Furthermore, there is no need to check for CRT compatibility multiple
times, so we can simplify the signature of `php_win32_crt_compatible`,
and at the same time clean up main.c a bit.

These changes require to change the signature of the exported
`php_win32_image_compatible` and `php_win32_crt_compatible` functions,
which now expect a `HMODULE` and nothing, respectively, instead of the
module name.
2020-09-21 16:25:31 +02:00
Máté Kocsis
64af12d13b Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Máté Kocsis
e950ca13ea Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Christoph M. Becker
c0f8cc1904 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #80114: parse_url does not accept URLs with port 0
2020-09-20 15:38:18 +02:00
Christoph M. Becker
105132bd6b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80114: parse_url does not accept URLs with port 0
2020-09-20 15:37:11 +02:00
Christoph M. Becker
81b2f3e5d9 Fix #80114: parse_url does not accept URLs with port 0
URIs with a 0 port are generally valid, so `parse_url()` should
recognize such URIs, but still report the port as missing.

Co-authored-by: twosee <twose@qq.com>

Closes GH-6152.
2020-09-20 15:34:45 +02:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Sara Golemon
95f2583743 Allow http tests to run in parallel by using ephemeral ports 2020-09-17 14:38:54 +00:00
Máté Kocsis
46d22e435f Change int parameter types to bool when the parameter behaves as bool
Closes GH-6148
2020-09-17 09:38:18 +02:00
Máté Kocsis
36fd95b524 Generate arginfos 2020-09-16 21:28:27 +02:00
Máté Kocsis
de912821e0 Display string default values in stubs more uniformly
Settling on using quoted string
2020-09-16 21:27:01 +02:00
Máté Kocsis
c76910cd96 Display types in stubs more uniformly
In preparation for generating method signatures for the manual.

This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types.
2020-09-16 21:19:36 +02:00