Commit Graph

1337 Commits

Author SHA1 Message Date
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
George Peter Banyard
3a4b89661e Remove quicktester
This is barely used and more of a hinderence than anything else

Closes GH-6712
2021-02-25 17:39:31 +00:00
Nikita Popov
9be0ee4309 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #42560
2021-01-19 11:44:49 +01:00
Nikita Popov
1bdd8f7ae4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #42560
2021-01-19 11:44:22 +01:00
sj-i
5d31ee302d Fixed bug #42560
Check open_basedir after the fallback to the system's temporary
directory in tempnam().

In order to preserve the current behavior of upload_tmp_dir
(do not check explicitly specified dir, but check fallback),
new flags are added to check open_basedir for explicit dir
and for fallback.

Closes GH-6526.
2021-01-19 11:41:58 +01:00
George Peter Banyard
589bdf30b2 Implement Explicit octal notation for integers RFC
RFC: https://wiki.php.net/rfc/explicit_octal_notation

Add an extensive test suits for other variants of integer literals

Closes GH-6360
2021-01-04 21:09:23 +01:00
Christoph M. Becker
89d4b6b790 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80384: limit read buffer size
2020-12-23 13:53:19 +01:00
Christoph M. Becker
7d9ddd61ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80384: limit read buffer size
2020-12-23 13:52:45 +01:00
Adam Seitz
70dfbe0068 Fix #80384: limit read buffer size
In the case of a stream with no filters, php_stream_fill_read_buffer
only reads stream->chunk_size into the read buffer. If the stream has
filters attached, it could unnecessarily buffer a large amount of data.

With this change, php_stream_fill_read_buffer only proceeds until either
the requested size or stream->chunk_size is available in the read buffer.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-6444.
2020-12-23 13:49:56 +01:00
Nikita Popov
6ab4e330ac Use ephemeral port in more server tests
Port the main php_cli_server.inc to use ephemeral ports, thus
allowing CLI server tests to be parallelized.

A complication here is that we also need to give each test a
separate doc root, to avoid index.php files writing over each
other.

Closes GH-6375.
2020-10-23 14:26:34 +02:00
Stanislav Malyshev
e14f835d8c Merge branch 'PHP-7.4'
* PHP-7.4:
  Update UPGRADING
  Update UPGRADING
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-28 22:55:37 -07:00
Stanislav Malyshev
c4dc080245 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update UPGRADING
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-28 22:54:57 -07:00
Stanislav Malyshev
a9e4321846 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-28 21:39:34 -07:00
Stanislav Malyshev
6559fe9126 Do not decode cookie names anymore 2020-09-26 23:47:04 -07: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
Máté Kocsis
c37a1cd650
Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
George Peter Banyard
31ef94cd42 Convert Division by 0 warnings to Error per the Engine Warning RFC
Closes GH-6125
2020-09-14 13:40:07 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Nikita Popov
52047addc7 Only force log startup errors if display_startup_errors disabled
Otherwise this results in duplicate errors.

Closes GH-5941.
2020-08-05 18:17:00 +02:00
Nikita Popov
c48b745f00 Promote "undefined array key" notice to warning
This implements the last remaining part of the
https://wiki.php.net/rfc/engine_warnings RFC.

Closes GH-5927.
2020-08-03 14:40:50 +02:00
George Peter Banyard
b2248789ed Implement 'Saner Numeric Strings' RFC:
RFC: https://wiki.php.net/rfc/saner-numeric-strings

This removes the -1 allow_error mode from is_numeric_string functions and replaces it by
a trailing boolean out argument to preserve BC in a couple of places.

Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit
a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError.

This mostly affects:
 - String offsets
 - Arithmetic operations
 - Bitwise operations

Closes GH-5762
2020-07-29 02:51:09 +01:00
Andrea Faulds
f759936591 Permit trailing whitespace in numeric strings
This is part 1 of the 'Saner Numeric Strings' RFC:
https://wiki.php.net/rfc/saner-numeric-strings
2020-07-29 02:22:38 +01:00
Christoph M. Becker
fc4d462e94 Fix #78236: convert error on receiving variables when duplicate [
When an input variable name contains a non matched open bracket, we not
only have to replace that with an underscore, but also all following
forbidden characters.
2020-07-23 15:48:09 +02:00
Nikita Popov
acbf7802af Improved number to string comparison semantics
RFC: https://wiki.php.net/rfc/string_to_number_comparison

Closes GH-3886.
2020-07-22 12:23:49 +02:00
Máté Kocsis
5770b66722
Cleanup argument handling of Zend functions and methods
Closes GH-5847
2020-07-21 14:47:03 +02:00
Nikita Popov
fbbcf82ab7 Unify static/non-static check for magic methods
And promote it to be fatal.
2020-07-20 10:39:43 +02:00
Christoph M. Becker
ae7554270f Fix #79805: sapi_windows_vt100_support throws TypeError
It does not make sense to throw a `TypeError` when the stream can't be
analyzed.  If `sapi_windows_vt100_support()` is used as getter, we just
return `false` in that case; if the function is used as setter, we
additionally trigger a warning.

We also fix the test cases for this function, which have been broken
before.  Note that these tests are still whitespace sensitive.
2020-07-16 18:36:02 +02:00
Pedro Magalhães
272b887b7b Ignore inheritance rules on private methods
Closes GH-5401
2020-07-15 17:09:57 +01:00
Rowan Tommins
55a15f32ce Improve output of tokens in Parse Errors
Currently, unexpected tokens in the parser are shown as the text
found, plus the internal token name, including the notorious
"unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)".

This commit replaces that with a more user-friendly format, with
two main types of token:

* Tokens which always represent the same text are shown like
  'unexpected token "::"' and 'expected "::"'
* Tokens which have variable text are given a user-friendly
  name, and show like 'unexpected identifier "foo"', and
  'expected identifer'.

A few tokens have special cases:

* unexpected token """ -> unexpected double-quote mark
* unexpected quoted string "'foo'" -> unexpected single-quoted
  string "foo"
* unexpected quoted string ""foo"" -> unexpected double-quoted
  string "foo"
* unexpected illegal character "_" -> unexpected character 0xNN
  (where _ is almost certainly a control character, and NN is the
   hexadecimal value of the byte)

The \ token has a special case in the implementation just to stop
bison making a mess of escaping it and it coming out as \\
2020-07-13 11:07:40 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Christoph M. Becker
d59709d1ad Mark test as XFAIL for Windows/JIT/Release builds 2020-07-10 09:32:28 +02:00