Some safe API changes to run querypath2 and 3 in parallel #110
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.