Skip to content

Commit bd82482

Browse files
committed
Merge pull request #115
2 parents 39d8974 + adbe8bb commit bd82482

15 files changed

+18
-237
lines changed

docs/crud.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ $w = MongoDB\Driver\WriteConcern::MAJORITY;
1313
* I have an application to run! */
1414
$wtimeout = 1000;
1515

16-
/* No need to journal or fsync (are infact discouraged in general) */
17-
$journal = $fsync = false;
18-
1916
/* Construct the WriteConcern object from our options */
20-
$wc = new MongoDB\Driver\WriteConcern($w, $wtimeout, $journal, $fsync);
17+
$wc = new MongoDB\Driver\WriteConcern($w, $wtimeout);
2118

2219

2320
/* We prefer to read from the secondary, but are OK to read from the primary

php_phongo.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ void php_phongo_write_concern_to_zval(zval *retval, const mongoc_write_concern_t
14181418
const char *wtag = mongoc_write_concern_get_wtag(write_concern);
14191419
const int32_t w = mongoc_write_concern_get_w(write_concern);
14201420

1421-
array_init_size(retval, 5);
1421+
array_init_size(retval, 4);
14221422

14231423
if (wtag) {
14241424
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
14321432

14331433
add_assoc_bool_ex(retval, ZEND_STRS("wmajority"), mongoc_write_concern_get_wmajority(write_concern));
14341434
add_assoc_long_ex(retval, ZEND_STRS("wtimeout"), mongoc_write_concern_get_wtimeout(write_concern));
1435-
if (write_concern->fsync_ != MONGOC_WRITE_CONCERN_FSYNC_DEFAULT) {
1436-
add_assoc_bool_ex(retval, ZEND_STRS("fsync"), mongoc_write_concern_get_fsync(write_concern));
1437-
} else {
1438-
add_assoc_null_ex(retval, ZEND_STRS("fsync"));
1439-
}
1435+
14401436
if (write_concern->journal != MONGOC_WRITE_CONCERN_JOURNAL_DEFAULT) {
14411437
add_assoc_bool_ex(retval, ZEND_STRS("journal"), mongoc_write_concern_get_journal(write_concern));
14421438
} else {

src/MongoDB/WriteConcern.c

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,22 @@ PHONGO_API zend_class_entry *php_phongo_writeconcern_ce;
4747

4848
zend_object_handlers php_phongo_handler_writeconcern;
4949

50-
/* {{{ proto MongoDB\Driver\WriteConcern WriteConcern::__construct(integer|string $w[, integer $wtimeout[, boolean $journal[, boolean $fsync]]])
50+
/* {{{ proto MongoDB\Driver\WriteConcern WriteConcern::__construct(integer|string $w[, integer $wtimeout[, boolean $journal]])
5151
Constructs a new WriteConcern */
5252
PHP_METHOD(WriteConcern, __construct)
5353
{
5454
php_phongo_writeconcern_t *intern;
5555
zend_error_handling error_handling;
56-
zval *w;
56+
zval *w, *journal;
5757
long wtimeout = 0;
58-
zend_bool journal = 0;
59-
zend_bool journal_is_null = 0;
60-
zend_bool fsync = 0;
61-
zend_bool fsync_is_null = 0;
6258

6359
(void)return_value; (void)return_value_ptr; (void)return_value_used;
6460

6561

6662
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
6763
intern = (php_phongo_writeconcern_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
6864

69-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|lb!b!", &w, &wtimeout, &journal, &journal_is_null, &fsync, &fsync_is_null) == FAILURE) {
65+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|lz", &w, &wtimeout, &journal) == FAILURE) {
7066
zend_restore_error_handling(&error_handling TSRMLS_CC);
7167
return;
7268
}
@@ -93,14 +89,9 @@ PHP_METHOD(WriteConcern, __construct)
9389
}
9490

