@@ -514,12 +514,13 @@ static int php_sqlite3_collation_callback(void *context,
514
514
return ret ;
515
515
}
516
516
517
- /* {{{ bool SQLite::sqliteCreateFunction(string name, mixed callback [, int argcount, int flags])
517
+ /* {{{ bool SQLite::sqliteCreateFunction(string name, callable callback [, int argcount, int flags])
518
518
Registers a UDF with the sqlite db handle */
519
519
static PHP_METHOD (SQLite , sqliteCreateFunction )
520
520
{
521
521
struct pdo_sqlite_func * func ;
522
- zval * callback ;
522
+ zend_fcall_info fci ;
523
+ zend_fcall_info_cache fcc ;
523
524
char * func_name ;
524
525
size_t func_name_len ;
525
526
zend_long argc = -1 ;
@@ -530,7 +531,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
530
531
531
532
ZEND_PARSE_PARAMETERS_START (2 , 4 )
532
533
Z_PARAM_STRING (func_name , func_name_len )
533
- Z_PARAM_ZVAL ( callback )
534
+ Z_PARAM_FUNC ( fci , fcc )
534
535
Z_PARAM_OPTIONAL
535
536
Z_PARAM_LONG (argc )
536
537
Z_PARAM_LONG (flags )
@@ -539,13 +540,6 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
539
540
dbh = Z_PDO_DBH_P (ZEND_THIS );
540
541
PDO_CONSTRUCT_CHECK ;
541
542
542
- if (!zend_is_callable (callback , 0 , NULL )) {
543
- zend_string * cbname = zend_get_callable_name (callback );
544
- php_error_docref (NULL , E_WARNING , "Function '%s' is not callable" , ZSTR_VAL (cbname ));
545
- zend_string_release_ex (cbname , 0 );
546
- RETURN_FALSE ;
547
- }
548
-
549
543
H = (pdo_sqlite_db_handle * )dbh -> driver_data ;
550
544
551
545
func = (struct pdo_sqlite_func * )ecalloc (1 , sizeof (* func ));
@@ -555,7 +549,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
555
549
if (ret == SQLITE_OK ) {
556
550
func -> funcname = estrdup (func_name );
557
551
558
- ZVAL_COPY (& func -> func , callback );
552
+ ZVAL_COPY (& func -> func , & fci . function_name );
559
553
560
554
func -> argc = argc ;
561
555
@@ -570,7 +564,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
570
564
}
571
565
/* }}} */
572
566
573
- /* {{{ bool SQLite::sqliteCreateAggregate(string name, mixed step, mixed fini [, int argcount])
567
+ /* {{{ bool SQLite::sqliteCreateAggregate(string name, callable step, callable fini [, int argcount])
574
568
Registers a UDF with the sqlite db handle */
575
569
576
570
/* The step function should have the prototype:
@@ -592,7 +586,8 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
592
586
static PHP_METHOD (SQLite , sqliteCreateAggregate )
593
587
{
594
588
struct pdo_sqlite_func * func ;
595
- zval * step_callback , * fini_callback ;
589
+ zend_fcall_info step_fci , fini_fci ;
590
+ zend_fcall_info_cache step_fcc , fini_fcc ;
596
591
char * func_name ;
597
592
size_t func_name_len ;
598
593
zend_long argc = -1 ;
@@ -602,29 +597,15 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
602
597
603
598
ZEND_PARSE_PARAMETERS_START (3 , 4 )
604
599
Z_PARAM_STRING (func_name , func_name_len )
605
- Z_PARAM_ZVAL ( step_callback )
606
- Z_PARAM_ZVAL ( fini_callback )
600
+ Z_PARAM_FUNC ( step_fci , step_fcc )
601
+ Z_PARAM_FUNC ( fini_fci , fini_fcc )
607
602
Z_PARAM_OPTIONAL
608
603
Z_PARAM_LONG (argc )
609
604
ZEND_PARSE_PARAMETERS_END ();
610
605
611
606
dbh = Z_PDO_DBH_P (ZEND_THIS );
612
607
PDO_CONSTRUCT_CHECK ;
613
608
614
- if (!zend_is_callable (step_callback , 0 , NULL )) {
615
- zend_string * cbname = zend_get_callable_name (step_callback );
616
- php_error_docref (NULL , E_WARNING , "Function '%s' is not callable" , ZSTR_VAL (cbname ));
617
- zend_string_release_ex (cbname , 0 );
618
- RETURN_FALSE ;
619
- }
620
-
621
- if (!zend_is_callable (fini_callback , 0 , NULL )) {
622
- zend_string * cbname = zend_get_callable_name (fini_callback );
623
- php_error_docref (NULL , E_WARNING , "Function '%s' is not callable" , ZSTR_VAL (cbname ));
624
- zend_string_release_ex (cbname , 0 );
625
- RETURN_FALSE ;
626
- }
627
-
628
609
H = (pdo_sqlite_db_handle * )dbh -> driver_data ;
629
610
630
611
func = (struct pdo_sqlite_func * )ecalloc (1 , sizeof (* func ));
@@ -634,9 +615,9 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
634
615
if (ret == SQLITE_OK ) {
635
616
func -> funcname = estrdup (func_name );
636
617
637
- ZVAL_COPY (& func -> step , step_callback );
618
+ ZVAL_COPY (& func -> step , & step_fci . function_name );
638
619
639
- ZVAL_COPY (& func -> fini , fini_callback );
620
+ ZVAL_COPY (& func -> fini , & fini_fci . function_name );
640
621
641
622
func -> argc = argc ;
642
623
@@ -651,12 +632,13 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
651
632
}
652
633
/* }}} */
653
634
654
- /* {{{ bool SQLite::sqliteCreateCollation(string name, mixed callback)
635
+ /* {{{ bool SQLite::sqliteCreateCollation(string name, callable callback)
655
636
Registers a collation with the sqlite db handle */
656
637
static PHP_METHOD (SQLite , sqliteCreateCollation )
657
638
{
658
639
struct pdo_sqlite_collation * collation ;
659
- zval * callback ;
640
+ zend_fcall_info fci ;
641
+ zend_fcall_info_cache fcc ;
660
642
char * collation_name ;
661
643
size_t collation_name_len ;
662
644
pdo_dbh_t * dbh ;
@@ -665,19 +647,12 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
665
647
666
648
ZEND_PARSE_PARAMETERS_START (2 , 2 )
667
649
Z_PARAM_STRING (collation_name , collation_name_len )
668
- Z_PARAM_ZVAL ( callback )
650
+ Z_PARAM_FUNC ( fci , fcc )
669
651
ZEND_PARSE_PARAMETERS_END ();
670
652
671
653
dbh = Z_PDO_DBH_P (ZEND_THIS );
672
654
PDO_CONSTRUCT_CHECK ;
673
655
674
- if (!zend_is_callable (callback , 0 , NULL )) {
675
- zend_string * cbname = zend_get_callable_name (callback );
676
- php_error_docref (NULL , E_WARNING , "Function '%s' is not callable" , ZSTR_VAL (cbname ));
677
- zend_string_release_ex (cbname , 0 );
678
- RETURN_FALSE ;
679
- }
680
-
681
656
H = (pdo_sqlite_db_handle * )dbh -> driver_data ;
682
657
683
658
collation = (struct pdo_sqlite_collation * )ecalloc (1 , sizeof (* collation ));
@@ -686,7 +661,7 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
686
661
if (ret == SQLITE_OK ) {
687
662
collation -> name = estrdup (collation_name );
688
663
689
- ZVAL_COPY (& collation -> callback , callback );
664
+ ZVAL_COPY (& collation -> callback , & fci . function_name );
690
665
691
666
collation -> next = H -> collations ;
692
667
H -> collations = collation ;
0 commit comments