-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-314: Implement type map syntax for documents within field paths #793
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
derickr
merged 12 commits into
mongodb:master
from
derickr:PHPC-314-typemap-for-fieldpaths
Apr 18, 2018
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f5e4976
PHPC-314: Read fieldPaths elements and check for correct map types
derickr d4d1fa3
PHPC-314: Record whether we're dealing with a document or an array fo…
derickr bdda892
PHPC-314: Parse fieldPaths element of the typemap into a tree
derickr eddcd4b
PHPC-1154: Implement wild card syntax for typemap field paths
derickr e7e9fe7
PHPC-1154: Fix memory leak with typemaps and MongoDB\BSON\toPHP
derickr f5965ce
s/allocated/allocated_size
derickr dac1d78
Use correct size in reallocs
derickr 6da5d4b
Rename free_elements to owns_elements, as that is more descriptive
derickr bb31cd4
Hint to the compiler that map_element_matches_field_path() should be …
derickr 2cd3e4f
Abandon strtok_r() in favour of a hand rolled algorithm
derickr b42165e
Tweaks to test cases
derickr da8853a
Move test case that doesn't touch server to BSON\toPHP()
derickr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,9 +365,10 @@ static void php_phongo_bson_append(bson_t* bson, php_phongo_field_path* field_pa | |
} | ||
|
||
bson_append_array_begin(bson, key, key_len, &child); | ||
field_path->current_level++; | ||
php_phongo_field_path_write_type_at_current_level(field_path, PHONGO_FIELD_PATH_ITEM_ARRAY); | ||
field_path->size++; | ||
php_phongo_zval_to_bson_internal(entry, field_path, flags, &child, NULL TSRMLS_CC); | ||
field_path->current_level--; | ||
field_path->size--; | ||
bson_append_array_end(bson, &child); | ||
|
||
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) { | ||
|
@@ -391,9 +392,10 @@ static void php_phongo_bson_append(bson_t* bson, php_phongo_field_path* field_pa | |
ZEND_HASH_INC_APPLY_COUNT(tmp_ht); | ||
} | ||
|
||
field_path->current_level++; | ||
php_phongo_field_path_write_type_at_current_level(field_path, PHONGO_FIELD_PATH_ITEM_DOCUMENT); | ||
field_path->size++; | ||
php_phongo_bson_append_object(bson, field_path, flags, key, key_len, entry TSRMLS_CC); | ||
field_path->current_level--; | ||
field_path->size--; | ||
|
||
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) { | ||
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht); | ||
|
@@ -648,7 +650,7 @@ static void php_phongo_zval_to_bson_internal(zval* data, php_phongo_field_path* | |
* will be used. */ | ||
void php_phongo_zval_to_bson(zval* data, php_phongo_bson_flags_t flags, bson_t* bson, bson_t** bson_out TSRMLS_DC) /* {{{ */ | ||
{ | ||
php_phongo_field_path* field_path = php_phongo_field_path_alloc(); | ||
php_phongo_field_path* field_path = php_phongo_field_path_alloc(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
|
||
php_phongo_zval_to_bson_internal(data, field_path, flags, bson, bson_out TSRMLS_CC); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have macros or inline functions for incrementing and decrementing
size
?Does
php_phongo_field_path_write_type_at_current_level()
ensure that there is always sufficient buffer space to incrementsize
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does: https://github.com/mongodb/mongo-php-driver/pull/793/files#diff-f7d29a680148f52d6601f59ed787f577R147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it does. I can make it a macro, but as we're only doing this twice, I didn't see much use of it. Happy to do so if you would prefer it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with keeping this as-is if it's only two uses.