9591
switch(ZEND_NUM_ARGS()) {
96-
case 4:
97-
if (!fsync_is_null) {
98-
mongoc_write_concern_set_fsync(intern->write_concern, fsync);
99-
}
100-
/* fallthrough */
10192
case 3:
102-
if (!journal_is_null) {
103-
mongoc_write_concern_set_journal(intern->write_concern, journal);
93+
if (Z_TYPE_P(journal) != IS_NULL) {
94+
mongoc_write_concern_set_journal(intern->write_concern, Z_BVAL_P(journal));
10495
}
10596
/* fallthrough */
10697
case 2:
@@ -184,37 +175,15 @@ PHP_METHOD(WriteConcern, getJournal)
184175
}
185176
/* }}} */
186177

187-
/* {{{ proto null|boolean WriteConcern::getFsync()
188-
Returns the WriteConcern "fsync" option */
189-
PHP_METHOD(WriteConcern, getFsync)
190-
{
191-
php_phongo_writeconcern_t *intern;
192-
(void)return_value_ptr; (void)return_value_used;
193-
194-
intern = (php_phongo_writeconcern_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
195-
196-
if (zend_parse_parameters_none() == FAILURE) {
197-
return;
198-
}
199-
200-
if (intern->write_concern->fsync_ != MONGOC_WRITE_CONCERN_FSYNC_DEFAULT) {
201-
RETURN_BOOL(mongoc_write_concern_get_fsync(intern->write_concern));
202-
}
203-
204-
RETURN_NULL();
205-
}
206-
/* }}} */
207-
208178
/**
209179
* Value object for write concern used in issuing write operations.
210180
*/
211181
/* {{{ MongoDB\Driver\WriteConcern */
212182

213183
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___construct, 0, 0, 1)
214-
ZEND_ARG_INFO(0, wstring)
184+
ZEND_ARG_INFO(0, w)
215185
ZEND_ARG_INFO(0, wtimeout)
216186
ZEND_ARG_INFO(0, journal)
217-
ZEND_ARG_INFO(0, fsync)
218187
ZEND_END_ARG_INFO();
219188

220189
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_getW, 0, 0, 0)
@@ -226,15 +195,11 @@ ZEND_END_ARG_INFO();
226195
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_getJournal, 0, 0, 0)
227196
ZEND_END_ARG_INFO();
228197

