1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Commit Graph

140141 Commits

Author SHA1 Message Date
Ilija Tovilo
10ccb6bf0d Drop intel macOS build from push (#17551)
This build becomes less relevant as all currently sold Apple computers
contain Apple Silicon CPUs. This build rarely fails in isolation anyway.
For the time being, we'll keep the nightly builds in all configurations.
2025-01-23 19:17:24 +01:00
Niels Dossche
6d4598eba8 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix type confusion with session SID constant
2025-01-23 19:03:45 +01:00
Niels Dossche
b448d540c2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix type confusion with session SID constant
2025-01-23 19:03:35 +01:00
Niels Dossche
2a2cc2ccce Fix type confusion with session SID constant
Closes GH-17548.
2025-01-23 19:03:04 +01:00
Gina Peter Banyard
ad4cbf4e7f ext/pdo_firebird: Add LSAN suppression for isc_attach_database() (#17544) 2025-01-22 20:51:00 +00:00
Dmitry Stogov
387ce309ba Merge branch 'PHP-8.4'
* PHP-8.4:
  Update IR
2025-01-22 18:30:56 +03:00
Dmitry Stogov
63965f1de5 Update IR
IR commit: 02909bc123845fc2c41ec333b44b6f5ea1a196fe
2025-01-22 18:30:33 +03:00
David Carlier
3337f22eb1 Merge branch 'PHP-8.4' 2025-01-21 19:34:14 +00:00
Christian Schneider
fa21fce84f ext/pgsql: Add check for constant PGRES_TUPLES_CHUNK to fix compilation failures
close GH-17540
2025-01-21 19:32:38 +00:00
Christoph M. Becker
aa76127d01 Address more Clang warnings (GH-17506)
We prefer clean solutions (such as declaring the proper type in the
first place, or introducing a portable format specifier) where easily
possible, but resort to casts otherwise.

We also port f1480ab14b.
2025-01-21 20:05:29 +01:00
Niels Dossche
75bd1a9dc0 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
2025-01-21 19:27:24 +01:00
Niels Dossche
0b12db6afa Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
2025-01-21 19:27:19 +01:00
Niels Dossche
0b3e637aec Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
The check for `!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)` is
performed after `fbc` is set to NULL, so this always returns true.
This results in `ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS` always being
set for unpack sends. Fix it by moving the flag updates to the point
before setting `fbc` to NULL.

Closes GH-17534.
2025-01-21 19:26:49 +01:00
Niels Dossche
c218f62920 Remove always-true check in pdo_stmt.c (#17535)
`check_empty` is checked earlier up, so this variable is always true.
2025-01-21 19:20:57 +01:00
Tim Düsterhus
1aaf2b1899 array_filter: Remove unnecessary refcounting (#17538)
This syncs the implementation with the updated implementation of `array_find()`
in php/php-src#17536. For the following test script:

    <?php

    $array = range(1, 8000);

    $result = 0;
    for ($i = 0; $i < 4000; $i++) {
    	$result += count(array_filter($array, static function ($item) {
    		return $item <= 4000;
    	}));
    }
    var_dump($result);

This change results in:

    Benchmark 1: /tmp/before array_filter.php
      Time (mean ± σ):     696.9 ms ±  16.3 ms    [User: 692.9 ms, System: 3.5 ms]
      Range (min … max):   681.6 ms … 731.5 ms    10 runs

    Benchmark 2: /tmp/after array_filter.php
      Time (mean ± σ):     637.5 ms ±   5.6 ms    [User: 633.6 ms, System: 3.8 ms]
      Range (min … max):   630.2 ms … 648.6 ms    10 runs

    Summary
      /tmp/after array_filter.php ran
        1.09 ± 0.03 times faster than /tmp/before array_filter.php

Or as reported by perf:

    # Samples: 2K of event 'cpu_core/cycles/'
    # Event count (approx.): 2567197440
    #
    # Overhead  Command  Shared Object         Symbol
    # ........  .......  ....................  ........................................................
    #
        37.02%  before   before                [.] zend_call_function
        15.50%  before   before                [.] execute_ex
        10.60%  before   before                [.] zif_array_filter
         9.43%  before   before                [.] zend_hash_index_add_new
         9.13%  before   before                [.] ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMPVARCV_CONST_HANDLER
         8.46%  before   before                [.] zend_init_func_execute_data
         3.78%  before   before                [.] zval_add_ref
         3.47%  before   before                [.] zval_ptr_dtor
         1.17%  before   before                [.] zend_is_true

vs

    # Samples: 2K of event 'cpu_core/cycles/'
    # Event count (approx.): 2390202140
    #
    # Overhead  Command  Shared Object         Symbol
    # ........  .......  ....................  ........................................................
    #
        36.87%  after    after                 [.] zend_call_function
        20.46%  after    after                 [.] execute_ex
         8.22%  after    after                 [.] zend_init_func_execute_data
         7.94%  after    after                 [.] zend_hash_index_add_new
         7.89%  after    after                 [.] zif_array_filter
         6.28%  after    after                 [.] ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMPVARCV_CONST_HANDLER
         3.95%  after    after                 [.] zval_add_ref
         2.23%  after    after                 [.] zend_is_true
2025-01-21 15:43:16 +01:00
Tim Düsterhus
c39d112620 array_find: Remove unnecessary refcounting (#17536)
* array_find: Fix data type for `retval_true`

* array_find: Remove unnecessary refcounting

In a post on LinkedIn [1], Bohuslav Šimek reported that the native
implementation of `array_find()` was about 3× slower than the equivalent
userland implementation. While I was not able to verify this claim, due to a
lack of reproducer provided, I could confirm that the native `array_find()` was
indeed slower than the equivalent userland implementation. For the following
example script:

    <?php

    function my_array_find(array $array, callable $callback): mixed {
        foreach ($array as $key => $value) {
            if ($callback($value, $key)) {
                return $value;
            }
        }

        return null;
    }

    $array = range(1, 10000);

    $result = 0;
    for ($i = 0; $i < 5000; $i++) {
    	$result += array_find($array, static function ($item) {
    		return $item === 5000;
    	});
    }
    var_dump($result);

with the `array_find()` call appropriately replaced for each case, a PHP-8.4
release build provided the following results:

    Benchmark 1: /tmp/before native.php
      Time (mean ± σ):     765.9 ms ±   7.9 ms    [User: 761.1 ms, System: 4.4 ms]
      Range (min … max):   753.2 ms … 774.7 ms    10 runs

    Benchmark 2: /tmp/before userland.php
      Time (mean ± σ):     588.0 ms ±  17.9 ms    [User: 583.6 ms, System: 4.1 ms]
      Range (min … max):   576.0 ms … 633.3 ms    10 runs

    Summary
      /tmp/before userland.php ran
        1.30 ± 0.04 times faster than /tmp/before native.php

Running `native.php` with perf reports that a third of the time is spent in
`zend_call_function()` and another 20% in `execute_ex()`, however
`php_array_find()` comes next at 14%:

    # Samples: 3K of event 'cpu_core/cycles/'
    # Event count (approx.): 2895247444
    #
    # Overhead  Command  Shared Object      Symbol
    # ........  .......  .................  ...........................................
    #
        32.47%  before   before             [.] zend_call_function
        20.63%  before   before             [.] execute_ex
        14.06%  before   before             [.] php_array_find
         7.89%  before   before             [.] ZEND_IS_IDENTICAL_SPEC_CV_CONST_HANDLER
         7.31%  before   before             [.] zend_init_func_execute_data
         6.50%  before   before             [.] zend_copy_extra_args

which was surprising, because the function doesn’t too all that much. Looking
at the implementation, the refcounting stood out and it turns out that it is
not actually necessary. The `array` is passed by value to `array_find()` and
thus cannot magically change within the callback. This also means that the
array will continue to hold a reference to string keys and values, preventing
these values from being collected. The refcounting inside of `php_array_find()`
thus will never do anything useful.

Comparing the updated implementation against the original implementation shows
that this change results in a 1.14× improvement:

    Benchmark 1: /tmp/before native.php
      Time (mean ± σ):     775.4 ms ±  29.6 ms    [User: 771.6 ms, System: 3.5 ms]
      Range (min … max):   740.2 ms … 844.4 ms    10 runs

    Benchmark 2: /tmp/after native.php
      Time (mean ± σ):     677.3 ms ±  16.7 ms    [User: 673.9 ms, System: 3.1 ms]
      Range (min … max):   655.9 ms … 705.0 ms    10 runs

    Summary
      /tmp/after native.php ran
        1.14 ± 0.05 times faster than /tmp/before native.php

Comparing the native implementation against the userland implementation with
the new implementation shows that while the native implementation still is
slower, the difference reduced to 15% (down from 30%):

    Benchmark 1: /tmp/after native.php
      Time (mean ± σ):     670.4 ms ±   9.3 ms    [User: 666.7 ms, System: 3.4 ms]
      Range (min … max):   657.1 ms … 689.0 ms    10 runs

    Benchmark 2: /tmp/after userland.php
      Time (mean ± σ):     576.7 ms ±   7.6 ms    [User: 572.5 ms, System: 3.7 ms]
      Range (min … max):   563.9 ms … 588.1 ms    10 runs

    Summary
      /tmp/after userland.php ran
        1.16 ± 0.02 times faster than /tmp/after native.php

Looking at the updated perf results shows that `php_array_find()` now only
takes up 8% of the time:

    # Samples: 2K of event 'cpu_core/cycles/'
    # Event count (approx.): 2540947159
    #
    # Overhead  Command  Shared Object         Symbol
    # ........  .......  ....................  ...........................................
    #
        34.77%  after    after                 [.] zend_call_function
        18.57%  after    after                 [.] execute_ex
        12.28%  after    after                 [.] zend_copy_extra_args
        10.91%  after    after                 [.] zend_init_func_execute_data
         8.77%  after    after                 [.] php_array_find
         6.70%  after    after                 [.] ZEND_IS_IDENTICAL_SPEC_CV_CONST_HANDLER
         4.68%  after    after                 [.] zend_is_identical

[1] https://www.linkedin.com/posts/bohuslav-%C5%A1imek-kambo_the-surprising-performance-of-php-84-activity-7287044532280414209-6WnA

* array_find: Clean up exception handling

This change has no effect on performance, but greatly improves readability of
the implementation.
2025-01-21 12:27:49 +01:00
Niels Dossche
3786b721e8 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17408: Assertion failure Zend/zend_exceptions.c
2025-01-21 08:21:27 +01:00
Niels Dossche
25543b4566 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17408: Assertion failure Zend/zend_exceptions.c
2025-01-21 08:21:13 +01:00
Niels Dossche
5344bcca97 Fix GH-17408: Assertion failure Zend/zend_exceptions.c
`zend_test_create_throwing_resource` sets the exception in the `test`
call frame and unwinds to `main`. It then throws for the `resource`
variable and verifies that the exception opline is set. However, it
wasn't set in `main`, it was set at the `test` call frame and rethrown later.
The assertion is too conservative, but the end result is right, so drop
the assertion.

Closes GH-17533.

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2025-01-21 08:20:38 +01:00
Tim Düsterhus
0f8340d0a5 zend_ini: Implement zend_ini_string*() in terms of zend_ini_str*() (#17530) 2025-01-20 22:15:23 +01:00
Christoph M. Becker
ce53dab272 Fix Clang builds regarding undefined function call
While MSVC is apparently fine using `_AddressOfReturnAddress()` without
including intrin.h, Clang complains that the function is undefined.  So
we include the header, if `_MSC_VER` is defined, what is the case for
MSVC and clang-cl, but not for some other compilers on Windows (e.g.
GCC).
2025-01-20 14:49:25 +01:00
Gina Peter Banyard
6bd2b8dfa5 ext/pdo: Throw an exception instead of fatal error if the class is not found (#17528) 2025-01-19 23:35:24 +00:00
Gina Peter Banyard
9283abc1a0 ext/pdo: Rename and add tests for PDO::FETCH_CLASS fetch mode (#17526) 2025-01-19 20:33:13 +00:00
Jakub Zelenka
b60f9bf27a Merge branch 'PHP-8.4' 2025-01-19 20:39:27 +01:00
Jakub Zelenka
b3c297d88f Merge branch 'PHP-8.3' into PHP-8.4 2025-01-19 20:38:51 +01:00
Jakub Zelenka
191e16b703 Merge branch 'PHP-8.2' into PHP-8.3 2025-01-19 20:38:19 +01:00
Jakub Zelenka
5d632230ba Merge branch 'PHP-8.1' into PHP-8.2 2025-01-19 20:37:53 +01:00
Jakub Zelenka
235d1b14a3 Fix GH-17499: mysqli flaky test: ghsa-h35g-vwh6-m678-stmt-row-string 2025-01-19 20:36:12 +01:00
David Carlier
27125b8c39 Merge branch 'PHP-8.4' 2025-01-19 18:01:52 +00:00
David Carlier
c82e31b026 Fix GH-17516: SplFileTempObject::getPathInfo() crash on invalid class.
This no longer caught the case where an non SplFileInfo/inherited class
of nwas passed since the refactoring in 8.4.

close GH-17517
2025-01-19 18:01:02 +00:00
Kamil Tekiela
a883082f87 Improve mysqli_thread_id test (#17515) 2025-01-19 17:54:01 +00:00
Kamil Tekiela
d6d23fe002 Improve bug74021 test (#17514) 2025-01-19 17:53:54 +00:00
Kamil Tekiela
6919b95010 Ensure charset in tests (#17513) 2025-01-19 17:53:37 +00:00
Gina Peter Banyard
a100450cd9 ext/intl: Call DateTimeInterface::getTimestamp() directly (#17487) 2025-01-19 17:28:36 +00:00
Niels Dossche
b8ee4c2b19 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17518: offset overflow phar extractTo()
2025-01-19 13:06:01 +01:00
Niels Dossche
7cc8719ee5 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17518: offset overflow phar extractTo()
2025-01-19 13:05:55 +01:00
Niels Dossche
eab209d81d Fix GH-17518: offset overflow phar extractTo()
`search` can be the empty string, so we need to check the length before
checking the last char.

Closes GH-17519.
2025-01-19 13:05:19 +01:00
Niels Dossche
675f359e91 Merge branch 'PHP-8.4'
* PHP-8.4:
  Cherry-pick lexbor/lexbor@f94d97a3
2025-01-19 11:51:41 +01:00
Niels Dossche
22704af4b8 Cherry-pick lexbor/lexbor@f94d97a3
Co-authored-by: Alexander Borisov <lex.borisov@gmail.com>
2025-01-19 11:50:56 +01:00
Jorg Adam Sowa
8c11382a52 Removed unused headers from link.c (#16080) 2025-01-19 10:20:03 +01:00
Ayesh Karunaratne
88fc34aa7a ext/curl: update CURLOPT_PREREQFUNCTION test to validate CURLE_ABORTED_BY_CALLBACK return value
Updates the `CURLOPT_PREREQFUNCTION` test to validate that
connections failed when the PREREQFUNC returns abort returns
CURLE_ABORTED_BY_CALLBACK as the error number.

Previously, it only checked against a hardcoded value. Now, it
checks against the `CURLE_ABORTED_BY_CALLBACK` constant as well.
2025-01-19 11:20:41 +07:00
David CARLIER
252c0c9164 win32: switch handful of memmove over memcpy. (#17508) 2025-01-18 14:47:48 +00:00
David Carlier
709c0a9905 Merge branch 'PHP-8.4' 2025-01-17 22:25:37 +00:00
David Carlier
05a1c04c43 Merge branch 'PHP-8.3' into PHP-8.4 2025-01-17 22:25:24 +00:00
David Carlier
a1d1269688 Fix GH-17469: UConverter::transcode() not hardcoding error handling.
Respecting instead intl.use_exceptions/intl.error_level.

close GH-17488
2025-01-17 22:23:27 +00:00
Christoph M. Becker
7dbfacb27e Suppress UB warnings regarding indirect function calls
Like for POSIX systems, we pass `-fno-sanitize=function`.

Closes GH-17462.
2025-01-17 23:00:57 +01:00
Christoph M. Becker
e1c4c0300e Fix Clang lib folder detection on Windows
First, more recent versions of Clang do no longer have trailing info in
parentheses, so the detection would fail.  Since we're not interested
in this information, we just ignore it.

Then we should not rely on Clang being installed in the default program
folder.  Instead we look up where the first clang.exe can be found, and
assume that it is located in a bin/ folder in the installation path.
From there we construct the library path, which is
`lib\clang\<ver>\lib\windows` where `<ver>` is either the full version
(older Clang) or only the major version.  Note that this is the case
for stand-alone LLVM installations as well as Visual Studio supplied
ones.

Finally, we clean up by improving the error messages, and removing the
duplicate clang version detection in `add_asan_opts()`.

While we're at it, we also apply a cosmetic improvement to avoid
(trailing) whitespace in the compiler name (e.g. shown by `-v`).
2025-01-17 23:00:57 +01:00
Niels Dossche
ddfa3934d8 [ci skip] Fix NEWS format 2025-01-17 19:45:59 +01:00
Niels Dossche
0bed3d5d6d Merge branch 'PHP-8.4'
* PHP-8.4:
  NEWS for GH-17485
  Cherry-pick lexbor/lexbor@e58e1e8c
  Cherry-pick lexbor/lexbor@ae97abfb
  Cherry-pick lexbor/lexbor@e39083b0
2025-01-17 19:44:16 +01:00
Niels Dossche
0b04061e71 NEWS for GH-17485
Fixes GH-17485.
2025-01-17 19:43:08 +01:00