Skip to content

PHPC-539: Include read concern in Query debug output #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2016

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Feb 2, 2016

zval *zv;
#endif

php_phongo_read_concern_to_zval(&zv, intern->read_concern);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work in PHP 5.4-5.6 as Travis says:

/home/travis/build/mongodb/mongo-php-driver/src/MongoDB/Query.c: In function ‘php_phongo_query_get_debug_info’:

/home/travis/build/mongodb/mongo-php-driver/src/MongoDB/Query.c:238:3: error: passing argument 1 of ‘php_phongo_read_concern_to_zval’ from incompatible pointer type [-Werror]

./php_phongo.h:133:6: note: expected ‘struct zval *’ but argument is of type ‘struct zval **’

@jmikola jmikola force-pushed the phpc-539 branch 3 times, most recently from b34f4b5 to 22d05ee Compare February 5, 2016 21:30
zval read_concern;

php_phongo_read_concern_to_zval(&read_concern, intern->read_concern);
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", &read_concern);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ADD_ASSOC_ZVAL_EX copy the read_concern zval? If not, it's value is going to be out of scope when the function ends. I would at least run the tests covering this with valgrind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valgrind reported no issues. I poked into PHP 7's code for add_assoc_zval_ex() and it does appear to copy the zval argument. See: http://lxr.php.net/xref/PHP_7_0/Zend/zend_hash.c#552 and references to the pData argument therein. It's used with ZVAL_COPY_VALUE() when assigning the index.

@jmikola jmikola merged commit 20e601a into mongodb:master Feb 10, 2016
jmikola added a commit that referenced this pull request Feb 10, 2016
@jmikola jmikola deleted the phpc-539 branch February 10, 2016 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants