Skip to content

PHPC-1716 Allow configuring server API version in manager #1204

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 18 commits into from
Mar 26, 2021

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Mar 1, 2021

PHPC-1716

This PR is built on the current WIP state of versioned API support in the C driver to allow designing the PHP driver interface and verify that it passes all spec tests. Note that the changes to submodules (including the libmongoc version) will be re-done once versioned API support lands in the main libmongoc development branch.

@alcaeus alcaeus requested a review from jmikola March 1, 2021 11:39
@alcaeus alcaeus self-assigned this Mar 1, 2021
@alcaeus alcaeus force-pushed the phpc-1716 branch 3 times, most recently from b241321 to 0248588 Compare March 10, 2021 12:17
@alcaeus alcaeus changed the title [POC] PHPC-1716 Allow configuring server API version in manager PHPC-1716 Allow configuring server API version in manager Mar 10, 2021
@alcaeus alcaeus force-pushed the phpc-1716 branch 3 times, most recently from 851de9e to bac6f18 Compare March 22, 2021 17:17
@@ -7,7 +7,7 @@ DO NOT EDIT THIS FILE
--FILE--
<?php

require_once __DIR__ . '/../utils/tools.php';
Copy link
Member

Choose a reason for hiding this comment

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

Is this the result of using a wide net for search/replace? I would have assumed tests that manually include tools.php could be left as-is, because they typically do not connect to a server.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I replaced all instances of tools.php to require the .inc file for consistency. I can revert this change if you think that's unwise.

Copy link
Member

Choose a reason for hiding this comment

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

It's not necessary but I can see how it'd make maintenance easier by not having to think about which file to include. No objections to leaving as-is.

.gitmodules Outdated
@@ -1,6 +1,6 @@
[submodule "src/libmongoc"]
path = src/libmongoc
url = https://github.com/mongodb/mongo-c-driver.git
url = https://github.com/alcaeus/mongo-c-driver.git
Copy link
Member

Choose a reason for hiding this comment

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

Is this still necessary given that CDRIVER-3821 is merged?

The only open PR I found on libmongoc is mongodb/mongo-c-driver#753, but that seems unrelated to PHP.

Copy link
Member Author

@alcaeus alcaeus Mar 24, 2021

Choose a reason for hiding this comment

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

I had not managed to create the PR before. mongodb/mongo-c-driver#765 contains the changes necessary, most notably fixing a wrong function name and adding a getter for the version field in mongoc_server_api_t.


if (*server_api) {
mongoc_server_api_destroy(*server_api);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this ever reached? If not, would it be better to throw an exception and return false? AFAICT, this is only called from the constructor and php_phongo_serverapi_init_from_hash, both of which should use freshly initialized objects.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced this with an exception instructing users to file a bug report as it shouldn't happen.

Copy link
Member

Choose a reason for hiding this comment

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

Should we standardize on American English spelling ("initialized") here?

Copy link
Member Author

@alcaeus alcaeus Mar 25, 2021

Choose a reason for hiding this comment

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

I forgot we use American English as opposed to British English. I'll update it.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

Some questions on code formatting for macros, but LGTM otherwise.

Beyond that, take a look at the CI failures. AppVeyor reports a compilation failure in some macro.

The Evergreen failure appears to be related to what you fixed in #1206.

EH_THROW, \
phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), \
&error_handling); \
ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be indented consistently with the lines above since it falls within do {?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, totally missed that. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah...I was wondering about this: it seems like clang-format immediately wants to undo my changes and restore this broken formatting, so I'm afraid we're stuck with this for the time being :(

ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)

#define PHONGO_PARSE_PARAMETERS_END \
ZEND_PARSE_PARAMETERS_END_EX( \
Copy link
Member

Choose a reason for hiding this comment

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

Same question about indentation here.

@@ -7,7 +7,7 @@ DO NOT EDIT THIS FILE
--FILE--
<?php

require_once __DIR__ . '/../utils/tools.php';
Copy link
Member

Choose a reason for hiding this comment

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

It's not necessary but I can see how it'd make maintenance easier by not having to think about which file to include. No objections to leaving as-is.

@alcaeus
Copy link
Member Author

alcaeus commented Mar 25, 2021

Beyond that, take a look at the CI failures. AppVeyor reports a compilation failure in some macro.

This was due to me using ZEND_STRL in zend_hash_str_add, which is implemented as a macro in PHP < 7.3. I've removed this usage for the time being. According to @cmb69, ZEND_STRL should not be used; this will most likely also affect other usages of ZEND_STRL in similar instances.

The Evergreen failure appears to be related to what you fixed in #1206.

Yes, those are fixed as well now.

@alcaeus
Copy link
Member Author

alcaeus commented Mar 25, 2021

Note: holding off on merge until mongodb/mongo-c-driver#765 is merged.

@alcaeus alcaeus changed the title PHPC-1716 Allow configuring server API version in manager [WAIT] PHPC-1716 Allow configuring server API version in manager Mar 25, 2021
@jmikola
Copy link
Member

jmikola commented Mar 25, 2021

This was due to me using ZEND_STRL in zend_hash_str_add, which is implemented as a macro in PHP < 7.3. I've removed this usage for the time being. According to @cmb69, ZEND_STRL should not be used; this will most likely also affect other usages of ZEND_STRL in similar instances.

I'm familiar with that. I assume it's because ZEND_STRL may not be expanded before the preprocessor checks arguments for the outer macro (zend_hash_str_add in this case).

Our previous issues with ZEND_STRL had to do with it only being suitable for literals (see: https://github.com/mongodb/mongo-php-driver/search?q=ZEND_STRL&type=commits). That seems unrelated to this.

I don't think we need to stop using ZEND_STRL altogether, though. The build failures when we do something wrong should be obvious :)

@alcaeus alcaeus changed the title [WAIT] PHPC-1716 Allow configuring server API version in manager PHPC-1716 Allow configuring server API version in manager Mar 26, 2021
@alcaeus alcaeus merged commit deead96 into mongodb:master Mar 26, 2021
@alcaeus alcaeus deleted the phpc-1716 branch March 26, 2021 14:43
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