229-
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_getFsync, 0, 0, 0)
230-
ZEND_END_ARG_INFO();
231-
232198
static zend_function_entry php_phongo_writeconcern_me[] = {
233199
PHP_ME(WriteConcern, __construct, ai_WriteConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
234200
PHP_ME(WriteConcern, getW, ai_WriteConcern_getW, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
235201
PHP_ME(WriteConcern, getWtimeout, ai_WriteConcern_getWtimeout, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
236202
PHP_ME(WriteConcern, getJournal, ai_WriteConcern_getJournal, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
237-
PHP_ME(WriteConcern, getFsync, ai_WriteConcern_getFsync, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
238203
PHP_FE_END
239204
};
240205

tests/bulk/write-0002.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ object(MongoDB\Driver\BulkWrite)#%d (%d) {
6161
["server_id"]=>
6262
int(1)
6363
["write_concern"]=>
64-
array(5) {
64+
array(%d) {
6565
["w"]=>
6666
int(1)
6767
["wmajority"]=>
6868
bool(false)
6969
["wtimeout"]=>
7070
int(1000)
71-
["fsync"]=>
72-
NULL
7371
["journal"]=>
7472
NULL
7573
}

tests/manager/manager-getwriteconcern-001.phpt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
4242
bool(false)
4343
["wtimeout"]=>
4444
int(0)
45-
["fsync"]=>
46-
NULL
4745
["journal"]=>
4846
NULL
4947
}
@@ -54,8 +52,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
5452
bool(false)
5553
["wtimeout"]=>
5654
int(0)
57-
["fsync"]=>
58-
NULL
5955
["journal"]=>
6056
NULL
6157
}
@@ -66,8 +62,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
6662
bool(true)
6763
["wtimeout"]=>
6864
int(0)
69-
["fsync"]=>
70-
NULL
7165
["journal"]=>
7266
NULL
7367
}
@@ -78,8 +72,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
7872
bool(false)
7973
["wtimeout"]=>
8074
int(0)
81-
["fsync"]=>
82-
NULL
8375
["journal"]=>
8476
bool(true)
8577
}
@@ -90,8 +82,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
9082
bool(true)
9183
["wtimeout"]=>
9284
int(0)
93-
["fsync"]=>
94-
NULL
9585
["journal"]=>
9686
bool(true)
9787
}
@@ -102,8 +92,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
10292
bool(false)
10393
["wtimeout"]=>
10494
int(0)
105-
["fsync"]=>
106-
NULL
10795
["journal"]=>
10896
bool(false)
10997
}
@@ -114,8 +102,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
114102
bool(false)
115103
["wtimeout"]=>
116104
int(0)
117-
["fsync"]=>
118-
NULL
119105
["journal"]=>
120106
NULL
121107
}
@@ -126,8 +112,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
126112
bool(false)
127113
["wtimeout"]=>
128114
int(0)
129-
["fsync"]=>
130-
NULL
131115
["journal"]=>
132116
NULL
133117
}
@@ -138,8 +122,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
138122
bool(false)
139123
["wtimeout"]=>
140124
int(1000)
141-
["fsync"]=>
142-
NULL
143125
["journal"]=>
144126
NULL
145127
}
@@ -150,8 +132,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
150132
bool(true)
151133
["wtimeout"]=>
152134
int(1000)
153-
["fsync"]=>
154-
NULL
155135
["journal"]=>
156136
NULL
157137
}
@@ -162,8 +142,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
162142
bool(false)
163143
["wtimeout"]=>
164144
int(1000)
165-
["fsync"]=>
166-
NULL
167145
["journal"]=>
168146
NULL
169147
}

tests/replicaset/writeresult-getserver-002.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ object(MongoDB\Driver\WriteResult)#%d (%d) {
8787
bool(false)
8888
["wtimeout"]=>
8989
int(0)
90-
["fsync"]=>
91-
NULL
9290
["journal"]=>
9391
NULL
9492
}

tests/server/server-executeBulkWrite-001.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ object(MongoDB\Driver\WriteResult)#%d (%d) {
7777
bool(false)
7878
["wtimeout"]=>
7979
int(0)
80-
["fsync"]=>
81-
NULL
8280
["journal"]=>
8381
NULL
8482
}

tests/standalone/writeresult-isacknowledged-001.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ object(MongoDB\Driver\WriteResult)#%d (%d) {
4646
bool(false)
4747
["wtimeout"]=>
4848
int(0)
49-
["fsync"]=>
50-
NULL
5149
["journal"]=>
5250
NULL
5351
}

tests/standalone/writeresult-isacknowledged-002.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ object(MongoDB\Driver\WriteResult)#%d (%d) {
4141
array(0) {
4242
}
4343
["writeConcern"]=>
44-
array(5) {
44+
array(%d) {
4545
["w"]=>
4646
int(0)
4747
["wmajority"]=>
4848
bool(false)
4949
["wtimeout"]=>
5050
int(0)
51-
["fsync"]=>
52-
NULL
5351
["journal"]=>
5452
NULL
5553
}

tests/standalone/writeresult-isacknowledged-003.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ object(MongoDB\Driver\WriteResult)#%d (%d) {
3939
array(0) {
4040
}
4141
["writeConcern"]=>
42-
array(5) {
42+
array(%d) {
4343
["w"]=>
4444
int(0)
4545
["wmajority"]=>
4646
bool(false)
4747
["wtimeout"]=>
4848
int(0)
49-
["fsync"]=>
50-
NULL
5149
["journal"]=>
5250
NULL
5351
}

0 commit comments

Comments
 (0)