See #1152908: Remove calls to drush_backend_invoke() (Call to undefined function drush_backend_invoke() in features.drush.inc line 214). If Mark's latest patch is committed, then features is broken for drush-4. If it is not committed, then features is broken for drush-5. Module writers already need to have separate versions for each major version of Drupal; it seems severe to require them to have multiple versions of their drush commands as well. I should have argued this more at the sprint.
The new drush_invoke_process is equivalent to the old drush_invoke_sitealias_args. If We put back drush_invoke_sitealias_args as a simple function that calls through to drush_invoke_process, and mark it as deprecated, then it would be possible for a module such as features to use that function and remain compatible with both drush-4 and drush-5.
If we don't do this, then we need to add support for *.drush-5.inc for commandfile loading (and make sure that drush-5 and later ignores *.drush.inc if there is any similarly-named *.drush-INTEGER.inc available), pronto.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | version-specific-for-4.x.patch | 12.82 KB | greg.1.anderson |
| #17 | version-specific-for-4.x.patch | 0 bytes | greg.1.anderson |
| #16 | version.diff | 15.22 KB | moshe weitzman |
| #15 | version-specific-14.patch | 9.81 KB | greg.1.anderson |
| #13 | version-specific-13.patch | 7.59 KB | greg.1.anderson |
Comments
Comment #1
moshe weitzman commentedI prefer this road, than keep around legacy code from a prior version. Needs discussion.
Comment #2
greg.1.anderson commentedI have to admit that there might be other differences between drush-4 and drush-5 that may get to be more and more difficult to track; perhaps it is better to allow / force developers to keep multiple versions of their drush commandfiles around. Perhaps we should put support for drush-4.inc into drush-4.5 as well to keep things uniform.
Comment #3
msonnabaum commentedVery glad to see this. As I was writing the new feature patch it dawned on me that this will be a big problem. I'm fine with the separate command files, but I could also see declaring api compatibility in the command hook (I know we've talked about that before), or even adding the 4 or 5 to the callback name.
Either way, we need to come up with something. I'm also in favor of doing this as opposed to trying to maintain compatibility in code.
Comment #4
moshe weitzman commentedI'll note that it is technically possible for module developers to do this today. Have a look at http://api.drush.org/api/function/_drush_add_commandfiles/5.x and focus on the $load_test_inc stuff. A module author can ship with two commandfiles and only load one of them by also shipping with two COMMANDFILE.drush.load.inc files with simple hook_drush_load() implementations (e.g. return DRUSH_VERSION == 5). I think Aegir uses this hook.
Apart from this strategy being obtuse, I don't think module developers will be too happy about shipping with two commandfiles. The commandfiles can share common code, but we might be causing too much aggravation. Not sure what other solution we can offer.
Declaring compatibility from within the command declaration is no good. We just can't load incompatible code. If we do, we'll run into duplicate function problems once the compatible commandfile tries to load.
Comment #5
moshe weitzman commentedCopying a valuable comment by by Greg.1.Anderson from #1175446: Best practice for upgrading shared drush to next major version that belongs here:
Comment #6
greg.1.anderson commentedThanks. Regarding the research on function availability in different versions of drush, this is already available at api.drush.ws; for example, see http://api.drush.ws/api/function/drush_backend_invoke/4.x. Perhaps we could do more to point users to the right function to use in the next version of drush when a function is deprecated or removed.
Comment #7
tim.plunkettSubscribe.
Comment #8
moshe weitzman commentedComment #9
moshe weitzman commentedI think the plan outlined in #5 is solid. Anyone have further thoughts on this. Anyone willing to take it on? This issue is marked critical for good reason.
Comment #10
greg.1.anderson commentedWilling, but busy for a week or two; will be a squeak to get this in for BADCamp. Wouldn't mind if someone else wants to take it.
Comment #11
moshe weitzman commentedSeems like the attached patch the first paragraph of the spec in #5. Just adds some drush4, drush5, etc to the $nomask for drush_scan_directory().
When we unify aliasfile searching with commandfile searching, this should apply to aliasfiles as well.
Comment #12
greg.1.anderson commentedEnhanced version of #11 attached. Code should be good, but needs docs -- those are coming shortly.
Comment #13
greg.1.anderson commentedNow with docs.
New features:
drushrc.php still works as before; drush5rc.php (where 5 == DRUSH_MAJOR_VERSION) is also loaded, if it exists. The version-specific file can appear anywhere the regular config file does. This feature is useful for end users, who can separate version-specific configuration directives from their general-purpose drush options.
drush4/mycommand.drush.inc (where 4 == any number other than DRUSH_MAJOR_VERSION) is now ignored, same as in #11, above. This is useful for end-users, who can separate their version-specific drush commands into $HOME/.drush/drush4 and $HOME/.drush/drush5.
mycommand.drush5.inc (where 5 == DRUSH_MAJOR_VERSION) is now loaded. This is useful for module developers, who can provide mycommand.drush4.inc and mycommand.drush5.inc. (n.b. no previous version of drush will load either of these files, which is good; drush 4.5 would load drush5/mycommand.drush.inc.)
alias files work the same as above (drush5/mysite.aliases.drushrc.php and mysite.aliases.drush5rc.php both recognized) for consistency. This is useful for users who want to put in version-specific alias options. Maybe this will be rare.
Comment #14
greg.1.anderson commentedThis adds a --ignored-modules flag so that you can skip *.drush.inc files in modules that have drush commands that are incompatible with the version of drush that you are using. Only commandfiles in drupal modules are ignored, so you can move fixed drush commandfiles to $HOME/.drush/drushN if you'd like.
Comment #15
greg.1.anderson commentedAnd here is the patch.
Comment #16
moshe weitzman commentedNice work!
Attached is same patch plus unit tests for version specific config files and commandfiles. The commandfile one is not ready yet. I'll keep hacking on it, unless someone feels inspired to work on it today.
Comment #17
greg.1.anderson commentedHere's a start on the 4.x branch. I think the code is working okay (only lightly tested), but the test cases are broken -- ran out of time and have to stop here.
Comment #18
greg.1.anderson commentedWhoops, I screwed up the patch above and then did a git reset --hard HEAD. Is there a way I can find the commit hash to get my work back? :p
Edit: Nope, no commits, so
git reflogis of no hope. Oh well, I'll have it back with ~15 minutes of work.Comment #19
greg.1.anderson commentedRe-made the patch above (this time using a branch :p); also adjusted the test case so that it runs on drush-4. Didn't add any new tests, though.
Comment #20
moshe weitzman commented@Greg - not sure how I should proceed. Is my patch in #16 the latest for drush5? I'm guessing that you didn't try to fix the commandfile test, did you?
Comment #21
greg.1.anderson commentedI didn't try your tests on drush5 -- I presumed that you were going to continue here. I did make whatever tests you had in the drush5 branch work in the drush4 branch, so perhaps this work might be helpful in master too if your tests are broken there -- I guess I misread #16 the first time. I thought that the tests you committed worked, and you had more to write, but that isn't what you said. So yeah, I guess I must have fixed the non-working commandfile test.
Want me to roll a new patch for master?
Comment #22
greg.1.anderson commentedI looked at this a little bit, and my test for drush-4 fails in master (moved from contextTest in 4.x to contextTest in master; not commandTest). Hm.
Comment #23
greg.1.anderson commentedI note on test case philosophy: I think the addition of drush unit tests is a good thing, but a unit test should never call any bootstrap code. Drush can only bootstrap Drupal (and itself) once, whereas unit tests should be executable in any order, over and over again, etc.
So, tests requiring a bootstrap should be done as functional test. Unit tests should only test functions (god, that's so confusing) with no side effects.
Comment #24
moshe weitzman commentedFYI, each UnitTest test should be executed in isolation. See 'runTestsInSeparateProcesses' in the doxygen in Drush_UnitTestCase.
I will look into the test fail on drush5. i'm not immediately sure whats different about commandfile loading between the two versions.
Comment #25
moshe weitzman commentedI fixed up the commandfile test and committed #16 to master. I think my commandfile test changes should be backportable to drush4.
Assigning to Greg for backport. See commit 54d1ca9aeeef91da9049f1b379aaa268fa814def
Comment #26
moshe weitzman commentedOops. Also needs my next commit which is only 1 line: 5e7573d
Update: changed again in 539283b
Comment #27
moshe weitzman commentedCommitted to drush4 without commandfile test since that uses a UnitTest which is not available on drush4.
Comment #28
moshe weitzman commentedNeeds change notification
Comment #30
moshe weitzman commentedChange notice at http://drupal.org/node/1406996