Closed (fixed)
Project:
Project Dependency
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
24 Nov 2011 at 15:20 UTC
Updated:
24 Nov 2012 at 20:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
rfayDefinitely we should get this in soon.
Comment #2
rfayComment #3
rfayOne major problem with versioned dependencies is that without git_deploy, the module versions won't be respected on the testbot (which uses git to check out). Are we going to always require git_deploy? I think that will be required.
The second issue is that requiring a dev is pretty iffy in Drupal right now. Which dev?
Comment #4
trobey commentedI have posted a proposal to allow dependency overrides on #1347790: Specify dependency overrides on the Automated Testing tab, comment #3.
Comment #5
rfayThis is the only way we're going to be able to solve the knottier dependency issues.
Comment #6
rfayAnother look at this one says it's not too terribly difficult to do: At least the versioned dependencies aren't too bad. The parsing of >3.5, etc. might be ugly. But just getting versioned would be good.
Note that project_release_get_recommended has an optional arg for the major.
Note that this will probably not solve every problem, as there are always some edge cases. I suspect it will solve #1802156: Rebuild dependencies for Media 7.x-2.x, but you can see in that one the complexity involved: file_entity was once a part of media but is no longer. So we have dependencies for both of them, and both might match with the same major version.
I'm ok with punting on the complicated cases like
dependencies[] = exampleapi (>1.0, <=3.2, !=3.0)at this point.Related: #1247516: drupal_parse_dependency fails on major version ops (>7.x) and (<=8.x) (project_dependency version)
Thanks so much for taking a look at this, @trobey.
Comment #7
trobey commentedI have some initial results. First, Drupal 7 has two functions that are used to parse versioned dependencies. The first function is drupal_parse_dependency() and the second one is drupal_check_incompatibility(). The second function calls the PHP function version_compare(). I have backported these two functions. This makes the whole thing a bit easier and we need to use the same approach or there will be discrepancies. And when this project is ported to Drupal 7 it will hopefully be a simple switch to the Drupal 7 functions.
But the problem is also worse than I initially thought. As I went through this I began to suspect versioned dependencies broke project_dependency and I have now confirmed it. The example is a dependency string of "media (<1.99)." No possible releases are found that match this string as I suspected. When I use a dependency string of "media" I find 20 possible releases in my test environment. So using versioned dependencies breaks project dependency and this is bug (and a feature request). So I am changing the category and assigning the problem to myself. I should have a patch shortly.
Comment #8
rfayEven if we only had
(2.x)it would solve most of the practical problems that we run up against.
I guess I agree this is a bug... but it's been a longstanding feature request :-)
Comment #9
trobey commentedHere is the patch. I had to add an argument to project_dependency_parse_dependency because projects can be from different core vesions of Drupal. This code looks like:
$dependency_component = $component_info['dependency'];
+ $parsed_component =
+ project_dependency_parse_dependency($dependency_component, $api_term);
+ $dependency_component = $parsed_component['name'];
This fixes the problem with introducing the versioned dependencies into Drupal 7. Each possible release is then checked using:
+ $check = project_dependency_check_incompatility($parsed_component,
+ substr($dependent_release['version'], drupal_strlen($api_term)+1));
and only compatible releases are included.
Comment #10
rfayNicely, elegantly done, thanks!
I found one major issue - the handling of core version wasn't working because of use of drupal_strlen($api_term) instead of $api_term->name, etc. I redid that part to be a bit more explicit.
One nit in a misspelled function name.
I tested this with the junk_test_project .info file in a number of forms.
Needs to use $api_term->name for removal. But I redid this to handle major version etc.
Irrelevant typo, but corrected.
Comment #11
trobey commentedLooks great except for one problem. Did you know that someone had already backported drupal_parse_dependency and called it project_dependency_info_parse_dependency? It is almost exactly like the one that I wrote including the additional argument for the core version. It does not appear to be used anywhere. And it mentions project_dependency_info_check_incompatibility but I cannot find that function. As far as I can tell project_dependency_info_parse_dependency is never used. I would suggest that it be deleted.
I tested your changes in my local environment and they work fine.
Comment #12
rfayWe should clean that up then. This has a long history of boombatower doing it... then it getting orphaned... being partially deployed on d.o... then me taking it on without a full understanding of his work, etc.
Comment #13
trobey commentedPatch updated with the removal of the orphaned function.
Comment #14
rfayOutstanding. Works for me. I did find one unrelated bug in testing #1817828: If no release is found for a dependency, an empty record/dependency array is created, I'll follow with that.
Committed: http://drupalcode.org/project/project_dependency.git/commitdiff/a6700556b
I'd love to get the Test Dependencies one in, and we can make a release and deploy. #698932: "test_dependencies" for dependencies / integration tests
I don't think there are any particular risks of this one, as it seems it would only affect projects using versioned dependencies.
Comment #16
rfayDeployed.
@trobey++
Comment #17
rfayPainful D7 port in http://drupalcode.org/project/project_dependency.git/commitdiff/2c838b2c333
Hopefully that will do it.