diff --git a/docs/crud.md b/docs/crud.md index 12eb69d91..7631d7f1b 100644 --- a/docs/crud.md +++ b/docs/crud.md @@ -13,11 +13,8 @@ $w = MongoDB\Driver\WriteConcern::MAJORITY; * I have an application to run! */ $wtimeout = 1000; -/* No need to journal or fsync (are infact discouraged in general) */ -$journal = $fsync = false; - /* Construct the WriteConcern object from our options */ -$wc = new MongoDB\Driver\WriteConcern($w, $wtimeout, $journal, $fsync); +$wc = new MongoDB\Driver\WriteConcern($w, $wtimeout); /* We prefer to read from the secondary, but are OK to read from the primary diff --git a/php_phongo.c b/php_phongo.c index b2b9ebc00..3b7d194a7 100644 --- a/php_phongo.c +++ b/php_phongo.c @@ -1418,7 +1418,7 @@ void php_phongo_write_concern_to_zval(zval *retval, const mongoc_write_concern_t const char *wtag = mongoc_write_concern_get_wtag(write_concern); const int32_t w = mongoc_write_concern_get_w(write_concern); - array_init_size(retval, 5); + array_init_size(retval, 4); if (wtag) { add_assoc_string_ex(retval, ZEND_STRS("w"), (char *)wtag, 1); @@ -1432,11 +1432,7 @@ void php_phongo_write_concern_to_zval(zval *retval, const mongoc_write_concern_t add_assoc_bool_ex(retval, ZEND_STRS("wmajority"), mongoc_write_concern_get_wmajority(write_concern)); add_assoc_long_ex(retval, ZEND_STRS("wtimeout"), mongoc_write_concern_get_wtimeout(write_concern)); - if (write_concern->fsync_ != MONGOC_WRITE_CONCERN_FSYNC_DEFAULT) { - add_assoc_bool_ex(retval, ZEND_STRS("fsync"), mongoc_write_concern_get_fsync(write_concern)); - } else { - add_assoc_null_ex(retval, ZEND_STRS("fsync")); - } + if (write_concern->journal != MONGOC_WRITE_CONCERN_JOURNAL_DEFAULT) { add_assoc_bool_ex(retval, ZEND_STRS("journal"), mongoc_write_concern_get_journal(write_concern)); } else { diff --git a/src/MongoDB/WriteConcern.c b/src/MongoDB/WriteConcern.c index 329f008a6..4e2c360c5 100644 --- a/src/MongoDB/WriteConcern.c +++ b/src/MongoDB/WriteConcern.c @@ -47,18 +47,14 @@ PHONGO_API zend_class_entry *php_phongo_writeconcern_ce; zend_object_handlers php_phongo_handler_writeconcern; -/* {{{ proto MongoDB\Driver\WriteConcern WriteConcern::__construct(integer|string $w[, integer $wtimeout[, boolean $journal[, boolean $fsync]]]) +/* {{{ proto MongoDB\Driver\WriteConcern WriteConcern::__construct(integer|string $w[, integer $wtimeout[, boolean $journal]]) Constructs a new WriteConcern */ PHP_METHOD(WriteConcern, __construct) { php_phongo_writeconcern_t *intern; zend_error_handling error_handling; - zval *w; + zval *w, *journal; long wtimeout = 0; - zend_bool journal = 0; - zend_bool journal_is_null = 0; - zend_bool fsync = 0; - zend_bool fsync_is_null = 0; (void)return_value; (void)return_value_ptr; (void)return_value_used; @@ -66,7 +62,7 @@ PHP_METHOD(WriteConcern, __construct) zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC); intern = (php_phongo_writeconcern_t *)zend_object_store_get_object(getThis() TSRMLS_CC); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|lb!b!", &w, &wtimeout, &journal, &journal_is_null, &fsync, &fsync_is_null) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|lz", &w, &wtimeout, &journal) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } @@ -93,14 +89,9 @@ PHP_METHOD(WriteConcern, __construct) } switch(ZEND_NUM_ARGS()) { - case 4: - if (!fsync_is_null) { - mongoc_write_concern_set_fsync(intern->write_concern, fsync); - } - /* fallthrough */ case 3: - if (!journal_is_null) { - mongoc_write_concern_set_journal(intern->write_concern, journal); + if (Z_TYPE_P(journal) != IS_NULL) { + mongoc_write_concern_set_journal(intern->write_concern, Z_BVAL_P(journal)); } /* fallthrough */ case 2: @@ -184,37 +175,15 @@ PHP_METHOD(WriteConcern, getJournal) } /* }}} */ -/* {{{ proto null|boolean WriteConcern::getFsync() - Returns the WriteConcern "fsync" option */ -PHP_METHOD(WriteConcern, getFsync) -{ - php_phongo_writeconcern_t *intern; - (void)return_value_ptr; (void)return_value_used; - - intern = (php_phongo_writeconcern_t *)zend_object_store_get_object(getThis() TSRMLS_CC); - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - if (intern->write_concern->fsync_ != MONGOC_WRITE_CONCERN_FSYNC_DEFAULT) { - RETURN_BOOL(mongoc_write_concern_get_fsync(intern->write_concern)); - } - - RETURN_NULL(); -} -/* }}} */ - /** * Value object for write concern used in issuing write operations. */ /* {{{ MongoDB\Driver\WriteConcern */ ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___construct, 0, 0, 1) - ZEND_ARG_INFO(0, wstring) + ZEND_ARG_INFO(0, w) ZEND_ARG_INFO(0, wtimeout) ZEND_ARG_INFO(0, journal) - ZEND_ARG_INFO(0, fsync) ZEND_END_ARG_INFO(); ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_getW, 0, 0, 0) @@ -226,15 +195,11 @@ ZEND_END_ARG_INFO(); ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_getJournal, 0, 0, 0) ZEND_END_ARG_INFO(); -ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_getFsync, 0, 0, 0) -ZEND_END_ARG_INFO(); - static zend_function_entry php_phongo_writeconcern_me[] = { PHP_ME(WriteConcern, __construct, ai_WriteConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(WriteConcern, getW, ai_WriteConcern_getW, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(WriteConcern, getWtimeout, ai_WriteConcern_getWtimeout, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(WriteConcern, getJournal, ai_WriteConcern_getJournal, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) - PHP_ME(WriteConcern, getFsync, ai_WriteConcern_getFsync, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_FE_END }; diff --git a/tests/bulk/write-0002.phpt b/tests/bulk/write-0002.phpt index 8bf708b57..e70493fdf 100644 --- a/tests/bulk/write-0002.phpt +++ b/tests/bulk/write-0002.phpt @@ -61,15 +61,13 @@ object(MongoDB\Driver\BulkWrite)#%d (%d) { ["server_id"]=> int(1) ["write_concern"]=> - array(5) { + array(%d) { ["w"]=> int(1) ["wmajority"]=> bool(false) ["wtimeout"]=> int(1000) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/manager/manager-getwriteconcern-001.phpt b/tests/manager/manager-getwriteconcern-001.phpt index 0caea2879..1b1ead8aa 100644 --- a/tests/manager/manager-getwriteconcern-001.phpt +++ b/tests/manager/manager-getwriteconcern-001.phpt @@ -42,8 +42,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -54,8 +52,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -66,8 +62,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(true) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -78,8 +72,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> bool(true) } @@ -90,8 +82,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(true) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> bool(true) } @@ -102,8 +92,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> bool(false) } @@ -114,8 +102,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -126,8 +112,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -138,8 +122,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(1000) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -150,8 +132,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(true) ["wtimeout"]=> int(1000) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -162,8 +142,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(1000) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/replicaset/writeresult-getserver-002.phpt b/tests/replicaset/writeresult-getserver-002.phpt index a13ffa940..a94fea942 100644 --- a/tests/replicaset/writeresult-getserver-002.phpt +++ b/tests/replicaset/writeresult-getserver-002.phpt @@ -87,8 +87,6 @@ object(MongoDB\Driver\WriteResult)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/server/server-executeBulkWrite-001.phpt b/tests/server/server-executeBulkWrite-001.phpt index 8b302ce3b..5ca856eee 100644 --- a/tests/server/server-executeBulkWrite-001.phpt +++ b/tests/server/server-executeBulkWrite-001.phpt @@ -77,8 +77,6 @@ object(MongoDB\Driver\WriteResult)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/standalone/writeresult-isacknowledged-001.phpt b/tests/standalone/writeresult-isacknowledged-001.phpt index f2fbcd27f..a0a65acb8 100644 --- a/tests/standalone/writeresult-isacknowledged-001.phpt +++ b/tests/standalone/writeresult-isacknowledged-001.phpt @@ -46,8 +46,6 @@ object(MongoDB\Driver\WriteResult)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/standalone/writeresult-isacknowledged-002.phpt b/tests/standalone/writeresult-isacknowledged-002.phpt index 9bb8c0f3a..c296ad084 100644 --- a/tests/standalone/writeresult-isacknowledged-002.phpt +++ b/tests/standalone/writeresult-isacknowledged-002.phpt @@ -41,15 +41,13 @@ object(MongoDB\Driver\WriteResult)#%d (%d) { array(0) { } ["writeConcern"]=> - array(5) { + array(%d) { ["w"]=> int(0) ["wmajority"]=> bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/standalone/writeresult-isacknowledged-003.phpt b/tests/standalone/writeresult-isacknowledged-003.phpt index b059fe5cc..74c29aa2c 100644 --- a/tests/standalone/writeresult-isacknowledged-003.phpt +++ b/tests/standalone/writeresult-isacknowledged-003.phpt @@ -39,15 +39,13 @@ object(MongoDB\Driver\WriteResult)#%d (%d) { array(0) { } ["writeConcern"]=> - array(5) { + array(%d) { ["w"]=> int(0) ["wmajority"]=> bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } diff --git a/tests/writeConcern/writeconcern-ctor-001.phpt b/tests/writeConcern/writeconcern-ctor-001.phpt index 9280021dc..8c25e22e8 100644 --- a/tests/writeConcern/writeconcern-ctor-001.phpt +++ b/tests/writeConcern/writeconcern-ctor-001.phpt @@ -17,16 +17,7 @@ var_dump(new MongoDB\Driver\WriteConcern("string", 3000)); var_dump(new MongoDB\Driver\WriteConcern("string", 4000, true)); var_dump(new MongoDB\Driver\WriteConcern("string", 5000, false)); - -var_dump(new MongoDB\Driver\WriteConcern("string", 6000, false, false)); -var_dump(new MongoDB\Driver\WriteConcern("string", 7000, true, true)); - -var_dump(new MongoDB\Driver\WriteConcern("string", 8000, true, false)); -var_dump(new MongoDB\Driver\WriteConcern("string", 9000, false, true)); - -var_dump(new MongoDB\Driver\WriteConcern("string", 10000, null)); -var_dump(new MongoDB\Driver\WriteConcern("string", 11000, null, true)); -var_dump(new MongoDB\Driver\WriteConcern("string", 12000, true, null)); +var_dump(new MongoDB\Driver\WriteConcern("string", 6000, null)); ?> ===DONE=== @@ -39,8 +30,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(true) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -51,8 +40,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(true) ["wtimeout"]=> int(1000) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -63,8 +50,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -75,8 +60,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(2000) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -87,8 +70,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -99,8 +80,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(3000) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -111,8 +90,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(4000) - ["fsync"]=> - NULL ["journal"]=> bool(true) } @@ -123,8 +100,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(5000) - ["fsync"]=> - NULL ["journal"]=> bool(false) } @@ -135,81 +110,7 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(6000) - ["fsync"]=> - bool(false) - ["journal"]=> - bool(false) -} -object(MongoDB\Driver\WriteConcern)#%d (%d) { - ["w"]=> - string(6) "string" - ["wmajority"]=> - bool(false) - ["wtimeout"]=> - int(7000) - ["fsync"]=> - bool(true) - ["journal"]=> - bool(true) -} -object(MongoDB\Driver\WriteConcern)#%d (%d) { - ["w"]=> - string(6) "string" - ["wmajority"]=> - bool(false) - ["wtimeout"]=> - int(8000) - ["fsync"]=> - bool(false) - ["journal"]=> - bool(true) -} -object(MongoDB\Driver\WriteConcern)#%d (%d) { - ["w"]=> - string(6) "string" - ["wmajority"]=> - bool(false) - ["wtimeout"]=> - int(9000) - ["fsync"]=> - bool(true) - ["journal"]=> - bool(false) -} -object(MongoDB\Driver\WriteConcern)#%d (%d) { - ["w"]=> - string(6) "string" - ["wmajority"]=> - bool(false) - ["wtimeout"]=> - int(10000) - ["fsync"]=> - NULL - ["journal"]=> - NULL -} -object(MongoDB\Driver\WriteConcern)#%d (%d) { - ["w"]=> - string(6) "string" - ["wmajority"]=> - bool(false) - ["wtimeout"]=> - int(11000) - ["fsync"]=> - bool(true) ["journal"]=> NULL } -object(MongoDB\Driver\WriteConcern)#%d (%d) { - ["w"]=> - string(6) "string" - ["wmajority"]=> - bool(false) - ["wtimeout"]=> - int(12000) - ["fsync"]=> - NULL - ["journal"]=> - bool(true) -} ===DONE=== diff --git a/tests/writeConcern/writeconcern-ctor_error-001.phpt b/tests/writeConcern/writeconcern-ctor_error-001.phpt index 60d5aa647..d959ac7f1 100644 --- a/tests/writeConcern/writeconcern-ctor_error-001.phpt +++ b/tests/writeConcern/writeconcern-ctor_error-001.phpt @@ -8,7 +8,7 @@ MongoDB\Driver\WriteConcern construction (invalid arguments) require_once __DIR__ . "/../utils/basic.inc"; echo throws(function() { - new MongoDB\Driver\WriteConcern("string", 10000, false, true, 1); + new MongoDB\Driver\WriteConcern("string", 10000, false, 1); }, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n"; ?> @@ -16,5 +16,5 @@ echo throws(function() { --EXPECT-- OK: Got MongoDB\Driver\Exception\InvalidArgumentException -MongoDB\Driver\WriteConcern::__construct() expects at most 4 parameters, 5 given +MongoDB\Driver\WriteConcern::__construct() expects at most 3 parameters, 4 given ===DONE=== diff --git a/tests/writeConcern/writeconcern-debug-001.phpt b/tests/writeConcern/writeconcern-debug-001.phpt index e16999baa..598eedc11 100644 --- a/tests/writeConcern/writeconcern-debug-001.phpt +++ b/tests/writeConcern/writeconcern-debug-001.phpt @@ -10,7 +10,7 @@ require_once __DIR__ . "/../utils/basic.inc"; * Although "w" will be omitted from the write concern sent to the server, we * should still yield other fields in the debug output, which may be sent. */ -var_dump(new MongoDB\Driver\WriteConcern(-2, 1000, true, true)); +var_dump(new MongoDB\Driver\WriteConcern(-2, 1000, true)); ?> ===DONE=== @@ -23,8 +23,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(1000) - ["fsync"]=> - bool(true) ["journal"]=> bool(true) } diff --git a/tests/writeConcern/writeconcern-debug-002.phpt b/tests/writeConcern/writeconcern-debug-002.phpt index c29bce42f..f33f0971f 100644 --- a/tests/writeConcern/writeconcern-debug-002.phpt +++ b/tests/writeConcern/writeconcern-debug-002.phpt @@ -7,8 +7,8 @@ MongoDB\Driver\WriteConcern debug output require_once __DIR__ . "/../utils/basic.inc"; var_dump(new MongoDB\Driver\WriteConcern(1)); -var_dump(new MongoDB\Driver\WriteConcern("tag", 1000, false, false)); -var_dump(new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 500, true, true)); +var_dump(new MongoDB\Driver\WriteConcern("tag", 1000, false)); +var_dump(new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 500, true)); ?> ===DONE=== @@ -21,8 +21,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(0) - ["fsync"]=> - NULL ["journal"]=> NULL } @@ -33,8 +31,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(false) ["wtimeout"]=> int(1000) - ["fsync"]=> - bool(false) ["journal"]=> bool(false) } @@ -45,8 +41,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) { bool(true) ["wtimeout"]=> int(500) - ["fsync"]=> - bool(true) ["journal"]=> bool(true) } diff --git a/tests/writeConcern/writeconcern-getfsync-001.phpt b/tests/writeConcern/writeconcern-getfsync-001.phpt deleted file mode 100644 index 0e5011bd1..000000000 --- a/tests/writeConcern/writeconcern-getfsync-001.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -MongoDB\Driver\WriteConcern::getFsync() ---SKIPIF-- - ---FILE-- -getFsync()); -} - -// Test with default value -$wc = new MongoDB\Driver\WriteConcern(1, 0, true); -var_dump($wc->getFsync()); - -?> -===DONE=== - ---EXPECT-- -bool(true) -bool(false) -bool(true) -bool(false) -NULL -NULL -===DONE===