Commit graph

564 commits

Author SHA1 Message Date
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
ee4a9a4a7c
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17736: Assertion failure zend_reference_destroy()
2025-03-02 22:37:07 +01:00
Niels Dossche
ce8ab5f16a
Fix GH-17736: Assertion failure zend_reference_destroy()
The cache slot for FETCH_OBJ_W in function `test` is primed with the
class for C. The next call uses a simplexml instance and reuses the same
cache slot. simplexml's get_property_ptr handler does not use the cache
slot, so the old values remain in the cache slot. When
`zend_handle_fetch_obj_flags` is called this is not guarded by a check
for the class entry. So we end up using the prop_info from the property
C::$a instead of the simplexml property.

This patch adds a reset to the cache slots in the property address fetch
code and also in the extensions with a non-standard reference handler.
This keeps the run time cache consistent and avoids the issue without
complicating the fast paths.

Closes GH-17739.
2025-03-02 22:33:32 +01:00
Gina Peter Banyard
7f321a1313
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/pdo: Fix a UAF when changing default fetch class ctor args
2025-01-26 23:37:14 +00:00
Gina Peter Banyard
3027600ffc
ext/pdo: Fix a UAF when changing default fetch class ctor args
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-01-26 23:32:35 +00:00
Gina Peter Banyard
5b06a066f6
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entries
  Fix crash in firebird statement dtor
  ext/pdo: Fix memory leak if GC needs to free PDO Statement
