Commit graph

14619 commits

Author SHA1 Message Date
Ayesh Karunaratne
673b4e890c
ext/standard: change highlight_string()/print_r stub return type from string|bool to string|true (#14959)
* ext/standard: change `highlight_string()` return type from `string|bool` to `string|true`

* ext/standard: change `print_r` return type from `string|bool` to `string|true`
2024-07-15 23:20:32 +02:00
Peter Kokot
0e2e8e0f13
Autotools: Quote all PHP_ADD_BUILD_DIR arguments (#14947)
- All arguments quoted for consistency
- m4_normalize used where list of directories becomes a bit simpler to
  read and see the diff
2024-07-14 16:58:43 +02:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00
Niels Dossche
3703459c3e
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14930: Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3
2024-07-12 19:28:37 +02:00
Joe Cai
38501ed48a
Fix GH-14930: Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3
Revert "Reserve less file space if possible in a directory entry"
This reverts commit 00c1e7bf0f.

Closes GH-14933.
2024-07-12 19:26:42 +02:00
Tim Düsterhus
29f98e7485
Replace @deprecated by #[\Deprecated] for internal functions / class constants (#14750)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-07-10 16:47:31 +02:00
Peter Kokot
1bdf9aa38d
Remove support for EOL Apache 2.0 and 2.2 in favor of 2.4+ (#14664)
Apache 2.2 has been marked as EOL in December 2017 and doesn't receive
security patches any longer. Also, most *nix distributions and packages
mostly support 2.4 as minimum by now.

On Windows, this removes the configure option --enable-apache2-2handler
and merges the --enable-apache2handler and --enable-apache2-4handler
into a single option with favoring the --enable-apache2handler.

- The upstream MODULE_MAGIC_NUMBER is deprecated in favor of
  MODULE_MAGIC_NUMBER_MAJOR in apache2/ap_mmn.h
- The initial upstream MODULE_MAGIC_NUMBER_MAJOR was 20111025 in Apache
  2.4.0
- The upstream APLOG_USE_MODULE is always available since Apache 2.3.6
- The upstream CORE_PRIVATE is unnecessary and ignored since Apache
  2.4.0

See:
https://forum.apachehaus.com/news-general-discussion/apache-2-2-users-your-time-is-running-out/

Discussion: https://news-web.php.net/php.internals/124067
2024-07-08 00:07:55 +02:00
Peter Kokot
9def76ebbc
Autotools: Refactor crypt check in ext/standard (#14856)
- AH_TEMPLATE sets the CPP macro help text on a single place
- AC_DEFINE can be used instead of AC_DEFINE_UNQUOTED
- AS_VAR_IF used and CS synced
- crypt() function is at this point required as all required algorithm
  checks are depending on it and error is thrown if not found when using
  external crypt library
2024-07-07 21:46:44 +02:00
David Carlier
c14fa48526
Merge branch 'PHP-8.3' 2024-07-06 20:44:47 +01:00
David Carlier
0b28914a26
Merge branch 'PHP-8.2' into PHP-8.3 2024-07-06 20:44:20 +01:00
David Carlier
237518763f
Fix GH-14774 time_sleep_until overflow. 2024-07-06 20:43:59 +01:00
Peter Kokot
fbc329733c
Autotools: Move crypt_r check (#14832)
The crypt_r() function is required and check can error out separately.
2024-07-05 13:14:48 +02:00
Peter Kokot
1a380989ee
Remove HAVE_STRPTIME_DECL_FAILS (#14821)
The strptime, where available, needs the _GNU_SOURCE defined or compiler
flag -std=gnuXX appended to be declared in time.h. PHP's strptime is
also deprecated as of PHP 8.1.

This removes the HAVE_STRPTIME_DECL_FAILS in favor of a simpler
AC_CHECK_DECL check and HAVE_DECL_STRPTIME CPP macro.
2024-07-04 20:26:14 +02:00
Niels Dossche
0fb12385fb
Merge branch 'PHP-8.3'
* PHP-8.3:
  NEWS for GH-14814
  ext/standard/tests: strings/wordwrap_memory_limit_32bit.phpt has two outputs
  ext/standard/tests: 32bit wordwrap tests aren't just for Windows
2024-07-04 15:56:48 +02:00
Niels Dossche
7ee7492f30
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  NEWS for GH-14814
  ext/standard/tests: strings/wordwrap_memory_limit_32bit.phpt has two outputs
  ext/standard/tests: 32bit wordwrap tests aren't just for Windows
2024-07-04 15:56:43 +02:00
Michael Orlitzky
27dd393be9
ext/standard/tests: strings/wordwrap_memory_limit_32bit.phpt has two outputs
It turns out that on a 32-bit system, this test can produce either the
"usual" expected output from the 64-bit test, OR the 32-bit-only
integer overflow message. We copy the dual expected outputs from
chunk_split_variation1_32bit.phpt to handle both cases.

This fixes an earlier commit that split the two tests based only on
the size of an int (32-bit versus 64-bit). The CI reveals that, at
least on a debug/zts build, the "64-bit" memory limit error (and not
the integer overflow error) is still produced.
2024-07-04 15:55:05 +02:00
Michael Orlitzky
68a0efedeb
ext/standard/tests: 32bit wordwrap tests aren't just for Windows
The test in strings/wordwrap_memory_limit.phpt has a counterpart in
strings/wordwrap_memory_limit_win32.phpt. The two are conditional on
both the OS name and the size of an int (32- versus 64-bits).

A Gentoo Linux user has however reported that the 64-bit test fails on
a 32-bit system, with precisely the error message that the "win32"
test is expecting. I don't have any 32-bit hardware to test myself,
but I think it's reasonable to conclude that the OS name is not an
essential part of the test: it's simply 32- versus 64-bit.

This commit drops the conditionals for the OS name. Now one test will
be run on 32-bit systems, and the other on 64-bit systems, regardless
of the OS name.

Bug: https://bugs.gentoo.org/935382
2024-07-04 15:55:04 +02:00
Peter Kokot
f2300376fc
Autotools: Refactor ext/standard strptime check (#14800)
- Cache variable renamed from ac_cv_strptime_decl_fails to
  php_cv_have_decl_strptime
- CS synced
2024-07-04 14:36:00 +02:00
Peter Kokot
c6ab4b31c0
Autotools: Refactor ext/standard cache variables (#14799)
- Cache variable renamed from ac_cv_flush_io to php_cv_have_flush_io
- CS synced
2024-07-04 14:34:54 +02:00
Niels Dossche
5b673e99fc
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix uninitialized (dummy) memory in php_strtr_array() (#14812)
2024-07-04 13:36:46 +02:00
Niels Dossche
6467655568
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix uninitialized (dummy) memory in php_strtr_array() (#14812)
2024-07-04 13:35:53 +02:00
Niels Dossche
7b74cadf8c
Fix uninitialized (dummy) memory in php_strtr_array() (#14812)
Fixes one issue in GH-14806.
2024-07-04 13:34:33 +02:00
Peter Kokot
88e36a7d5d
Merge branch 'PHP-8.3'
* PHP-8.3:
  ext/standard/tests: use %d instead of bytes in an overflow message
2024-07-04 00:48:52 +02:00
Peter Kokot
9c460bc65f
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/standard/tests: use %d instead of bytes in an overflow message
2024-07-04 00:48:35 +02:00
Michael Orlitzky
a8d1955348
ext/standard/tests: use %d instead of bytes in an overflow message
In strings/chunk_split_variation1_32bit.phpt, we have a test that is
expected to fail on x32 with a possible integer overflow error. The
message reports the exact number of bytes -- a number big enough to
overflow an int on x32 -- stemming from a memory allocation in
chunk_split().

This number appears unpredictable, and is not the point of the test.
We replace it with %d to make the test independent of the allocation
details.
2024-07-04 00:48:01 +02:00
Peter Kokot
a6b336aba6
Refactor HAVE_GETIFADDRS checks (#14787)
- AC_CACHE used with php_cv_func_getifaddrs cache variable
- Synced #if/ifdef/defined checks for HAVE_GETIFADDRS as it is either
  defined to 1 or undefined
2024-07-03 21:53:17 +02:00
David Carlier
0410bf4147
Merge branch 'PHP-8.3' 2024-07-03 18:57:54 +01:00
David Carlier
15bea9ed74
Fix GH-14775: range overflow on negative step.
overflow occurs since we only deal with positive steps.

close GH-14778
2024-07-03 18:57:25 +01:00
Peter Kokot
212b2834e9
Autotools: Sync indentation style in build system files (#14725) 2024-06-29 23:25:17 +02:00
Peter Kokot
b1c34a9163
Normalize AC_CHECK_HEADER* arguments (#14723)
The m4_normalize is for Autoconf < 2.70 (on 2.70 and later versions a
blank-or-newline separated items can be expanded without using
backslash-newline). The order of headers in configure.ac is left as is
because the first few headers depend on checking other headers (for
those includes the 4th argument).
2024-06-29 19:49:12 +02:00
Niels Dossche
4a9ff0f004
Add myself to ext-dom credits (#14718)
Suggested here [1] as well.

[1] https://github.com/php/php-src/pull/13819#pullrequestreview-2146095841
2024-06-29 15:18:34 +01:00
Peter Kokot
2041c133ac
Normalize AC_CHECK_FUNC* first argument (#14700)
The m4_normalize is for Autoconf < 2.70 (on 2.70 and later versions a
blank-or-newline separated items can be expanded without using
backslash-newline).

This also syncs the 1st argument quotes.
2024-06-28 22:40:24 +02:00
Peter Kokot
fd28bb0f51
Normalize ext/standard sources (#14677)
Follow-up of GH-14654
2024-06-27 20:45:09 +02:00
David CARLIER
bc585cd87a
Fix GH-14643 ext/standard: segfault on user shutdown function release. (#14656) 2024-06-25 21:13:15 +01:00
Peter Kokot
df6d85acf8
Fix CS for fnmatch check (#14659)
This wraps the check when cross-compiling into AS_* macros and uses the
default description template provided the AC_FUNC_FNMATCH. In such case
the 3rd argument can be omitted. Also, newer Autoconf versions have
replaced backticks with single quotes in AC_DEFINE* macros descriptions.
2024-06-25 00:15:54 +02:00
Peter Kokot
f3feef8b93
Define default RE2C_FLAGS (#14615)
The --no-generation-date flag is a common re2c flag used in all re2c
invocations. This adds the 2nd optional argument to PHP_PROG_RE2C M4
macro in BC manner to set the default re2c command-line options and sets
the default RE2C_FLAGS similarly on Windows.
2024-06-24 22:09:04 +02:00
Arnaud Le Blanc
ff58a7f624
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS for GH-13922
  [ci skip] NEWS for GH-13922
  Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922)
2024-06-24 19:57:28 +02:00
Arnaud Le Blanc
b1119de0c9
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-13922
  Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922)
2024-06-24 19:56:19 +02:00
Arnaud Le Blanc
3fbca7fb6a
Support sysconf(_SC_GETPW_R_SIZE_MAX) == -1 (#13922) 2024-06-24 19:52:55 +02:00
Peter Kokot
cf3b9fca8f
Sync #if/ifdef/defined (-Wundef) (#14623)
These are either define (to value 1) or undefined:
- __GNUC__
- DBA_CDB_BUILTIN
- DBA_GDBM
- HAVE_FORK
- HAVE_PUTENV
- HAVE_SETENV
- HAVE_SYS_SELECT_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_WAIT_H
- HAVE_UNSETENV
- RFC3678_API
- ZEND_ENABLE_ZVAL_LONG64
- ZTS

Follow-up of GH-5526
2024-06-24 19:37:07 +02:00
Tim Düsterhus
9907389007
Fix sprintf_rope_optimization_004.phpt for 32-bit versions
see 2c5ed50d5c
2024-06-17 17:45:46 +02:00
Tim Düsterhus
2c5ed50d5c
zend_compile: Add support for %d to sprintf() optimization (#14561)
* zend_compile: Rename `string_placeholder_count` to `placeholder_count` in `zend_compile_func_sprintf()`

This is intended to make the diff of a follow-up commit smaller.

* zend_compile: Add support for `%d` to `sprintf()` optimization

This extends the existing `sprintf()` optimization by support for the `%d`
placeholder, which effectively equivalent to an `(int)` cast followed by a
`(string)` cast.

For a synthetic test using:

    <?php

    $a = 'foo';
    $b = 42;

    for ($i = 0; $i < 100_000_000; $i++) {
        sprintf("%s-%d", $a, $b);
    }

This optimization yields a 1.3× performance improvement:

    $ hyperfine 'sapi/cli/php -d zend_extension=php-src/modules/opcache.so -d opcache.enable_cli=1 test.php' \
          '/tmp/unoptimized -d zend_extension=php-src/modules/opcache.so -d opcache.enable_cli=1 test.php'
    Benchmark 1: sapi/cli/php -d zend_extension=php-src/modules/opcache.so -d opcache.enable_cli=1 test.php
      Time (mean ± σ):      3.296 s ±  0.094 s    [User: 3.287 s, System: 0.005 s]
      Range (min … max):    3.213 s …  3.527 s    10 runs

    Benchmark 2: /tmp/unoptimized -d zend_extension=php-src/modules/opcache.so -d opcache.enable_cli=1 test.php
      Time (mean ± σ):      4.300 s ±  0.025 s    [User: 4.290 s, System: 0.007 s]
      Range (min … max):    4.266 s …  4.334 s    10 runs

    Summary
      sapi/cli/php -d zend_extension=php-src/modules/opcache.so -d opcache.enable_cli=1 test.php ran
        1.30 ± 0.04 times faster than /tmp/unoptimized -d zend_extension=php-src/modules/opcache.so -d opcache.enable_cli=1 test.php

* Fix sprintf_rope_optimization_003.phpt test expecation for 32-bit integers

* zend_compile: Indent switch-case labels in zend_compile_func_sprintf()

* Add GMP test to sprintf() rope optimization

* Add `%s` test case to sprintf() GMP test
2024-06-17 17:07:50 +02:00
Niels Dossche
c151d2d135 standard: change uses of sprintf into snprintf and zend_string_concat2 2024-06-14 08:12:03 -07:00
Derick Rethans
4b24f5d6db
Merge branch 'PHP-8.3' 2024-06-13 14:04:48 +01:00
Derick Rethans
31798e4b6d
Merge branch 'PHP-8.2' into PHP-8.3 2024-06-13 14:04:13 +01:00
Derick Rethans
e0e9eb4053
Merge branch 'fix-anonymous-socket-at-length-boundary' into PHP-8.2 2024-06-13 14:03:46 +01:00
Ilija Tovilo
4542cc66dd
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix windows rename test directories clashing
2024-06-13 14:03:33 +02:00
Ilija Tovilo
22ac07a886
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix windows rename test directories clashing
2024-06-13 14:03:26 +02:00
Ilija Tovilo
8d9f9755e8
Fix windows rename test directories clashing
Closes GH-14554
2024-06-13 14:02:57 +02:00
Derick Rethans
ad56ec7bbf
Fixed off-by-one error in checking length of abtract namespace Unix sockets 2024-06-13 12:46:22 +01:00