Skip to content

Commit

Permalink
Fix build with sqlite3 gc and fci/fcc api
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsdos committed Sep 9, 2023
1 parent cb6fac5 commit 1d59b37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2245,6 +2245,18 @@ static void php_sqlite3_object_free_storage(zend_object *object) /* {{{ */
}
/* }}} */

static void php_sqlite3_gc_buffer_add_fcc(zend_get_gc_buffer *gc_buffer, zend_fcall_info_cache *fcc)
{
if (ZEND_FCC_INITIALIZED(*fcc)) {
if (fcc->object) {
zend_get_gc_buffer_add_obj(gc_buffer, fcc->object);
}
if (fcc->closure) {
zend_get_gc_buffer_add_obj(gc_buffer, fcc->closure);
}
}
}

This comment has been minimized.

Copy link
@Girgias

Girgias Sep 9, 2023

Member

This very close to the implementation of zend_get_gc_buffer_add_fcc() except that it expects the FCC to be initialized, you could probably call this within the if block.

This comment has been minimized.

Copy link
@nielsdos

nielsdos Sep 9, 2023

Author Member

Ugh why did I miss zend_get_gc_buffer_add_fcc existence, I'll fix it up soon...

This comment has been minimized.

Copy link
@Girgias

Girgias Sep 9, 2023

Member

To be fair, it is not described where all the other zend_get_gc_add_* functions are :')


static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n)
{
php_sqlite3_db_object *intern = php_sqlite3_db_from_obj(object);
Expand All @@ -2259,15 +2271,15 @@ static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n)

php_sqlite3_func *func = intern->funcs;
while (func != NULL) {
zend_get_gc_buffer_add_zval(gc_buffer, &func->func);
zend_get_gc_buffer_add_zval(gc_buffer, &func->step);
zend_get_gc_buffer_add_zval(gc_buffer, &func->fini);
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->func);
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->step);
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->fini);
func = func->next;
}

php_sqlite3_collation *collation = intern->collations;
while (collation != NULL) {
zend_get_gc_buffer_add_zval(gc_buffer, &collation->cmp_func);
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &collation->cmp_func);
collation = collation->next;
}

Expand Down
3 changes: 3 additions & 0 deletions ext/sqlite3/tests/gh11878.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ class Foo {
$this->sqlite = new SQLite3(":memory:");
if ($aggregates) {
$this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 0);
$this->sqlite->createAggregate("indexes_closure", fn () => 0, fn () => 0, 0);
}
if ($normalFunctions) {
$this->sqlite->createFunction("func", array($this, "SQLiteIndex"), 0);
$this->sqlite->createFunction("func_closure", fn () => 0, 0);
$this->sqlite->createCollation("collation", array($this, "SQLiteIndex"));
$this->sqlite->createCollation("collation_closure", fn () => 0);
}
}
public function SQLiteIndex() {}
Expand Down

0 comments on commit 1d59b37

Please sign in to comment.