@@ -428,8 +428,7 @@ static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry
428
428
/* This implies an error within PDO if this does not hold */
429
429
ZEND_ASSERT (Z_TYPE_P (ctor_args ) == IS_ARRAY );
430
430
if (!dbstmt_ce -> constructor ) {
431
- /* TODO Error? */
432
- pdo_raise_impl_error (dbh , NULL , "HY000" , "user-supplied statement does not accept constructor arguments" );
431
+ zend_throw_error (NULL , "User-supplied statement does not accept constructor arguments" );
433
432
return NULL ;
434
433
}
435
434
}
@@ -508,34 +507,31 @@ PHP_METHOD(PDO, prepare)
508
507
509
508
if (options && (value = zend_hash_index_find (Z_ARRVAL_P (options ), PDO_ATTR_STATEMENT_CLASS )) != NULL ) {
510
509
if (Z_TYPE_P (value ) != IS_ARRAY ) {
511
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's value must be of type array, %s given" ,
510
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given" ,
512
511
zend_zval_type_name (value ));
513
512
RETURN_THROWS ();
514
513
}
515
514
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) == NULL ) {
516
- zend_value_error ("PDO::ATTR_STATEMENT_CLASS's value must be an array with the following "
517
- "format array(classname, array(ctor_args))" );
515
+ zend_value_error ("PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
516
+ "array(classname, array(ctor_args))" );
518
517
RETURN_THROWS ();
519
518
}
520
519
if (Z_TYPE_P (item ) != IS_STRING || (pce = zend_lookup_class (Z_STR_P (item ))) == NULL ) {
521
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's class must be a valid class" );
520
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS class must be a valid class" );
522
521
RETURN_THROWS ();
523
522
}
524
523
dbstmt_ce = pce ;
525
524
if (!instanceof_function (dbstmt_ce , pdo_dbstmt_ce )) {
526
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's class must be derived from PDOStatement" );
525
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement" );
527
526
RETURN_THROWS ();
528
527
}
529
528
if (dbstmt_ce -> constructor && !(dbstmt_ce -> constructor -> common .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED ))) {
530
- /* TODO Always Error? */
531
- pdo_raise_impl_error (dbh , NULL , "HY000" ,
532
- "user-supplied statement class cannot have a public constructor" );
533
- PDO_HANDLE_DBH_ERR ();
534
- RETURN_FALSE ;
529
+ zend_type_error ("User-supplied statement class cannot have a public constructor" );
530
+ RETURN_THROWS ();
535
531
}
536
532
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
537
533
if (Z_TYPE_P (item ) != IS_ARRAY ) {
538
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's ctor_args must be ?array, %s given" ,
534
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS ctor_args must be ?array, %s given" ,
539
535
zend_zval_type_name (value ));
540
536
RETURN_THROWS ();
541
537
}
@@ -548,12 +544,10 @@ PHP_METHOD(PDO, prepare)
548
544
ZVAL_COPY_VALUE (& ctor_args , & dbh -> def_stmt_ctor_args );
549
545
}
550
546
547
+ /* Need to check if pdo_stmt_instantiate() throws an exception unconditionally to see if can change the RETURN_FALSE; */
551
548
if (!pdo_stmt_instantiate (dbh , return_value , dbstmt_ce , & ctor_args )) {
552
549
if (EXPECTED (!EG (exception ))) {
553
- /* TODO Error? */
554
- pdo_raise_impl_error (dbh , NULL , "HY000" ,
555
- "failed to instantiate user-supplied statement class"
556
- );
550
+ zend_throw_error (NULL , "Cannot instantiate user-supplied statement class" );
557
551
}
558
552
PDO_HANDLE_DBH_ERR ();
559
553
RETURN_FALSE ;
@@ -701,7 +695,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
701
695
dbh -> error_mode = lval ;
702
696
return SUCCESS ;
703
697
default :
704
- zend_value_error ("Error mode must be one of PDO::ERRMODE_* constants" );
698
+ zend_value_error ("Error mode must be one of the PDO::ERRMODE_* constants" );
705
699
return FAILURE ;
706
700
}
707
701
return FAILURE ;
@@ -716,7 +710,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
716
710
dbh -> desired_case = lval ;
717
711
return SUCCESS ;
718
712
default :
719
- zend_value_error ("Case folding mode must be one of PDO::CASE_* constants" );
713
+ zend_value_error ("Case folding mode must be one of the PDO::CASE_* constants" );
720
714
return FAILURE ;
721
715
}
722
716
return FAILURE ;
@@ -731,7 +725,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
731
725
zval * tmp ;
732
726
if ((tmp = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) != NULL && Z_TYPE_P (tmp ) == IS_LONG ) {
733
727
if (Z_LVAL_P (tmp ) == PDO_FETCH_INTO || Z_LVAL_P (tmp ) == PDO_FETCH_CLASS ) {
734
- zend_value_error ("PDO::FETCH_INTO and PDO::FETCH_CLASS cannot be set as default fetch mode" );
728
+ zend_value_error ("PDO::FETCH_INTO and PDO::FETCH_CLASS cannot be set as the default fetch mode" );
735
729
return FAILURE ;
736
730
}
737
731
}
@@ -764,28 +758,25 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
764
758
return FAILURE ;
765
759
}
766
760
if (Z_TYPE_P (value ) != IS_ARRAY ) {
767
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's value must be of type array, %s given" ,
761
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given" ,
768
762
zend_zval_type_name (value ));
769
763
return FAILURE ;
770
764
}
771
765
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) == NULL ) {
772
- zend_value_error ("PDO::ATTR_STATEMENT_CLASS's value must be an array with the following "
773
- "format array(classname, array(ctor_args))" );
766
+ zend_value_error ("PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
767
+ "array(classname, array(ctor_args))" );
774
768
return FAILURE ;
775
769
}
776
770
if (Z_TYPE_P (item ) != IS_STRING || (pce = zend_lookup_class (Z_STR_P (item ))) == NULL ) {
777
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's class must be a valid class" );
771
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS class must be a valid class" );
778
772
return FAILURE ;
779
773
}
780
774
if (!instanceof_function (pce , pdo_dbstmt_ce )) {
781
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's class must be derived from PDOStatement" );
775
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement" );
782
776
return FAILURE ;
783
777
}
784
778
if (pce -> constructor && !(pce -> constructor -> common .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED ))) {
785
- /* TODO Always Error? */
786
- pdo_raise_impl_error (dbh , NULL , "HY000" ,
787
- "user-supplied statement class cannot have a public constructor" );
788
- PDO_HANDLE_DBH_ERR ();
779
+ zend_type_error ("User-supplied statement class cannot have a public constructor" );
789
780
return FAILURE ;
790
781
}
791
782
dbh -> def_stmt_ce = pce ;
@@ -795,7 +786,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
795
786
}
796
787
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
797
788
if (Z_TYPE_P (item ) != IS_ARRAY ) {
798
- zend_type_error ("PDO::ATTR_STATEMENT_CLASS's ctor_args must be ?array, %s given" ,
789
+ zend_type_error ("PDO::ATTR_STATEMENT_CLASS ctor_args must be ?array, %s given" ,
799
790
zend_zval_type_name (value ));
800
791
return FAILURE ;
801
792
}
0 commit comments