2025-01-24 20:22:13 +00:00
Gina Peter Banyard
99f8ec33d9
ext/pdo: Fix memory leak if GC needs to free PDO Statement 2025-01-24 20:16:12 +00:00
Saki Takamachi
a800a03562
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Added gc_handler to properly handle circular references. (#16703)
2024-11-06 20:32:33 +09:00
Saki Takamachi
ca27e40a5f
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Added gc_handler to properly handle circular references. (#16703)
2024-11-06 20:31:30 +09:00
Saki Takamachi
4d14325b19
Added gc_handler to properly handle circular references. (#16703)
closes #16703

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2024-11-06 20:30:08 +09: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
Arnaud Le Blanc
1fbb666545
Use zend_std_build_properties() to access zend_object.properties
The zend_object.properties HashTable needs to be built just in time by calling
rebuild_object_properties() on the object before accessing it. Normally this is
done automatically in zend_std_get_properties(), but we do it manually in a few
places.

In this change I introduce an inline variant of zend_std_build_properties(), and
refactor these places to use it instead of calling rebuild_object_properties()
manually.

rebuild_object_properties() renamed as rebuild_object_properties_internal(), to
enforce usage of zend_std_get_properties() or zend_std_build_properties_ex().

Closes GH-14996
2024-07-18 22:18:38 +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
Levi Morrison
c461b60060
refactor: change zend_is_true to return bool (#14301)
Previously this returned `int`. Many functions actually take advantage
of the fact this returns exactly 0 or 1. For instance,
`main/streams/xp_socket.c` does:

    sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);

And `Zend/zend_compile.c` does:

    child = &ast->child[2 - zend_is_true(zend_ast_get_zval(ast->child[0]))];

I changed a few places trivially from `int` to `bool`, but there are
still many places such as the object handlers which return `int` that
should eventually be `bool`.
2024-05-24 15:16:36 -06:00
Niels Dossche
ad1dfa35f2
Minor PDO conditions cleanup (#13584)
* Get rid of inverted NULL checks

As the dbh pointer is already used in address computation,
the NULL checks is redundant. Looking at the callers
there are no cases where this can be passed as NULL.

* Message can't be NULL here

* Remove null check for return_value

As one of the branches dereferences return_value unconditionally, the
NULL check is dubious. In fact, looking at the callers we see that
return_value can never be NULL. So remove the check and fix the comment.
2024-03-04 17:36:51 +01:00
Gina Peter Banyard
5c7a0abe55
Merge branch 'PHP-8.3'
* PHP-8.3:
  ext/pdo: Fix various PDORow bugs
2024-02-27 15:32:20 +00:00
Gina Peter Banyard
ddebe469e1
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/pdo: Fix various PDORow bugs
2024-02-27 15:31:48 +00:00
Gina Peter Banyard
b4e272c56a
ext/pdo: Fix various PDORow bugs
- Add tests
- NULL derefencing in read_dimension handler
- Fix isset()
- Fix empty() with column numbers as offsets
- Refactoring to use common functions
2024-02-27 15:30:23 +00:00
Máté Kocsis
d6a0b3af68
Implement PDO driver-specific subclasses
RFC: https://wiki.php.net/rfc/pdo_driver_specific_subclasses
Closes GH-12804

Co-Authored-By: Danack <Danack@basereality.com>
2024-01-11 23:22:41 +01:00
David CARLIER
9726721560
general signatures discrepencies fixes (#13122) 2024-01-10 22:19:23 +00:00
Máté Kocsis
7936c8085e
Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385) 2023-01-23 10:52:14 +01:00
Bob Weinand
a01dd9feda Revert "Port all internally used classes to use default_object_handlers"
This reverts commit 94ee4f9834.

The commit was a bit too late to be included in PHP 8.2 RC1. Given it's a massive ABI break, we decide to postpone the change to PHP 8.3.
2022-09-14 11:13:23 +02:00
Bob Weinand
94ee4f9834 Port all internally used classes to use default_object_handlers
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
David Carlier
59503c0518 Merge branch 'PHP-8.1' 2022-06-02 17:36:02 +01:00
David Carlier
0f428ae240 Merge branch 'PHP-8.0' into PHP-8.1 2022-06-02 17:35:45 +01:00
Yurun
df52903ee0 Closes GH-8626: Fix PDOStatement->execute() failed.
Then execute successfully, errorInfo() information is incorrect
2022-06-02 17:32:43 +01:00
hassan
888bec1be3
Merge duplicate identical conditions in PDO (#7638) 2021-11-10 12:21:04 +00:00
Nikita Popov
8a26cbe0dd Remove unnecessary PDORow get_method / get_class_name handlers
These implement the default behavior, but badly.
2021-07-22 10:40:10 +02:00
Joe Watkins
570d9b63e9
Not serializable flag permeation 2021-07-20 12:28:35 +02:00
Nikita Popov
9d2a466c4b Remove explicit assignments of zend_objects_destroy_object
This is the default handler, no need to set it explicitly. This
makes it easier to see which objects really have a custom dtor_obj.
2021-06-09 11:29:50 +02:00
Nikita Popov
91eb201fd8 Allow initializing assignment to PDOStatement::$queryString
If the object is not created through PDO::prepare(), e.g. in a
mock scenario, it should still be possible to initialize the
$queryString property.

See bug #81084.
2021-05-31 14:54:29 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Máté Kocsis
7df7867624
Merge branch 'PHP-8.0'
* Fix the signature of PDOStatement::fetchObject()
2021-05-05 16:51:23 +02:00
Máté Kocsis
068c8db276
Fix the signature of PDOStatement::fetchObject()
The ?array $ctorArgs = null parameter is changed to array $constructorArgs = [], and an additional memory leak revealed by the new test case is fixed.

Closes GH-6937

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
2021-05-05 16:48:22 +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
Kamil Tekiela
0a779040a0 Add test case for errorCode() 2021-04-25 15:57:43 +01:00
Kamil Tekiela
3292b9761a Add ZEND_ASSERT to stmt->errorCode 2021-04-25 15:57:43 +01:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Máté Kocsis
f15d52796e
Declare PDORow::queryString property
Relates GH-6742
2021-03-17 09:42:35 +01:00
George Peter Banyard
262744ff0d Boolify pdo_stmt_describe_columns() 2021-03-15 14:48:33 +00:00
Nikita Popov
7e3840df90 Assert that stmt is set in PDORow 2021-03-15 14:22:49 +01:00
Nikita Popov
f7751f2d8b Use zend_objects_not_comparable in PDO 2021-03-15 13:01:42 +01:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
George Peter Banyard
ef36de1317 Use zend_string_equals() in PDO
Closes GH-6623
2021-01-19 15:11:21 +00:00
Nikita Popov
7aa00369b0 Switch bound_param_map to zend_string 2021-01-07 15:53:47 +00:00