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

572 Commits

Author SHA1 Message Date
Ilija Tovilo
073dcf66bb Merge branch 'PHP-8.5'
* PHP-8.5:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:28 +01:00
Ilija Tovilo
07e29acbd4 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:21 +01:00
Ilija Tovilo
6f91209260 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:14 +01:00
Ilija Tovilo
c6ad84fb9e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:04:24 +01:00
Ilija Tovilo
3a57b4ced5 Add RUN_RESOURCE_HEAVY_TESTS env var
Disable resource-heavy tests by default (>1GB of memory usage), unless the
RUN_RESOURCE_HEAVY_TESTS env variable is set.

Fixes GH-20762
Closes GH-20935
2026-02-27 15:00:35 +01:00
Peter Kokot
435e67e075 Remove HAVE_SQLITE3_{CLOSE_V2,ERRSTR} (#18963)
As of PHP 8.5 the minimum required SQLite library is 3.7.17, and this
removes the following preprocessor macros checks:

- HAVE_SQLITE3_CLOSE_V2 (sqlite3_close_v2() function is available since
  SQLite 3.7.14.)
- HAVE_SQLITE3_ERRSTR (sqlite3_errstr() function is available since
  SQLite 3.7.15)
- SQLITE_VERSION_NUMBER should be now always greater than 3006011
  (3.6.11).
2026-02-11 13:13:18 +01:00
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Tim Düsterhus
0fcd0bec11 Merge branch 'PHP-8.5'
* PHP-8.5:
  pdo: Fix scope for PDO mixins in pdo_hash_methods() (#20200)
2025-10-19 14:14:02 +02:00
Tim Düsterhus
1cb166cbbb pdo: Fix scope for PDO mixins in pdo_hash_methods() (#20200)
From what I see the incorrect scope is not observable in any other way. The
mixin methods are completely invisible to Reflection and a SQLite function
referring to a private method is still properly called as before.

Fixes php/php-src#20095.
2025-10-19 14:13:54 +02:00
Niels Dossche
b272021d0c [ci skip] Remove outdated comment (#20125)
Yes this is correct, the blob is returned as a string so it needs to be
put that way into the return value.
2025-10-11 18:05:57 +02:00
Niels Dossche
57ce245e1e Reduce code bloat in arginfo by using specialised string releases (#20016)
* Reduce code bloat in arginfo by using specialised string releases

Comparing this patch to master (c7da728574),
with a plain configure command without any options:

```
   text	   data	    bss	    dec	    hex	filename
20683738	1592400	 137712	22413850	156021a	sapi/cli/php
20688522	1592400	 137712	22418634	15614ca	sapi/cli/php_old
```

We see a minor reduction of 0.023% in code size.

* Also use true for the other initialization line

* Also use specialized code for consts
2025-10-02 22:00:20 +02:00
Samuel Štancl
a09d919ce8 Implement GH-8967: Add PDO_SQLITE_ATTR_TRANSACTION_MODE (#19317)
This commit implements GH-8967.

SQLite supports multiple transaction modes. These include:
- DEFERRED (default) only acquires a lock when you start a read/write
- IMMEDIATE acquires a reserved lock
- EXCLUSIVE acquires an exclusive lock (stricter than immediate)

In WAL mode IMMEDIATE and EXCLUSIVE are identical.

One reason for wanting to specify a transaction mode is that SQLite
doesn't respect busy_timeout when a DEFERRED transaction tries to
upgrade a read lock to a write lock. Normally if you try to acquire a
lock and have busy_timeout configured, SQLite will wait for that period
until giving up and erroring out (SQLITE_BUSY). With DEFERRED, if you
have a transaction that first reads and there's a concurrent writer
while it's trying to upgrade to a write lock, you will immediately get
SQLITE_BUSY regardless of your busy_timeout.

Prior to this commit, the only available workarounds were:
- Using $pdo->exec("BEGIN IMMEDIATE TRANSACTION") instead of
  $pdo->beginTransaction()
- Doing a dummy write at the start of each transaction so you don't get
  stuck with a read lock

Both of those aren't very usable, especially in a framework context
where the user doesn't have complete control over how transactions are
started.

To address that, this commit adds four class constants to Pdo\Sqlite:
- ATTR_TRANSACTION_MODE -- a new attribute
- TRANSACTION_MODE_DEFERRED = 0
- TRANSACTION_MODE_IMMEDIATE = 1
- TRANSACTION_MODE_EXCLUSIVE = 2

These can be used as:
  $pdo->setAttribute(
    $pdo::ATTR_TRANSACTION_MODE,
    $pdo::TRANSACTION_MODE_IMMEDIATE
  );
2025-09-07 15:42:30 +02:00
Arnaud Le Blanc
a4afc57f1d Deprecate driver specific PDO methods
RFC: https://wiki.php.net/rfc/deprecations_php_8_5.

Closes GH-19596
2025-09-03 08:42:33 +02:00
Arnaud Le Blanc
6f32e1c690 Deprecate driver specific PDO constants
RFC: https://wiki.php.net/rfc/deprecations_php_8_5.

Closes GH-19526
2025-08-26 09:06:19 +02:00
Tim Düsterhus
732069d98b pdo: Deprecate the uri: DSN scheme (#19274)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_pdo_s_urischeme
2025-08-08 21:24:15 +01:00
DanielEScherzer
ddd33fd7e4 Generated arginfo headers: combine preprocessor conditional blocks (2) (#18667)
When global constants' or class constants' availability is based on some
preprocessor condition, the generated arginfo header files wrap the
declarations in the preprocessor `#if` conditional blocks, one per declaration,
even if they are in the same conditional block based on comments in the stub
file. Instead of having multiple conditional blocks one after the other with
the same condition, combine them into a single conditional block.
2025-06-22 14:35:28 -07:00
David CARLIER
f129586459 ext/pdo_sqlite: fix minimal version for EXPLAIN feature support. (#18854) 2025-06-18 21:06:03 +01:00
Ilija Tovilo
2e2494fbef [skip ci] Fix whitespace in ext/pdo_sqlite/sqlite_statement.c 2025-06-14 16:00:13 +02:00
Ilija Tovilo
0a9697f5e1 Fix unused variable in pdo_sqlite_stmt_set_attribute() (GH-18851)
The indentation is also wrong (using spaces instead of tabs), but this should be
fixed in a separate commit.
2025-06-14 15:51:18 +02:00
David CARLIER
7361a1206d ext/pdo_sqlite: explain statement prefixing with its class for errors. (#18846) 2025-06-13 19:19:13 +01:00
David Carlier
71a254489c ext/pdo_sqlite: EXPLAIN mode support for SQL statements.
available since 3.41.0 we can reprepare a statement in either
 explain, explain query plan or the usual prepared mode.

close GH-18829
2025-06-13 05:45:45 +01:00
David Carlier
53231a81dd ext/pdo_sqlite: adding Pdo_Sqlite::ATTR_BUSY_STATEMENT
allow to check if a statement is still running before reusage.

close GH-18804
2025-06-09 18:24:35 +01:00
David Carlier
e3cfa4bcae ext/pdo_sqlite: PDO::sqliteCreateCollection return type strenghtening.
Is supposed to be Pdo_Sqlite::createCollation but behavior differs in
regard of return type checks.

close GH-18799
2025-06-08 13:29:26 +01:00
David CARLIER
ceffa70b97 ext/pdo_sqlite: Fix GH-18796 test exception message. (#18798) 2025-06-07 15:53:46 +01:00
David Carlier
b72dccb3e3 Merge branch 'PHP-8.4' 2025-06-07 14:29:13 +01:00
David Carlier
1044558b64 ext/pdo_sqlite: createCollation memory leaks fix.
coming from callback arguments when its return type is incorrect.

close GH-18796
2025-06-07 14:28:29 +01:00
Niels Dossche
8376904aeb Implement GH-17321: Add setAuthorizer to Pdo\Sqlite (#17905) 2025-04-18 00:34:46 +02:00
Niels Dossche
66d5cf8d2d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak on error return of collation callback in pdo_sqlite
2025-04-16 13:52:34 +02:00
Niels Dossche
ce7304f909 Fix memory leak on error return of collation callback in pdo_sqlite
We should destroy it when it's not IS_LONG, not when it's IS_LONG.

Closes GH-18332.
2025-04-16 13:52:23 +02:00
hanshenrik
0a10f6db26 ext/pdo_sqlite - throw on null bytes / resolve GH-13952 (#18320)
fix a corruption issue where PDO::quote for SQLite would silently truncate
strings with null bytes in them, by throwing.

Fixes #13952
Closes #18320
2025-04-15 08:52:31 +09:00
Niels Dossche
c4a79617a9 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak when destroying PDORow
2025-03-20 23:14:37 +01:00
Niels Dossche
0ef57501d9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak when destroying PDORow
2025-03-20 23:14:14 +01:00
Niels Dossche
2dde07af55 Fix memory leak when destroying PDORow
This should call zend_object_std_dtor() to clean the property table etc.
This also has a semantic influence because previously weak refs were not
notified for example.

This fixes the final issue in GH-18114 (the crash was master-only and
fixed already).

Closes GH-18114.
Closes GH-18123.
2025-03-20 23:13:42 +01:00
Niels Dossche
e1eeb483ef Fix GH-18114: pdo lazy object crash (#18116)
Since 0537968, the properties are no longer initialized.
So we call object_properties_init to handle that correctly.
Lower branches have a memory leak, but that requires a separate fix.
2025-03-19 23:43:30 +01:00
Niels Dossche
6a4b0c922c Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leaks in pdo_sqlite callback registration
  Fix cycle leak in sqlite3 setAuthorizer()
2025-02-23 16:36:06 +01:00
Niels Dossche
635fe263ac Fix memory leaks in pdo_sqlite callback registration
* We need to clean the trampoline if the construction check fails
* Checking for an exception and then returning causes a leak on
  `collation`. Returning early is pointless anyway.

Closes GH-17904.
2025-02-23 16:35:55 +01:00
Christoph M. Becker
3d9a0a0c17 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17837: ::getColumnMeta() on unexecuted statement segfaults
2025-02-18 17:03:33 +01:00
Christoph M. Becker
4a514f653a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17837: ::getColumnMeta() on unexecuted statement segfaults
2025-02-18 17:03:00 +01:00
Christoph M. Becker
260e0e9bd3 Fix GH-17837: ::getColumnMeta() on unexecuted statement segfaults
We cannot properly get the column meta data of a statement which has
been prepared, but has not yet been executed.  As such we bail out
early, reporting failure.

Closes GH-17850.
2025-02-18 17:01:46 +01:00
Gina Peter Banyard
60252b7845 ext/pdo: Improve testing for FETCH_FUNC mode (#17325) 2025-01-02 23:31:25 +00:00
Niels Dossche
b2c891f88e Avoid string duplications in sqlite drivers (#17115)
These string duplications are necessary to unregister the callback
later. We can just keep using zend_string to avoid memory duplications.
2024-12-18 17:32:11 +01:00
Máté Kocsis
5892991941 Fix GH-16131: Prevent mixing PDO sub-classes with different DSN 2024-10-22 22:51:29 +02:00
Christoph M. Becker
a57ce052cd Don't export php_pdo_int.h
This is, as the name and a comment in the header imply, an internal
header which is not supposed to be used by extensions other than PDO
(not even by drivers).

Since there is apparently no need to include this header in the parsers
of the drivers, we remove these includes, and no longer declare the
header to be installed.  Given that the header is only exported for a
couple of weeks[1], this is not considered to be a BC break, because
it's unlikely that external drivers have already been adjusted to use
this header, and otherwise they can still be fixed; PHP 8.4 is still in
the pre-release stage.

[1] <https://github.com/php/php-src/pull/14797>

Closes GH-15688.
2024-09-01 13:33:53 +02:00
Máté Kocsis
8d12f666ae Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
Peter Kokot
693ec809b9 Autotools: Remove PDO dependency related errors (#15347)
Follow-up of GH-15344 (687eb9125a)

This removes the customized error messages in PDO extensions when PDO is
not enabled (--disable-all or --disable-pdo) in favor of the default
error done by PHP_ADD_EXTENSION_DEP.
2024-08-11 21:35:36 +02:00
Peter Kokot
bd77462c7c Update sqlite3 and pdo_sqlite preprocessor macros help texts (#15291) 2024-08-09 14:51:05 +02:00
Peter Kokot
1ceadaed52 Autotools: Normalize and quote all PHP_NEW_EXTENSION arguments (#15144)
This adds Autoconf quote characters to all PHP_NEW_EXTENSION arguments
and syncs the CS across the php-src Autotools build system.
2024-07-29 00:14:59 +02:00
Peter Kokot
2b97c84d4c Autotools: Quote PHP_CHECK_LIBRARY arguments (#15136)
This syncs the quotes across the PHP_CHECK_LIBRARY macro arguments.
2024-07-28 18:39:14 +02:00