4040#define OCI_STMT_CALL 10
4141#endif
4242
43+ #define ERROR_ARG_POS (arg_num ) (getThis() ? (arg_num-1) : (arg_num))
44+
4345/* {{{ Register a callback function for Oracle Transparent Application Failover (TAF) */
4446PHP_FUNCTION (oci_register_taf_callback )
4547{
@@ -109,8 +111,8 @@ PHP_FUNCTION(oci_define_by_name)
109111 ZEND_PARSE_PARAMETERS_END ();
110112
111113 if (!name_len ) {
112- php_error_docref ( NULL , E_WARNING , "Column name cannot be empty" );
113- RETURN_FALSE ;
114+ zend_argument_value_error ( 2 , " cannot be empty" );
115+ RETURN_THROWS () ;
114116 }
115117
116118 PHP_OCI_ZVAL_TO_STATEMENT (stmt , statement );
@@ -210,8 +212,8 @@ PHP_FUNCTION(oci_bind_array_by_name)
210212 }
211213
212214 if (max_array_len <= 0 ) {
213- php_error_docref ( NULL , E_WARNING , "Maximum array length must be greater than zero " );
214- RETURN_FALSE ;
215+ zend_argument_value_error ( 4 , " must be greater than 0 " );
216+ RETURN_THROWS () ;
215217 }
216218
217219 if (php_oci_bind_array_by_name (statement , name , (sb4 ) name_len , bind_var , max_array_len , max_item_len , type )) {
@@ -257,18 +259,18 @@ PHP_FUNCTION(oci_lob_save)
257259 RETURN_THROWS ();
258260 }
259261
262+ if (offset < 0 ) {
263+ zend_argument_value_error (ERROR_ARG_POS (3 ), "must be greater than or equal to 0" );
264+ RETURN_THROWS ();
265+ }
266+
260267 if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
261268 php_error_docref (NULL , E_WARNING , "Unable to find descriptor property" );
262269 RETURN_FALSE ;
263270 }
264271
265272 PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
266273
267- if (offset < 0 ) {
268- php_error_docref (NULL , E_WARNING , "Offset parameter must be greater than or equal to 0" );
269- RETURN_FALSE ;
270- }
271-
272274 if (php_oci_lob_write (descriptor , (ub4 ) offset , data , (ub4 ) data_len , & bytes_written )) {
273275 RETURN_FALSE ;
274276 }
@@ -284,7 +286,7 @@ PHP_FUNCTION(oci_lob_import)
284286 char * filename ;
285287 size_t filename_len ;
286288
287- if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Os " , & z_descriptor , oci_lob_class_entry_ptr , & filename , & filename_len ) == FAILURE ) {
289+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Op " , & z_descriptor , oci_lob_class_entry_ptr , & filename , & filename_len ) == FAILURE ) {
288290 RETURN_THROWS ();
289291 }
290292
@@ -293,11 +295,6 @@ PHP_FUNCTION(oci_lob_import)
293295 RETURN_FALSE ;
294296 }
295297
296- if (CHECK_NULL_PATH (filename , filename_len )) {
297- php_error_docref (NULL , E_WARNING , "filename must not contain null bytes" );
298- RETURN_FALSE ;
299- }
300-
301298 PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
302299
303300 if (php_oci_lob_import (descriptor , filename )) {
@@ -354,18 +351,18 @@ PHP_FUNCTION(oci_lob_read)
354351 RETURN_THROWS ();
355352 }
356353
354+ if (length <= 0 ) {
355+ zend_argument_value_error (ERROR_ARG_POS (2 ), "must be greater than 0" );
356+ RETURN_THROWS ();
357+ }
358+
357359 if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
358360 php_error_docref (NULL , E_WARNING , "Unable to find descriptor property" );
359361 RETURN_FALSE ;
360362 }
361363
362364 PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
363365
364- if (length <= 0 ) {
365- php_error_docref (NULL , E_WARNING , "Length parameter must be greater than 0" );
366- RETURN_FALSE ;
367- }
368-
369366 if (php_oci_lob_read (descriptor , length , descriptor -> lob_current_position , & buffer , & buffer_len )) {
370367 RETURN_FALSE ;
371368 }
@@ -604,13 +601,13 @@ PHP_FUNCTION(oci_lob_truncate)
604601 RETURN_THROWS ();
605602 }
606603
607- if (( tmp = zend_hash_str_find ( Z_OBJPROP_P ( z_descriptor ), "descriptor" , sizeof ( "descriptor" ) - 1 )) == NULL ) {
608- php_error_docref ( NULL , E_WARNING , "Unable to find descriptor property " );
609- RETURN_FALSE ;
604+ if (trim_length < 0 ) {
605+ zend_argument_value_error ( ERROR_ARG_POS ( 2 ), "must be greater than or equal to 0 " );
606+ RETURN_THROWS () ;
610607 }
611608
612- if (trim_length < 0 ) {
613- php_error_docref (NULL , E_WARNING , "Length must be greater than or equal to zero " );
609+ if (( tmp = zend_hash_str_find ( Z_OBJPROP_P ( z_descriptor ), "descriptor" , sizeof ( "descriptor" ) - 1 )) == NULL ) {
610+ php_error_docref (NULL , E_WARNING , "Unable to find descriptor property " );
614611 RETURN_FALSE ;
615612 }
616613
@@ -640,15 +637,15 @@ PHP_FUNCTION(oci_lob_erase)
640637 if (offset_is_null ) {
641638 offset = -1 ;
642639 } else if (offset < 0 ) {
643- php_error_docref ( NULL , E_WARNING , "Offset must be greater than or equal to 0" );
644- RETURN_FALSE ;
640+ zend_argument_value_error ( ERROR_ARG_POS ( 2 ), " must be greater than or equal to 0" );
641+ RETURN_THROWS () ;
645642 }
646643
647644 if (length_is_null ) {
648645 length = -1 ;
649646 } else if (length < 0 ) {
650- php_error_docref ( NULL , E_WARNING , "Length must be greater than or equal to 0" );
651- RETURN_FALSE ;
647+ zend_argument_value_error ( ERROR_ARG_POS ( 3 ), " must be greater than or equal to 0" );
648+ RETURN_THROWS () ;
652649 }
653650
654651 if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
@@ -756,6 +753,13 @@ PHP_FUNCTION(oci_lob_copy)
756753 RETURN_THROWS ();
757754 }
758755
756+ if (length_is_null ) {
757+ length = -1 ;
758+ } else if (length < 0 ) {
759+ zend_argument_value_error (3 , "must be greater than or equal to 0" );
760+ RETURN_THROWS ();
761+ }
762+
759763 if ((tmp_dest = zend_hash_str_find (Z_OBJPROP_P (z_descriptor_dest ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
760764 php_error_docref (NULL , E_WARNING , "Unable to find descriptor property. The first argument should be valid descriptor object" );
761765 RETURN_FALSE ;
@@ -769,13 +773,6 @@ PHP_FUNCTION(oci_lob_copy)
769773 PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp_dest , descriptor_dest );
770774 PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp_from , descriptor_from );
771775
772- if (length_is_null ) {
773- length = -1 ;
774- } else if (length < 0 ) {
775- php_error_docref (NULL , E_WARNING , "Length parameter must be greater than 0" );
776- RETURN_FALSE ;
777- }
778-
779776 if (php_oci_lob_copy (descriptor_dest , descriptor_from , length )) {
780777 RETURN_FALSE ;
781778 }
@@ -831,34 +828,29 @@ PHP_FUNCTION(oci_lob_export)
831828 php_stream * stream ;
832829 ub4 lob_length ;
833830
834- if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Os |l!l!" , & z_descriptor , oci_lob_class_entry_ptr , & filename , & filename_len , & start , & start_is_null , & length , & length_is_null ) == FAILURE ) {
831+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Op |l!l!" , & z_descriptor , oci_lob_class_entry_ptr , & filename , & filename_len , & start , & start_is_null , & length , & length_is_null ) == FAILURE ) {
835832 RETURN_THROWS ();
836833 }
837834
838835 if (start_is_null ) {
839836 start = -1 ;
840837 } else if (start < 0 ) {
841- php_error_docref ( NULL , E_WARNING , "Start parameter must be greater than or equal to 0" );
842- RETURN_FALSE ;
838+ zend_argument_value_error ( ERROR_ARG_POS ( 3 ), " must be greater than or equal to 0" );
839+ RETURN_THROWS () ;
843840 }
844841
845842 if (length_is_null ) {
846843 length = -1 ;
847844 } else if (length < 0 ) {
848- php_error_docref ( NULL , E_WARNING , "length parameter must be greater than or equal to 0" );
849- RETURN_FALSE ;
845+ zend_argument_value_error ( ERROR_ARG_POS ( 4 ), " must be greater than or equal to 0" );
846+ RETURN_THROWS () ;
850847 }
851848
852849 if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
853850 php_error_docref (NULL , E_WARNING , "Unable to find descriptor property" );
854851 RETURN_FALSE ;
855852 }
856853
857- if (CHECK_NULL_PATH (filename , filename_len )) {
858- php_error_docref (NULL , E_WARNING , "filename must not contain null bytes" );
859- RETURN_FALSE ;
860- }
861-
862854 PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
863855
864856 if (php_oci_lob_get_length (descriptor , & lob_length )) {
@@ -1630,8 +1622,8 @@ PHP_FUNCTION(oci_set_prefetch)
16301622 PHP_OCI_ZVAL_TO_STATEMENT (z_statement , statement );
16311623
16321624 if (size < 0 ) {
1633- php_error_docref ( NULL , E_WARNING , "Number of rows to be prefetched has to be greater than or equal to 0" );
1634- return ;
1625+ zend_argument_value_error ( 2 , "must be greater than or equal to 0" );
1626+ RETURN_THROWS () ;
16351627 }
16361628
16371629 if (php_oci_statement_set_prefetch (statement , (ub4 )size )) {
@@ -1899,16 +1891,16 @@ PHP_FUNCTION(oci_password_change)
18991891 PHP_OCI_ZVAL_TO_CONNECTION (z_connection , connection );
19001892
19011893 if (!user_len ) {
1902- php_error_docref ( NULL , E_WARNING , "Username cannot be empty" );
1903- RETURN_FALSE ;
1894+ zend_argument_value_error ( 2 , " cannot be empty" );
1895+ RETURN_THROWS () ;
19041896 }
19051897 if (!pass_old_len ) {
1906- php_error_docref ( NULL , E_WARNING , "Old password cannot be empty" );
1907- RETURN_FALSE ;
1898+ zend_argument_value_error ( 3 , " cannot be empty" );
1899+ RETURN_THROWS () ;
19081900 }
19091901 if (!pass_new_len ) {
1910- php_error_docref ( NULL , E_WARNING , "New password cannot be empty" );
1911- RETURN_FALSE ;
1902+ zend_argument_value_error ( 4 , " cannot be empty" );
1903+ RETURN_THROWS () ;
19121904 }
19131905
19141906 if (php_oci_password_change (connection , user , (int ) user_len , pass_old , (int ) pass_old_len , pass_new , (int ) pass_new_len )) {
@@ -1918,16 +1910,16 @@ PHP_FUNCTION(oci_password_change)
19181910 } else if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "ssss" , & dbname , & dbname_len , & user , & user_len , & pass_old , & pass_old_len , & pass_new , & pass_new_len ) == SUCCESS ) {
19191911
19201912 if (!user_len ) {
1921- php_error_docref ( NULL , E_WARNING , "Username cannot be empty" );
1922- RETURN_FALSE ;
1913+ zend_argument_value_error ( 2 , " cannot be empty" );
1914+ RETURN_THROWS () ;
19231915 }
19241916 if (!pass_old_len ) {
1925- php_error_docref ( NULL , E_WARNING , "Old password cannot be empty" );
1926- RETURN_FALSE ;
1917+ zend_argument_value_error ( 3 , " cannot be empty" );
1918+ RETURN_THROWS () ;
19271919 }
19281920 if (!pass_new_len ) {
1929- php_error_docref ( NULL , E_WARNING , "New password cannot be empty" );
1930- RETURN_FALSE ;
1921+ zend_argument_value_error ( 4 , " cannot be empty" );
1922+ RETURN_THROWS () ;
19311923 }
19321924
19331925 connection = php_oci_do_connect_ex (user , (int ) user_len , pass_old , (int ) pass_old_len , pass_new , (int ) pass_new_len , dbname , (int ) dbname_len , NULL , OCI_DEFAULT , 0 , 0 );
0 commit comments