Commit graph

557 commits

Author SHA1 Message Date
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
Saki Takamachi
acd6ac3324
Fixed parent class of stub (#14990) 2024-07-17 21:38:59 +09:00
Peter Kokot
bee84c0468
Autotools: Quote PHP_SUBST arguments in extensions (#14748) 2024-07-02 06:56:18 +02:00
David Carlier
58a6e5551e
Merge branch 'PHP-8.3' 2024-06-29 15:52:52 +01:00
David Carlier
1b71a9e01f
Merge branch 'PHP-8.2' into PHP-8.3 2024-06-29 15:52:28 +01:00
David Carlier
c03196a5be
Fix GH-14712: segfault on invalid object.
If the extension does not allow to get a property pointer (like PDORow
object), we fallback
to the read property cb anyway.
2024-06-29 15:51:57 +01:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +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
Matteo Beccati
3096ffa7ab
pdo_sqlite: identifier quoting with square brakets 2024-06-17 23:31:24 +02:00
Matteo Beccati
715b9aaa09
Implemented PDO Driver specific SQL parsers
RFC: http://wiki.php.net/rfc/pdo_driver_specific_parsers
2024-06-17 23:31:24 +02:00
Peter Kokot
df481ef941
Simplify PDO include paths (#14444)
PDO include paths can be simplified and synced as done in other
extensions: either the project root directory or the phpincludedir (for
the system installation). The 'ext' include is automatically appended
when doing phpize build. In php-src it is only present on Windows build.
The PHP_CHECK_PDO_INCLUDES is left intact working as before and checks
if PDO headers are found.
2024-06-03 12:56:21 +02:00
Máté Kocsis
6ec4220148
Amend PDO driver-specific class names (#14069)
As suggested in https://externals.io/message/123166
2024-05-30 20:15:42 +02:00
Peter Kokot
cba3891d53
Join SQLite library setup M4 macros to PHP_SETUP_SQLITE (#14372)
Macro can simplify managing minimum version of SQLite library on less
places.
2024-05-30 18:16:30 +02:00
Niels Dossche
b7bf846f72
Fix bug #81227: PDO::inTransaction reports false when in transaction (#14268) 2024-05-20 13:59:26 +02:00
Peter Kokot
2a23c91ad5
Remove unused HAVE_PDO_SQLITELIB symbol (#14232)
Symbol isn't defined on Windows and is redundant since the SQLite
library is required for ext/pdo_sqlite and isn't bundled in php-src
anymore.
2024-05-16 15:21:20 +02:00
Saki Takamachi
cf92a191e8
ext/pdo_sqlite: Use new F ZPP (#14059)
closes #14059
2024-05-01 23:44:41 +09:00