Skip to content

Commit 1d59b37

Browse files
committed
Fix build with sqlite3 gc and fci/fcc api
1 parent cb6fac5 commit 1d59b37

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

ext/sqlite3/sqlite3.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,18 @@ static void php_sqlite3_object_free_storage(zend_object *object) /* {{{ */
22452245
}
22462246
/* }}} */
22472247

2248+
static void php_sqlite3_gc_buffer_add_fcc(zend_get_gc_buffer *gc_buffer, zend_fcall_info_cache *fcc)
2249+
{
2250+
if (ZEND_FCC_INITIALIZED(*fcc)) {
2251+
if (fcc->object) {
2252+
zend_get_gc_buffer_add_obj(gc_buffer, fcc->object);
2253+
}
2254+
if (fcc->closure) {
2255+
zend_get_gc_buffer_add_obj(gc_buffer, fcc->closure);
2256+
}
2257+
}
2258+
}
2259+
22482260
static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n)
22492261
{
22502262
php_sqlite3_db_object *intern = php_sqlite3_db_from_obj(object);
@@ -2259,15 +2271,15 @@ static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n)
22592271

22602272
php_sqlite3_func *func = intern->funcs;
22612273
while (func != NULL) {
2262-
zend_get_gc_buffer_add_zval(gc_buffer, &func->func);
2263-
zend_get_gc_buffer_add_zval(gc_buffer, &func->step);
2264-
zend_get_gc_buffer_add_zval(gc_buffer, &func->fini);
2274+
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->func);
2275+
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->step);
2276+
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->fini);
22652277
func = func->next;
22662278
}
22672279

22682280
php_sqlite3_collation *collation = intern->collations;
22692281
while (collation != NULL) {
2270-
zend_get_gc_buffer_add_zval(gc_buffer, &collation->cmp_func);
2282+
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &collation->cmp_func);
22712283
collation = collation->next;
22722284
}
22732285

ext/sqlite3/tests/gh11878.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ class Foo {
1010
$this->sqlite = new SQLite3(":memory:");
1111
if ($aggregates) {
1212
$this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 0);
13+
$this->sqlite->createAggregate("indexes_closure", fn () => 0, fn () => 0, 0);
1314
}
1415
if ($normalFunctions) {
1516
$this->sqlite->createFunction("func", array($this, "SQLiteIndex"), 0);
17+
$this->sqlite->createFunction("func_closure", fn () => 0, 0);
1618
$this->sqlite->createCollation("collation", array($this, "SQLiteIndex"));
19+
$this->sqlite->createCollation("collation_closure", fn () => 0);
1720
}
1821
}
1922
public function SQLiteIndex() {}

0 commit comments

Comments
 (0)