@@ -53,19 +53,18 @@ PHP_METHOD(WriteConcern, __construct)
53
53
{
54
54
php_phongo_writeconcern_t * intern ;
55
55
zend_error_handling error_handling ;
56
- char * wstring ;
57
- int wstring_len ;
56
+ zval * w ;
58
57
long wtimeout = 0 ;
59
58
zend_bool journal = 0 ;
60
59
zend_bool fsync = 0 ;
61
- long w ;
60
+
62
61
(void )return_value ; (void )return_value_ptr ; (void )return_value_used ;
63
62
64
63
65
64
zend_replace_error_handling (EH_THROW , phongo_exception_from_phongo_domain (PHONGO_ERROR_INVALID_ARGUMENT ), & error_handling TSRMLS_CC );
66
65
intern = (php_phongo_writeconcern_t * )zend_object_store_get_object (getThis () TSRMLS_CC );
67
66
68
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s |lbb" , & wstring , & wstring_len , & wtimeout , & journal , & fsync ) == FAILURE ) {
67
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "z |lbb" , & w , & wtimeout , & journal , & fsync ) == FAILURE ) {
69
68
zend_restore_error_handling (& error_handling TSRMLS_CC );
70
69
return ;
71
70
}
@@ -74,13 +73,13 @@ PHP_METHOD(WriteConcern, __construct)
74
73
75
74
intern -> write_concern = mongoc_write_concern_new ();
76
75
77
- if (IS_LONG == is_numeric_string ( wstring , wstring_len , & w , NULL , 0 ) ) {
78
- mongoc_write_concern_set_w (intern -> write_concern , w );
79
- } else {
80
- if (strcmp (wstring , PHONGO_WRITE_CONCERN_W_MAJORITY ) == 0 ) {
76
+ if (Z_TYPE_P ( w ) == IS_LONG ) {
77
+ mongoc_write_concern_set_w (intern -> write_concern , Z_LVAL_P ( w ) );
78
+ } else if ( Z_TYPE_P ( w ) == IS_STRING ) {
79
+ if (strcmp (Z_STRVAL_P ( w ) , PHONGO_WRITE_CONCERN_W_MAJORITY ) == 0 ) {
81
80
mongoc_write_concern_set_w (intern -> write_concern , MONGOC_WRITE_CONCERN_W_MAJORITY );
82
81
} else {
83
- mongoc_write_concern_set_wtag (intern -> write_concern , wstring );
82
+ mongoc_write_concern_set_wtag (intern -> write_concern , Z_STRVAL_P ( w ) );
84
83
}
85
84
}
86
85
0 commit comments