@@ -48,7 +48,7 @@ ZEND_EXTERN_MODULE_GLOBALS(mongo)
48
48
49
49
zend_class_entry * mongo_ce_Collection = NULL ;
50
50
51
- static int is_gle_op (zval * coll , zval * options , mongo_server_options * server_options TSRMLS_DC );
51
+ static int is_gle_op (zval * coll , zval * options , mongo_server_options * server_options , int silent TSRMLS_DC );
52
52
static void do_gle_op (mongo_con_manager * manager , mongo_connection * connection , zval * cursor_z , mongo_buffer * buf , zval * return_value TSRMLS_DC );
53
53
static zval * append_getlasterror (zval * coll , mongo_buffer * buf , zval * options , mongo_connection * connection TSRMLS_DC );
54
54
static char * to_index_string (zval * zkeys , int * key_len TSRMLS_DC );
@@ -378,11 +378,13 @@ static zval* append_getlasterror(zval *coll, mongo_buffer *buf, zval *options, m
378
378
php_error_docref (NULL TSRMLS_CC , E_DEPRECATED , "The 'MongoCursor::$timeout' static property is deprecated, please call MongoCursor->timeout() instead" );
379
379
}
380
380
381
- /* Get the default value for journalling */
382
- fsync = link -> servers -> options .default_fsync ;
383
- journal = link -> servers -> options .default_journal ;
384
-
385
381
/* Read the default_* properties from the link */
382
+ if (link -> servers -> options .default_fsync != -1 ) {
383
+ fsync = link -> servers -> options .default_fsync ;
384
+ }
385
+ if (link -> servers -> options .default_journal != -1 ) {
386
+ journal = link -> servers -> options .default_journal ;
387
+ }
386
388
if (link -> servers -> options .default_w != -1 ) {
387
389
w = link -> servers -> options .default_w ;
388
390
}
@@ -609,7 +611,7 @@ static int send_message(zval *this_ptr, mongo_connection *connection, mongo_buff
609
611
return 0 ;
610
612
}
611
613
612
- if (is_gle_op (this_ptr , options , & link -> servers -> options TSRMLS_CC )) {
614
+ if (is_gle_op (this_ptr , options , & link -> servers -> options , NOISY TSRMLS_CC )) {
613
615
zval * cursor = append_getlasterror (this_ptr , buf , options , connection TSRMLS_CC );
614
616
if (cursor ) {
615
617
do_gle_op (link -> manager , connection , cursor , buf , return_value TSRMLS_CC );
@@ -632,7 +634,7 @@ static int send_message(zval *this_ptr, mongo_connection *connection, mongo_buff
632
634
* on whether a write concern ("w" or "safe") or fsync/journal options are
633
635
* specified.
634
636
*/
635
- static int is_gle_op (zval * coll , zval * options , mongo_server_options * server_options TSRMLS_DC )
637
+ static int is_gle_op (zval * coll , zval * options , mongo_server_options * server_options , int silent TSRMLS_DC )
636
638
{
637
639
int gle_op = 0 , default_fsync , default_journal , coll_w = 0 ;
638
640
zval * z_coll_w ;
@@ -674,10 +676,14 @@ static int is_gle_op(zval *coll, zval *options, mongo_server_options *server_opt
674
676
}
675
677
break ;
676
678
default :
677
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "The value of the 'w' option either needs to be a integer or string" );
679
+ if (silent == NOISY ) {
680
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "The value of the 'w' option either needs to be a integer or string" );
681
+ }
678
682
}
679
683
} else if (zend_hash_find (HASH_P (options ), "safe" , strlen ("safe" ) + 1 , (void * * ) & gle_pp ) == SUCCESS ) {
680
- php_error_docref (NULL TSRMLS_CC , E_DEPRECATED , "The 'safe' option is deprecated, please use 'w' instead" );
684
+ if (silent == NOISY ) {
685
+ php_error_docref (NULL TSRMLS_CC , E_DEPRECATED , "The 'safe' option is deprecated, please use 'w' instead" );
686
+ }
681
687
682
688
switch (Z_TYPE_PP (gle_pp )) {
683
689
case IS_STRING :
@@ -691,7 +697,9 @@ static int is_gle_op(zval *coll, zval *options, mongo_server_options *server_opt
691
697
}
692
698
break ;
693
699
default :
694
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "The value of the 'safe' option either needs to be a boolean or a string" );
700
+ if (silent == NOISY ) {
701
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "The value of the 'safe' option either needs to be a boolean or a string" );
702
+ }
695
703
}
696
704
} else if (coll_w >= 1 ) {
697
705
gle_op = 1 ;
@@ -722,7 +730,9 @@ static int is_gle_op(zval *coll, zval *options, mongo_server_options *server_opt
722
730
gle_op = (coll_w >= 1 || default_fsync == 1 || default_journal == 1 );
723
731
}
724
732
725
- mongo_manager_log (MonGlo (manager ), MLOG_IO , MLOG_FINE , "is_gle_op: %s" , gle_op ? "yes" : "no" );
733
+ if (silent == NOISY ) {
734
+ mongo_manager_log (MonGlo (manager ), MLOG_IO , MLOG_FINE , "is_gle_op: %s" , gle_op ? "yes" : "no" );
735
+ }
726
736
return gle_op ;
727
737
}
728
738
@@ -1135,7 +1145,7 @@ static void php_mongo_collection_insert(zval *z_collection, zval *document, zval
1135
1145
RETURN_FALSE ;
1136
1146
}
1137
1147
1138
- is_acknowledged = is_gle_op (z_collection , z_write_options , & link -> servers -> options TSRMLS_CC );
1148
+ is_acknowledged = is_gle_op (z_collection , z_write_options , & link -> servers -> options , QUIET TSRMLS_CC );
1139
1149
supports_command = php_mongo_api_connection_supports_feature (connection , PHP_MONGO_API_WRITE_API );
1140
1150
supports_opcode = php_mongo_api_connection_supports_feature (connection , PHP_MONGO_API_RELEASE_2_4_AND_BEFORE );
1141
1151
@@ -1518,7 +1528,7 @@ static void php_mongocollection_update(zval *this_ptr, mongo_collection *c, zval
1518
1528
RETURN_FALSE ;
1519
1529
}
1520
1530
1521
- is_acknowledged = is_gle_op (this_ptr , z_write_options , & link -> servers -> options TSRMLS_CC );
1531
+ is_acknowledged = is_gle_op (this_ptr , z_write_options , & link -> servers -> options , QUIET TSRMLS_CC );
1522
1532
supports_command = php_mongo_api_connection_supports_feature (connection , PHP_MONGO_API_WRITE_API );
1523
1533
supports_opcode = php_mongo_api_connection_supports_feature (connection , PHP_MONGO_API_RELEASE_2_4_AND_BEFORE );
1524
1534
@@ -1637,7 +1647,7 @@ static void php_mongocollection_remove(zval *this_ptr, mongo_collection *c, zval
1637
1647
RETURN_FALSE ;
1638
1648
}
1639
1649
1640
- is_acknowledged = is_gle_op (this_ptr , z_write_options , & link -> servers -> options TSRMLS_CC );
1650
+ is_acknowledged = is_gle_op (this_ptr , z_write_options , & link -> servers -> options , QUIET TSRMLS_CC );
1641
1651
supports_command = php_mongo_api_connection_supports_feature (connection , PHP_MONGO_API_WRITE_API );
1642
1652
supports_opcode = php_mongo_api_connection_supports_feature (connection , PHP_MONGO_API_RELEASE_2_4_AND_BEFORE );
1643
1653
0 commit comments