@@ -44,13 +44,6 @@ static int php_sqlite3_compare_stmt_zval_free(php_sqlite3_free_list **free_list,
44
44
RETURN_THROWS(); \
45
45
}
46
46
47
- #define SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE (db_obj , member , class_name , trampoline_fcc ) \
48
- if (!(db_obj) || !(member)) { \
49
- zend_release_fcall_info_cache((trampoline_fcc)); \
50
- zend_throw_error(NULL, "The " #class_name " object has not been correctly initialised or is already closed"); \
51
- RETURN_THROWS(); \
52
- }
53
-
54
47
#define SQLITE3_CHECK_INITIALIZED_STMT (member , class_name ) \
55
48
if (!(member)) { \
56
49
zend_throw_error(NULL, "The " #class_name " object has not been correctly initialised or is already closed"); \
@@ -949,16 +942,13 @@ PHP_METHOD(SQLite3, createFunction)
949
942
zend_long flags = 0 ;
950
943
db_obj = Z_SQLITE3_DB_P (object );
951
944
952
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sF|ll" , & sql_func , & sql_func_len , & fci , & fcc , & sql_func_num_args , & flags ) == FAILURE ) {
953
- zend_release_fcall_info_cache (& fcc );
945
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "sf|ll" , & sql_func , & sql_func_len , & fci , & fcc , & sql_func_num_args , & flags ) == FAILURE ) {
954
946
RETURN_THROWS ();
955
947
}
956
948
957
- SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE (db_obj , db_obj -> initialised , SQLite3 , & fcc );
949
+ SQLITE3_CHECK_INITIALIZED (db_obj , db_obj -> initialised , SQLite3 )
958
950
959
951
if (!sql_func_len ) {
960
- /* TODO Add warning/ValueError that name cannot be empty? */
961
- zend_release_fcall_info_cache (& fcc );
962
952
RETURN_FALSE ;
963
953
}
964
954
@@ -1000,24 +990,13 @@ PHP_METHOD(SQLite3, createAggregate)
1000
990
zend_long sql_func_num_args = -1 ;
1001
991
db_obj = Z_SQLITE3_DB_P (object );
1002
992
1003
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sFF|l" , & sql_func , & sql_func_len , & step_fci , & step_fcc , & fini_fci , & fini_fcc , & sql_func_num_args ) == FAILURE ) {
1004
- zend_release_fcall_info_cache (& step_fcc );
1005
- zend_release_fcall_info_cache (& fini_fcc );
993
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "sff|l" , & sql_func , & sql_func_len , & step_fci , & step_fcc , & fini_fci , & fini_fcc , & sql_func_num_args ) == FAILURE ) {
1006
994
RETURN_THROWS ();
1007
995
}
1008
996
1009
- /* Cannot use SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE() as we have 2 FCCs */
1010
- if (!db_obj || !db_obj -> initialised ) {
1011
- zend_release_fcall_info_cache (& step_fcc );
1012
- zend_release_fcall_info_cache (& fini_fcc );
1013
- zend_throw_error (NULL , "The SQLite3 object has not been correctly initialised or is already closed" );
1014
- RETURN_THROWS ();
1015
- }
997
+ SQLITE3_CHECK_INITIALIZED (db_obj , db_obj -> initialised , SQLite3 )
1016
998
1017
999
if (!sql_func_len ) {
1018
- /* TODO Add warning/ValueError that name cannot be empty? */
1019
- zend_release_fcall_info_cache (& step_fcc );
1020
- zend_release_fcall_info_cache (& fini_fcc );
1021
1000
RETURN_FALSE ;
1022
1001
}
1023
1002
@@ -1026,7 +1005,19 @@ PHP_METHOD(SQLite3, createAggregate)
1026
1005
if (sqlite3_create_function (db_obj -> db , sql_func , sql_func_num_args , SQLITE_UTF8 , func , NULL , php_sqlite3_callback_step , php_sqlite3_callback_final ) == SQLITE_OK ) {
1027
1006
func -> func_name = estrdup (sql_func );
1028
1007
1008
+ if (!ZEND_FCC_INITIALIZED (step_fcc )) {
1009
+ /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
1010
+ * with it outselves. It is important that it is not refetched on every call,
1011
+ * because calls may occur from different scopes. */
1012
+ zend_is_callable_ex (& step_fci .function_name , NULL , IS_CALLABLE_SUPPRESS_DEPRECATIONS , NULL , & step_fcc , NULL );
1013
+ }
1029
1014
zend_fcc_dup (& func -> step , & step_fcc );
1015
+ if (!ZEND_FCC_INITIALIZED (fini_fcc )) {
1016
+ /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
1017
+ * with it outselves. It is important that it is not refetched on every call,
1018
+ * because calls may occur from different scopes. */
1019
+ zend_is_callable_ex (& fini_fci .function_name , NULL , IS_CALLABLE_SUPPRESS_DEPRECATIONS , NULL , & fini_fcc , NULL );
1020
+ }
1030
1021
zend_fcc_dup (& func -> fini , & fini_fcc );
1031
1022
1032
1023
func -> argc = sql_func_num_args ;
@@ -1053,22 +1044,26 @@ PHP_METHOD(SQLite3, createCollation)
1053
1044
zend_fcall_info_cache fcc ;
1054
1045
db_obj = Z_SQLITE3_DB_P (object );
1055
1046
1056
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sF " , & collation_name , & collation_name_len , & fci , & fcc ) == FAILURE ) {
1047
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "sf " , & collation_name , & collation_name_len , & fci , & fcc ) == FAILURE ) {
1057
1048
RETURN_THROWS ();
1058
1049
}
1059
1050
1060
- SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE (db_obj , db_obj -> initialised , SQLite3 , & fcc );
1051
+ SQLITE3_CHECK_INITIALIZED (db_obj , db_obj -> initialised , SQLite3 )
1061
1052
1062
1053
if (!collation_name_len ) {
1063
- /* TODO Add warning/ValueError that name cannot be empty? */
1064
- zend_release_fcall_info_cache (& fcc );
1065
1054
RETURN_FALSE ;
1066
1055
}
1067
1056
1068
1057
collation = (php_sqlite3_collation * )ecalloc (1 , sizeof (* collation ));
1069
1058
if (sqlite3_create_collation (db_obj -> db , collation_name , SQLITE_UTF8 , collation , php_sqlite3_callback_compare ) == SQLITE_OK ) {
1070
1059
collation -> collation_name = estrdup (collation_name );
1071
1060
1061
+ if (!ZEND_FCC_INITIALIZED (fcc )) {
1062
+ /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
1063
+ * with it outselves. It is important that it is not refetched on every call,
1064
+ * because calls may occur from different scopes. */
1065
+ zend_is_callable_ex (& fci .function_name , NULL , IS_CALLABLE_SUPPRESS_DEPRECATIONS , NULL , & fcc , NULL );
1066
+ }
1072
1067
zend_fcc_dup (& collation -> cmp_func , & fcc );
1073
1068
1074
1069
collation -> next = db_obj -> collations ;
@@ -1322,10 +1317,10 @@ PHP_METHOD(SQLite3, setAuthorizer)
1322
1317
zend_fcall_info_cache fcc ;
1323
1318
1324
1319
ZEND_PARSE_PARAMETERS_START (1 , 1 )
1325
- Z_PARAM_FUNC_NO_TRAMPOLINE_FREE_OR_NULL (fci , fcc )
1320
+ Z_PARAM_FUNC_OR_NULL (fci , fcc )
1326
1321
ZEND_PARSE_PARAMETERS_END ();
1327
1322
1328
- SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE (db_obj , db_obj -> initialised , SQLite3 , & fcc );
1323
+ SQLITE3_CHECK_INITIALIZED (db_obj , db_obj -> initialised , SQLite3 )
1329
1324
1330
1325
/* Clear previously set callback */
1331
1326
if (ZEND_FCC_INITIALIZED (db_obj -> authorizer_fcc )) {
@@ -1334,7 +1329,14 @@ PHP_METHOD(SQLite3, setAuthorizer)
1334
1329
1335
1330
/* Only enable userland authorizer if argument is not NULL */
1336
1331
if (ZEND_FCI_INITIALIZED (fci )) {
1337
- zend_fcc_dup (& db_obj -> authorizer_fcc , & fcc );
1332
+ if (!ZEND_FCC_INITIALIZED (fcc )) {
1333
+ zend_is_callable_ex (& fci .function_name , NULL , IS_CALLABLE_SUPPRESS_DEPRECATIONS , NULL , & fcc , NULL );
1334
+ /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
1335
+ * with it outselves. It is important that it is not refetched on every call,
1336
+ * because calls may occur from different scopes. */
1337
+ }
1338
+ db_obj -> authorizer_fcc = fcc ;
1339
+ zend_fcc_addref (& db_obj -> authorizer_fcc );
1338
1340
}
1339
1341
1340
1342
RETURN_TRUE ;
0 commit comments