Several problems that are somewhat interconnected and whose solutions are interdependent. Details below.
To reproduce:
- Install the latest Drupal 7.22, Chaos Tools, and the latest dev release of drush.
- Append the following to ctools.info:
project status url = http://www.quietcompanymusic.com/drupal/release-history
- Run through each of the following commands and note expected output vs. actual.
drush pm-updatecode ctools
If a module contains submodules whose short names come before the primary module's short name alphabetically, the primary module's "project status url," defined in its .info file, will not be properly read/returned.
-
Expected output:
Name Installed Version Proposed version Message Chaos tools (ctools) 7.x-1.3 7.x-1.4 Update available
-
Actual output:
No code updates available.
drush pm-releases ctools
This command doesn't even take into consideration the "project status url" defined in an installed module's .info file at all.
-
Expected output:
------- RELEASES FOR 'CTOOLS' PROJECT ------- Release Date Status 7.x-1.4 2013-Jul-05 Supported, Recommended 7.x-1.x-dev 2013-Jul-05 Development 7.x-1.3 2013-Apr-03 Installed
-
Actual output:
------- RELEASES FOR 'CTOOLS' PROJECT ------- Release Date Status 7.x-1.x-dev 2013-Jul-05 Development 7.x-1.3 2013-Apr-03 Supported, Recommended, Security, Installed
drush pm-download ctools --select
This command doesn't even take into consideration the "project status url" defined in an installed module's .info file at all.
-
Expected output:
Choose one of the available releases for ctools: [0] : Cancel [1] : 7.x-1.4 - 2013-Jul-05 - Supported, Recommended [2] : 7.x-1.x-dev - 2013-Jul-05 - Development [3] : 7.x-1.3 - 2013-Apr-03 - Installed
-
Actual output:
Choose one of the available releases for ctools: [0] : Cancel [1] : 7.x-1.x-dev - 2013-Jul-05 - Development [2] : 7.x-1.3 - 2013-Apr-03 - Supported, Recommended, Security, Installed
drush make-generate
If a module contains a "project status url" definition in its .info file, it will not be properly reflected in the resulting projects[project_name][location] make file property.
-
Expected output:
projects[ctools][location] = "http://www.quietcompanymusic.com/drupal/release-history" projects[ctools][version] = "1.3"
-
Actual output:
projects[ctools][location] = "" projects[ctools][version] = "1.3"
Comments
Comment #1
iamEAP CreditAttribution: iamEAP commentedPatches for both 6.x and 5.x.
Comment #2
iamEAP CreditAttribution: iamEAP commentedLooks like calling this when drush isn't bootstrapped to a Drupal database causes fatals.
Adressing that in these patches. Again, 6.x and 5.x.
Comment #3
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis patch doesn't make much sense to me. So, Drush will be able to correctly find the source for non-drupal.org projects that you are downloading -- but only if they have already been downloaded into the current site? drush_get_extensions() is really slow; it doesn't seem to be worth it.
Comment #4
iamEAP CreditAttribution: iamEAP commentedUse-case here is for easier package management of custom modules / features that aren't suitable for distribution on drupal.org (e.g. at a large enterprise / university / other organization). If Drupal already has the info for the update URL, we should be taking advantage of it; especially since core provides this functionality in the Update module.
Some more context: https://drupal.org/project/project_src
I'm not terribly familiar with the drush codebase; is there anything more efficient at getting extension info than drush_get_extensions?
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis code is supposed to run at pm-update time? The concept seems good, but I'm not sure that the submitted patch does what it is intended to do.
Do you have any test data to run this with?
Comment #6
iamEAP CreditAttribution: iamEAP commentedSure. I've created a private gitlab.com repo with a clone of ctools; in my private repo, I've tagged a 7.x-1.4 release, which you'll see reflected here: http://www.quietcompanymusic.com/drupal/release-history/ctools/7.x
To test functionality...
project status url = http://www.quietcompanymusic.com/drupal/release-history
You should see that
drush dl ctools
--select will show the custom 7.x-1.4 release.I hadn't considered pm-update; tested it out and #2 indeed doesn't address it. I do think the end-solution should address both scenarios, though.
Comment #7
greg.1.anderson CreditAttribution: greg.1.anderson commentedI don't think the scenario in #6 is very useful, because we don't have the status url available unless the project already exists in the site. The pm-update use case would be very helpful, though; since you have updatexml for your releases, it should be possible for this to work.
You said this is supported in Drupal core, though; if the change in #6 is made, will Drupal's module update status page show new releases published at the custom project status url? I haven't tested, but it seems that if Drupal supports this, a lot of the operations required for Drush updates should already be handled.
Comment #8
iamEAP CreditAttribution: iamEAP commentedI and a few of my colleagues use
drush dl
to update/overwrite existing modules in place of pm-update/upc because, on sites with upwards of 50 modules, pm-update can take a minute or more to complete. I wouldn't be surprised if that behavior wasn't fairly common, regardless of codebase size.Regardless, it would feel broken for
drush dl
anddrush upc
to affect a drupal installation differently. Imagine running upc, seeing an available update, then aborting the actual command to run drush dl instead, only to have the dl fail with a "no updates available" error (or worse, that it doesn't even think the module exists upstream).Regarding your second point, I tested upc, and it nearly works, but I found a bug in drush_get_projects() that could break this in some situations. Opened a separate issue for that here: #2044487: drush_get_projects() does not properly load project status url in rare cases
Since
upc
more or less works (except that issue I noted), I'm flipping this back to needs review, since I still think making it work fordl
is important, and the attached patch makes that happen / it's worth discussing.Comment #9
greg.1.anderson CreditAttribution: greg.1.anderson commentedI think the patch presented here can be committed if pm-update also works. #2044487: drush_get_projects() does not properly load project status url in rare cases also looks good, so I am in favor of committing both of these, once they have been tested. I'll try to squeeze in time to do that, but maybe another maintainer will get to it first.
Comment #10
greg.1.anderson CreditAttribution: greg.1.anderson commentedWhile I like the idea and direction here, I'm still reluctant to add the overhead of drush_get_extensions(), which loads information about all extensions, just to get some info on just one project. Also, note that this technique won't work if the project you are downloading is not enabled. Maybe that's not an issue for the use case, but I think that the performance hit is still too high.
pm-download already finds the destination where it is going to save the project. Perhaps you can use this directory to deterine if there is already an info file present, and if so, parse it with _drush_drupal_parse_info_file(). That would be much faster.
I didn't look at the code to see if this variable is available early enough, or if it would be easy enough to refactor the code so that it was, if necessary. I'd guess this should be possible, though.
Comment #11
iamEAP CreditAttribution: iamEAP commentedUnfortunately, the code used to find the install destination in pm-download depends on $request['project_type'] being set (e.g. module, theme, core, profile, etc). The project type itself isn't determined until after loading the update XML.
Comment #12
iamEAP CreditAttribution: iamEAP commentedClarifying the title and, moving back to bugs. Update the issue summary with details shortly.
Comment #12.0
iamEAP CreditAttribution: iamEAP commentedClarifying the bugs.
Comment #12.1
iamEAP CreditAttribution: iamEAP commentedFixing markup error.
Comment #13
iamEAP CreditAttribution: iamEAP commentedPatch that takes care of all of the scenarios above. Does not take care of your performance concerns, @greg.1.anderson, but we can look at tackling that within the framework of this patch.
PS, really appreciate your quick responses and direction!
Comment #14
greg.1.anderson CreditAttribution: greg.1.anderson commentedI think we need to commit #2044487: drush_get_projects() does not properly load project status url in rare cases first; then we can return here and see if there is a better way to find the .info file than drush_get_extensions().
Comment #15
greg.1.anderson CreditAttribution: greg.1.anderson commentedI didn't notice that you merged these issues together. Re-opening.
Comment #16
greg.1.anderson CreditAttribution: greg.1.anderson commentedFrom https://drupal.org/node/2044487#comment-7658845:
I still need an answer to this before I can do any further testing here.
Comment #17
iamEAP CreditAttribution: iamEAP commentedThat should be it; I followed my instructions on a clean D7.22 install and am able to toggle back and forth by un/commenting the relevant line in the info file with no cache clears necessary.
Did you verify that you're updating the right ctools.info file (e.g. in a multisite environment)? Did you verify ctools is enabled? Did you verify drush is targeting the right site?
Comment #18
greg.1.anderson CreditAttribution: greg.1.anderson commentedI tried again with #13. pm-download and pm-releases work fine, but I still cannot get pm-updatestatus or pm-updatecode to work.
Comment #19
greg.1.anderson CreditAttribution: greg.1.anderson commentedI tried again on another Drupal site, and pm-updatestatus / pm-updatecode worked fine.
This is all very excellent, except I still don't like the fact that pm-download will end up calling drush_get_extensions() via request_info_url(), and I don't really like that you stored this large structure into a static variable.
The later issue is minor, but is also easy to fix. Note that pm-enable does the following, at the end of its validate function:
You could do something similar (with just the extensions) in request_info_url(), or perhaps better yet, make drush_get_extensions() cache in a context, so any client may repeatedly call drush_get_extensions(), and only take a performance hit on the first call. Note that by caching in a context instead of a static, clients can clear the cache by setting the context to an empty array. This is also sometimes done via a boolean parameter $refresh (e.g. in the case of an implementation that uses a static variable, to clear it).
I'm going to leave it up to another maintainer to decide whether any of this warrants further work, or if it should just be committed as-is, with additional performance enhancements to be handled in a future issue.
Good work on this.
Comment #20
moshe weitzman CreditAttribution: moshe weitzman commentedAssign to jonhattan for review
Comment #21
jonhattanpm-download and other pm- commands accepts a non-drupal.org status url (or update xml) via --source option. So
drush dl ctools --source=http://www.quietcompanymusic.com/drupal/release-history/ctools/7.x
works, after applying the patch in #2044487: drush_get_projects() does not properly load project status url in rare cases.Also, if a project has a custom "status url", pm-update uses it through drupal's update.module.
So the request here is to allow pm-download to use the status url of an already downloaded module.
I'm planning to introduce caching to drush_get_extensions() since I've found some problems while debugging #1989202: Infinite loop when trying to enable not available extensions and it doesn't work consistently across Drupal versions. #13 should wait till then.
An alternative to #13 would be to hook in pm-download and pass in
source
option if argument matches. It could be even a handy documentation example.Comment #22
iamEAP CreditAttribution: iamEAP commentedThis may be a slight mischaracterization; while that may be one net gain, the idea is to architect pm commands to take project status url into consideration the same way Core does:
In the meantime, I'll dive into the issue that this issue is waiting on.
Comment #23
minorOffense CreditAttribution: minorOffense commentedJust to through one more step in that list, I'm working on #2004058: Allow default update URL to be configured in drush profile settings to match Drupal core update options and thought I'd get some feedback here (and some direction).
I'd propose to have a new third step where drush checks if an override for the default location has been set. Similarly to how you can change the update_fetch_url variable in drupal.
So we would have
You can see in the referenced issue where I'm at, but I don't really know where it would be ideal to check for the override.
Comment #24
greg.1.anderson CreditAttribution: greg.1.anderson commentedCould #23 be done with a command-specific --source option?
Specifying --source on the commandline will override the command-specific option. You'd have to set both 'pm-updatecode' and 'pm-update'.
Comment #25
iamEAP CreditAttribution: iamEAP commented#24 seems plausible. I wonder if it would be easier to understand if we were to include @minorOffense's additional logic within the release_info_url() function from #13?
Comment #26
greg.1.anderson CreditAttribution: greg.1.anderson commentedWell, yes, but if I am understanding correctly, what we have (modified version from #13) is:
I think that in #24, you are suggesting that we add logic to
release_info_url()
to replace RELEASE_INFO_DEFAULT_URL withdrush_get_option('update_fetch_url')
if it is specified. However, I think that the result of this is that --source and --update_fetch_url (should be --update-fetch-url, I think) do exactly the same thing -- so I don't think that the later is actually necessary.Comment #27
iamEAP CreditAttribution: iamEAP commentedSee: https://github.com/drush-ops/drush/issues/19
Comment #27.0
iamEAP CreditAttribution: iamEAP commentedOne more markup fix.
Comment #28
Nico Heulsen CreditAttribution: Nico Heulsen commentedFixed issue in drush upc/up.
StatusInfoDrush.php:93
should be:
StatusInfoDrush.php:93
Please review
Comment #29
Nico Heulsen CreditAttribution: Nico Heulsen commented