Skip to content

ext/pdo: Refactor PDO::FETCH_CLASS to not rely on a FCI and use a HashTable for ctor_arg #17427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ PHP 8.5 UPGRADE NOTES
. pcntl_exec() now throws ValueErrors when entries or keys of the
$env_vars parameter contain null bytes.

- PDO:
. The constructor arguments set in conjunction with PDO::FETCH_CLASS now
follow the usual CUFA (call_user_func_array) semantics.
This means string keys will act like a named argument.
Moreover, automatic wrapping for by-value arguments passed to a by-ref
parameter has been removed, and the usual E_WARNING about this is now
emitted.
To pass a variable by-ref to a constructor argument use the general
array value reference assignment: $ctor_args = [&$valByRef]
. Attempting to modify a PDOStatement during a call to PDO::fetch(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be worded better? I assume you mean that the default fetch mode cannot be changed, right? It seems like I can still make other changes to the object, e.g. execute it again. Also, it's not immediately clear what is meant by "during a call".

Reposting the comment for better visibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, while it's now forbidden to change the default fetch mode, the actual fetch mode can still be changed via the parameter to fetch/fetchAll.

I wonder if there exists a driver that allows the default fetch mode to be changed via PDOStatement::setAttribute.

What exactly is the reason behind introduction of this error?

PDO::fetchObject(), PDO::fetchAll() will now throw an Error.

- PDO_FIREBIRD:
. A ValueError is now thrown when trying to set a cursor name that is too
long on a PDOStatement resulting from the Firebird driver.
Expand Down
12 changes: 12 additions & 0 deletions Zend/zend_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ static zend_always_inline void zend_get_gc_buffer_add_obj(
gc_buffer->cur++;
}

static zend_always_inline void zend_get_gc_buffer_add_ht(
zend_get_gc_buffer *gc_buffer, HashTable *ht) {
if (GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) {
return;
}
if (UNEXPECTED(gc_buffer->cur == gc_buffer->end)) {
zend_get_gc_buffer_grow(gc_buffer);
}
ZVAL_ARR(gc_buffer->cur, ht);
gc_buffer->cur++;
}

static zend_always_inline void zend_get_gc_buffer_add_ptr(
zend_get_gc_buffer *gc_buffer, void *ptr) {
if (UNEXPECTED(gc_buffer->cur == gc_buffer->end)) {
Expand Down
Loading