Commit Graph

1368 Commits

Author SHA1 Message Date
Niels Dossche
719fa46150
Fix Windows SKIPIF (#14219)
PHP_OS_FAMILY never has the value WIN, for Windows platforms it is the
string "Windows". As such, this test was never executed. Fix this.
2024-05-13 22:09:47 +02:00
Christoph M. Becker
4b1feda574
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-9905: constant() behaves inconsistent when class is undefined
2022-11-09 15:23:21 +01:00
Christoph M. Becker
b2186ca7c4
Fix GH-9905: constant() behaves inconsistent when class is undefined
Directly referring to a constant of an undefined throws an exception;
there is not much point in `constant()` raising a fatal error in this
case.

Closes GH-9907.
2022-11-09 15:21:50 +01:00
Michael Voříšek
60189aa96a
Skip locale tests /w musl libc (#9141) 2022-07-25 23:56:14 +01:00
Eric Norris
09237f6126
Update request startup error messages 2022-07-18 23:19:59 +01:00
Jakub Zelenka
922371f3b1
Do not send X-Powered-By if headers sent (#9039)
Co-authored-by: Eric Norris <erictnorris@gmail.com>
2022-07-18 18:01:05 +01:00
Mikhail Galanin
ffdf25a270
Add "error_log_mode" setting 2022-07-18 15:41:28 +01:00
Ayesh Karunaratne
9f8e5182a1
INI parser: Fix typo /multipler/multiplier
Closes GH-8987.
2022-07-13 12:16:26 +02:00
Dennis Snell
492af9f88e
Add ini_parse_quantity function to convert ini quantities shorthand notation to int (#8454) 2022-07-10 14:48:52 +02:00
Christoph M. Becker
3e32717c78
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7896: Environment vars may be mangled on Windows
2022-01-17 23:46:15 +01:00
Christoph M. Becker
8d2ed194bf
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-7896: Environment vars may be mangled on Windows
2022-01-17 23:45:49 +01:00
Christoph M. Becker
93a3c71eb4
Fix GH-7896: Environment vars may be mangled on Windows
When bug 77574[1] has been fixed, the fix only catered to variables
retrieved via `getenv()` with a `$varname` passed, but neither to
`getenv()` without arguments nor to the general import of environment
variables into `$_ENV` and `$_SERVER`.  We catch up on this by using
`GetEnvironmentStringsW()` in `_php_import_environment_variables()` and
converting the encoding to whatever had been chosen by the user.

[1] <https://bugs.php.net/bug.php?id=75574>

Closes GH-7928.
2022-01-17 23:44:41 +01:00
Nikita Popov
902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Nikita Popov
ee510eed68 Deprecate partially supported callables
This deprecates all callables that are accepted by
call_user_func($callable) but not by $callable(). In particular:

    "self::method"
    "parent::method"
    "static::method"
    ["self", "method"]
    ["parent", "method"]
    ["static", "method"]
    ["Foo", "Bar::method"]
    [new Foo, "Bar::method"]

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

Closes GH-7446.
2021-10-22 10:15:24 +02:00
Kamil Tekiela
c3dda473cc
Fix 'can not' in test data and in code comments 2021-10-05 09:51:58 +01:00
Nikita Popov
23e6856e41 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug #69751
2021-09-29 12:21:56 +02:00
Nikita Popov
3dfdf968e1 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix bug #69751
2021-09-29 12:21:49 +02:00
Aliaksandr Bystry
41df5c0675 Fix bug #69751
Change error message of sprintf/printf for missing/invalid position
specifier to make it clear that this is talking about the specifier,
not the number of arguments passed to the function. Also mention
the upper limit of INT_MAX.

Closes GH-7515.
2021-09-29 12:21:37 +02:00
Nikita Popov
0652e81041 Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't leak header callback if headers already sent
2021-09-16 15:31:39 +02:00
Nikita Popov
9bff96396d Don't leak header callback if headers already sent
We need to avoid storing it in the first place, as we don't
really have a good place to release it later. If headers haven't
been sent yet, send_headers will do this. sapi_deactive happens
too late in the shutdown sequence and will result in leak reports.
2021-09-16 15:31:27 +02:00
Nikita Popov
2ffa70b97c Slightly clean up is_callable implementation
And adjust an error message to line up with the error message
used for $callable() in zend_execute.c.
2021-09-02 10:37:13 +02:00
Christoph M. Becker
02b725a269
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #71542: disk_total_space does not work with relative paths
2021-08-17 11:32:24 +02:00
Christoph M. Becker
e45a063f4b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #71542: disk_total_space does not work with relative paths
2021-08-17 11:31:14 +02:00
Christoph M. Becker
f924e97269
Fix #71542: disk_total_space does not work with relative paths
For ZTS builds, we need to expand the path given to `disk_free_space()`
and `disk_total_space()` to properly support the VCWD.

Closes GH-7377.
2021-08-17 11:29:33 +02:00
Jeremy Mikola
858d0c0916 Include class name in Serializable deprecation message
The deprecation message was originally introduced in 3e6b447 (#6494).

I first encountered this notice when testing the MongoDB extension
with PHP 8.1, which produced many duplicate messages that provided
no detail about the particular class that needed to be fixed.

Closes GH-7346.
2021-08-11 10:35:47 +02:00
Nikita Popov
604848188b Add additional double to string APIs
zend_double_to_str() converts a double to string in the way that
(string) would (using %.*H using precision).

smart_str_append_double() provides some more fine control over
the precision, and whether a zero fraction should be appeneded
for whole numbers.

A caveat here is that raw calls to zend_gcvt and going through
s*printf has slightly different behavior for the degenarate
precision=0 case. zend_gcvt will add a dummy E+0 in that case,
while s*printf convert this to precision=1 and will not. I'm
going with the s*printf behavior here, which is more common,
but does result in a minor change to the precision.phpt test.
2021-08-02 16:14:53 +02:00
Nikita Popov
fc45223f85 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter name in call_user_func() error message
2021-07-29 12:49:17 +02:00
Nikita Popov
840e441d2d Fix parameter name in call_user_func() error message
This parameter name has been changed to $callback.
2021-07-29 12:48:25 +02:00
Nikita Popov
380e705fc2 Use consistent line numbers for early binding errors
Non-early-bound classes report inheritance errors at the first line
of the class, if no better line information is available (we should
really store line numbers for properties at least...) Early bound
classes report it at the last line of the class instead.

Make the error reporting consistent by always reporting at the
first line.
2021-07-28 12:35:20 +02:00
Máté Kocsis
663536d7d9
Improve class inheritance error messages (#7307) 2021-07-27 09:42:37 +02:00
Máté Kocsis
75a678a7e3
Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00
Máté Kocsis
a5360e80c2
Add support for final class constants
RFC: https://wiki.php.net/rfc/final_class_const

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-06 21:42:38 +02:00
Nikita Popov
9871a624bf Clean up some more function_exists() checks 2021-06-14 15:47:08 +02:00
Nikita Popov
7485978339
Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Ayesh Karunaratne
b8e380ab09 Update deprecation message for incompatible float to int conversion
Updates the deprecation message for implicit incompatible float to int conversion from:

```
Implicit conversion from non-compatible float %.*H to int in %s on line %d
```

to

```
Implicit conversion from float %.*H to int loses precision in %s on line %d
```

Related: #6661
2021-06-07 14:36:11 +02:00
Ayesh Karunaratne
a706d7302a Improve interface non-public method error message
Currently interface methods with visibility `private` or `protected` fail
with an error message:

  Access type for interface method A::b() must be omitted

However, explicitly setting visibility `public` is allowed and often desired.
This commit updates the error message to:

  Access type for interface method A::b() must be public
2021-06-02 20:08:36 +01:00
George Peter Banyard
b6958bb847
Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Nikita Popov
e9b005158f Fix output buffer discard on memory limit
Move this code directly into the error handler, and check the
heap->overflow flag. Discarding output here allows us to print
the normal memory limit message to standard output. Otherwise
nothing would be printed unless a different log medium was used,
which makes for a suboptimal debugging experience.
2021-05-31 16:30:36 +02:00
Peter van Dommelen
3a4ea6cb91 Don't automatically adjust memory_limit to 2M
As PHP has a minimum memory usage of 2M (size of allocator chunk),
setting a limit below that value is not meaningful and will be
automatically rounded up to the chunk size. Rather than doing this
silently, show the newly introduced error message.

The memory limit had to be increased to 2M for a number of tests.

tests/lang/bug45392 has been marked as XFAIL. This old bugfix is
not working as intended. The memory limit in main's `PG(memory_limit)`
differs from the one in zend_alloc. In zend_alloc the `AG(mm_heap)->limit`
is defined as `max(passed_value, ZEND_MM_CHUNK_SIZE)`. The check made in
an unclean shutdown will never be true unless the memory limit is lower
than ZEND_MM_CHUNK_SIZE, which happened to be the case in the test.
https://bugs.php.net/bug.php?id=45392
fcc0fdd125
2021-05-31 15:42:10 +02:00
Christoph M. Becker
fda53548b5
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:47:25 +02:00
Christoph M. Becker
a5601b2ab5
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:46:38 +02:00
Christoph M. Becker
ee9e07541f
Fix #76359: open_basedir bypass through adding ".."
We explicitly forbid adding paths with a leading `..` to `open_basedir`
at runtime.

Closes GH-7024.
2021-05-25 13:44:53 +02:00
Nikita Popov
de6e401e05
Use common formatting for backtraces (#6977)
This makes debug_print_backtrace() use the same formatting as exception
backtraces. The only difference is that the final #{main} is omitted,
because it wouldn't make sense for limited backtraces, and wasn't there
previously either.
2021-05-18 11:43:37 +02:00
Björn Tantau
d764f1dc12
Fix #77372: Retain full path of files for directory uploads (#6917)
To fix https://bugs.php.net/bug.php?id=77372 and improve support of `<input type="file" name="files" multiple webkitdirectory>` I introduced another item to the `$_FILES` array called `full_path`, containing the full filename, as supplied by the user-agent.

Co-authored-by: Björn Tantau <bjoern@bjoern-tantau.de>
2021-05-14 11:43:55 +02:00
Nikita Popov
3e6b447979 Partially deprecate Serializable
If Serializable is implemented, require that __serialize() and
__unserialize() are implemented as well, else issue a deprecation
warning.

Also deprecate use of PDO::FETCH_SERIALIZE.

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

Closes GH-6494.
2021-04-28 16:55:14 +02:00
Máté Kocsis
30a082cb16
Make some exception properties typed
Closes GH-6891
2021-04-22 10:22:50 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Max Semenik
6c9a05667b run-tests: use the EXTENSIONS section for skipping
Currently, most skip checks are just for making sure an extension is
available. Even with recent addition of skip caching, this makes tests
needlessly slow:
* Checks for the same extension in its tests can have small differences
  impacting cacheability.
* Even identical skip checks in two tests can still be executed twice if
  they're run by different workers.

To remedy this, I'm repurposing the existing --EXTENSIONS-- section of
.phpt files to specify wjich extensions are required for current test to
run. Current behavior:
1) If the extension is already visible to PHP, all is good
2) If it isn't, assume it's present as a shared module and attempt to add
   it via a command line parameter
3) If that works, all is good
4) If it doesn't, PHP fails with a cryptic error message trying to
   execute the test itself

After this commit:
1) and 2) are kept unchanged
3) Check if shared extension file from 2) is actually present
4) Skip the test if it isn't

Other benefits include clear skip reasons (vs. sometimes none in many
current skip checks) and moving test information from code to metadata,
opening more opportunities for search and analysis.

Since --EXTENSIONS-- is barely ever used, this change poses no risk of
hidden failures.

As a demonstration of the new approach, this commit migrates one
extension to it. If merged, I will migrate other extensions in
subsequent PRs.

Closes GH-6787.
2021-03-22 09:53:38 +01:00
Ilija Tovilo
269c8dac1d
Implement enums
RFC: https://wiki.php.net/rfc/enumerations

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

Closes GH-6489.
2021-03-17 19:08:03 +01:00
Dmitry Stogov
72c3ededed Change the order of properties used for var_dump(), serialize(), comparison, etc.
Now properties are ordered according to their layout in zend_object structure.
2021-03-01 13:29:49 +03:00