40
40
#define OCI_STMT_CALL 10
41
41
#endif
42
42
43
+ #define ERROR_ARG_POS (arg_num ) (getThis() ? (arg_num-1) : (arg_num))
44
+
43
45
/* {{{ Register a callback function for Oracle Transparent Application Failover (TAF) */
44
46
PHP_FUNCTION (oci_register_taf_callback )
45
47
{
@@ -109,8 +111,8 @@ PHP_FUNCTION(oci_define_by_name)
109
111
ZEND_PARSE_PARAMETERS_END ();
110
112
111
113
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 () ;
114
116
}
115
117
116
118
PHP_OCI_ZVAL_TO_STATEMENT (stmt , statement );
@@ -210,8 +212,8 @@ PHP_FUNCTION(oci_bind_array_by_name)
210
212
}
211
213
212
214
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 () ;
215
217
}
216
218
217
219
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)
257
259
RETURN_THROWS ();
258
260
}
259
261
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
+
260
267
if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
261
268
php_error_docref (NULL , E_WARNING , "Unable to find descriptor property" );
262
269
RETURN_FALSE ;
263
270
}
264
271
265
272
PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
266
273
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
-
272
274
if (php_oci_lob_write (descriptor , (ub4 ) offset , data , (ub4 ) data_len , & bytes_written )) {
273
275
RETURN_FALSE ;
274
276
}
@@ -284,7 +286,7 @@ PHP_FUNCTION(oci_lob_import)
284
286
char * filename ;
285
287
size_t filename_len ;
286
288
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 ) {
288
290
RETURN_THROWS ();
289
291
}
290
292
@@ -293,11 +295,6 @@ PHP_FUNCTION(oci_lob_import)
293
295
RETURN_FALSE ;
294
296
}
295
297
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
-
301
298
PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
302
299
303
300
if (php_oci_lob_import (descriptor , filename )) {
@@ -354,18 +351,18 @@ PHP_FUNCTION(oci_lob_read)
354
351
RETURN_THROWS ();
355
352
}
356
353
354
+ if (length <= 0 ) {
355
+ zend_argument_value_error (ERROR_ARG_POS (2 ), "must be greater than 0" );
356
+ RETURN_THROWS ();
357
+ }
358
+
357
359
if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
358
360
php_error_docref (NULL , E_WARNING , "Unable to find descriptor property" );
359
361
RETURN_FALSE ;
360
362
}
361
363
362
364
PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
363
365
364
- if (length <= 0 ) {
365
- php_error_docref (NULL , E_WARNING , "Length parameter must be greater than 0" );
366
- RETURN_FALSE ;
367
- }
368
-
369
366
if (php_oci_lob_read (descriptor , length , descriptor -> lob_current_position , & buffer , & buffer_len )) {
370
367
RETURN_FALSE ;
371
368
}
@@ -604,13 +601,13 @@ PHP_FUNCTION(oci_lob_truncate)
604
601
RETURN_THROWS ();
605
602
}
606
603
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 () ;
610
607
}
611
608
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 " );
614
611
RETURN_FALSE ;
615
612
}
616
613
@@ -640,15 +637,15 @@ PHP_FUNCTION(oci_lob_erase)
640
637
if (offset_is_null ) {
641
638
offset = -1 ;
642
639
} 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 () ;
645
642
}
646
643
647
644
if (length_is_null ) {
648
645
length = -1 ;
649
646
} 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 () ;
652
649
}
653
650
654
651
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)
756
753
RETURN_THROWS ();
757
754
}
758
755
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
+
759
763
if ((tmp_dest = zend_hash_str_find (Z_OBJPROP_P (z_descriptor_dest ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
760
764
php_error_docref (NULL , E_WARNING , "Unable to find descriptor property. The first argument should be valid descriptor object" );
761
765
RETURN_FALSE ;
@@ -769,13 +773,6 @@ PHP_FUNCTION(oci_lob_copy)
769
773
PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp_dest , descriptor_dest );
770
774
PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp_from , descriptor_from );
771
775
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
-
779
776
if (php_oci_lob_copy (descriptor_dest , descriptor_from , length )) {
780
777
RETURN_FALSE ;
781
778
}
@@ -831,34 +828,29 @@ PHP_FUNCTION(oci_lob_export)
831
828
php_stream * stream ;
832
829
ub4 lob_length ;
833
830
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 ) {
835
832
RETURN_THROWS ();
836
833
}
837
834
838
835
if (start_is_null ) {
839
836
start = -1 ;
840
837
} 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 () ;
843
840
}
844
841
845
842
if (length_is_null ) {
846
843
length = -1 ;
847
844
} 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 () ;
850
847
}
851
848
852
849
if ((tmp = zend_hash_str_find (Z_OBJPROP_P (z_descriptor ), "descriptor" , sizeof ("descriptor" )- 1 )) == NULL ) {
853
850
php_error_docref (NULL , E_WARNING , "Unable to find descriptor property" );
854
851
RETURN_FALSE ;
855
852
}
856
853
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
-
862
854
PHP_OCI_ZVAL_TO_DESCRIPTOR (tmp , descriptor );
863
855
864
856
if (php_oci_lob_get_length (descriptor , & lob_length )) {
@@ -1630,8 +1622,8 @@ PHP_FUNCTION(oci_set_prefetch)
1630
1622
PHP_OCI_ZVAL_TO_STATEMENT (z_statement , statement );
1631
1623
1632
1624
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 () ;
1635
1627
}
1636
1628
1637
1629
if (php_oci_statement_set_prefetch (statement , (ub4 )size )) {
@@ -1899,16 +1891,16 @@ PHP_FUNCTION(oci_password_change)
1899
1891
PHP_OCI_ZVAL_TO_CONNECTION (z_connection , connection );
1900
1892
1901
1893
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 () ;
1904
1896
}
1905
1897
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 () ;
1908
1900
}
1909
1901
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 () ;
1912
1904
}
1913
1905
1914
1906
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)
1918
1910
} 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 ) {
1919
1911
1920
1912
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 () ;
1923
1915
}
1924
1916
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 () ;
1927
1919
}
1928
1920
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 () ;
1931
1923
}
1932
1924
1933
1925
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