Some safe API changes to run querypath2 and 3 in parallel#110
Open
mkalkbrenner wants to merge 1 commit intotechnosophos:masterfrom
Open
Some safe API changes to run querypath2 and 3 in parallel#110mkalkbrenner wants to merge 1 commit intotechnosophos:masterfrom
mkalkbrenner wants to merge 1 commit intotechnosophos:masterfrom
Conversation
- renamed qp() to qp3() - renamed htmlqp() to htmlqp3() - renamed \QueryPath to \QueryPath\QueryPath If querypath2 is not present, these changes happen on the fly for backwards compatibility: - declare function qp() as wrapper for qp3() - declare function htmlqp() as wrapper for htmlqp3() - declare \QueryPath as class alias for \QueryPath\QueryPath
Contributor
Author
|
Thanks for your response and starting the discussion. Introducing qp3() is more a workaround than a good solution and not an API change I really like. Basically I don't see a problem in running two versions in parallel when you use namespaces. The real problem is that the functions qp() and htmlqp() and the class QueryPath are declared in the global namespace. And the functions are always loaded - not only if they are required. For classes switching the version is easy: use QueryPath3\QueryPathUnfortunately that does not work for functions. As long as the two functions exist, I don't see how to fix that on the drupal side as well :-( Let me think about it ... |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
First some background information:
For the development of HVRawConnectorPHP I decided to use querypath 3.x.
Therefor the drupal integration module HealthVault™ Connect adds querypath3 as library to your drupal installation.
But as soon as you install another contrib module that depends on the QueryPath module which still contains querypath2, you end up with fatal errors because functions like qp() could not be redeclared.
Unfortunately it's not an option to upgrade the querypath library within the drupal QueryPath module, because (for whatever reason) modules like Apache Solr Config Generator don't work with querypath3.
But due to the fact that you introduced a \QueryPath namespace in querypath3, it's not a big problem to run querypath2 and 3 in parallel. But you have to avoid the redeclaration of the global functions qp() and htmlqp() and the class QueryPath must not be part of the global namespace.
So I applied these safe API changes to run querypath2 and 3 in parallel:
Now I can explicit use querypath3 in my module.
If querypath2 is not present, these changes happen on the fly for backwards compatibility, so that nobody has to change his existing code:
To demonstrate the backwards compatibility I did not touch the tests in my patch.
What do you think about that?
From my point of view, the API change is OK, because querypath 3 is still very new and even the documentation on querypath.org has not been updated yet.
I'm open for a discussion or any other solution to run qp2 and qp3 in parallel.