Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Backend invoke sends back all options contexts as part of any function call, so drush should not store large data structures (e.g. site aliases) in the options context.
Drush is already copying site aliases out of the $options array returned from a configuration file into a particular options context, so it would be easy enough to change it to store them somewhere else without at all affecting how they are defined in user's config files.
Comment | File | Size | Author |
---|---|---|---|
#13 | drush-sitealias-context-3.patch | 23.38 KB | greg.1.anderson |
#6 | drush-sitealias-context-2.patch | 23.1 KB | greg.1.anderson |
#1 | drush-sitealias-context.patch | 7.23 KB | greg.1.anderson |
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedI whipped this together because it was easy, won't cause any compatibility problems with existing config files, and will reduce the size of the results record returned by backend_invoke by quite a bit.
As an added bonus, this patch also makes it possible to define a 'config-path' in your alias. If you do, the config file (drushrc.php file) referenced will be loaded when the alias is first fetched. This fell out naturally from the equivalent code that loads the drushrc.php file from the 'sites' dir of an alias when it is first loaded.
Comment #2
greg.1.anderson CreditAttribution: greg.1.anderson commentedI realize there are some minor interaction issues with this patch that need to be worked out, particularly with respect to when the options of an alias are added to the 'alias' context.
Comment #3
adrian CreditAttribution: adrian commentedi think the only time the 'alias' context should be used is when it is specified before the command.
ie: drush [context] command-here
This is just my gut feeling however.
Comment #4
greg.1.anderson CreditAttribution: greg.1.anderson commentedEdit: You're right, the 'alias' context is only used as you describe above, or when you use an alias in certain commands, such as 'sql-sync alias1 alias2'.
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commentedRegarding using $aliases instead of $options['site-aliases'], the later is a little more convenient in the following snippet from drush_load_context:
With only two such examples, we could easily enough unroll this loop to use $aliases and $command_specific. I could even add an array_merge($options['site_aliases'], $aliases) to keep backwards-compatibility with old configuration files, if anyone thought that was important.
Edit: I have another solution very similar to the suggestion above, except that it merges $aliases into $options and then runs the code above unchanged. Doing it this way is better vis-a-vis the reconciliation of site alias options and options in a configuration file. Patch available shortly.
Comment #6
greg.1.anderson CreditAttribution: greg.1.anderson commentedHere is a substantially improved patch. It does the following things:
$options['site-aliases']['mysite'] = ...
still works, but$aliases['mysite'] = ...
is now preferred.$options['command-specific']['dl'] = ...
still works, but$command_specific['dl'] = ...
is now preferred.drush sql-sync peer mysite
anddrush sql-sync mysite peer
will both work.Kind of a lot for one patch, but all of this stuff was interrelated, and this cleans things up quite a bit. These changes shouldn't break anyone; if it does, it's probably a bug.
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedAre you targetting 3.0 or next release for this? I'm OK with either.
Comment #8
greg.1.anderson CreditAttribution: greg.1.anderson commentedThat depends on how quickly you want to get 3.0 out. This could be committed now (after review) if you were going to do beta-2 in about a week, and rc1 a week after that. If you wanted to do rc1 followed by a quick 3.0 stable, then I'd go ahead and do that, and put this in 3.1.
My preference would be to put this in 3.0-stable, since $aliases is nicer than $options['site-aliases'], and there are good performance benefits to this wrt backend_invoke. These changes are not deep (no substantial change to the way things work), but they are broad (touches a lot of different parts of the code), so although I tested it, I wouldn't want to put it in a 'stable' release without some time at HEAD. A couple weeks or so is probably enough time to ferret out any missed bugs.
Comment #9
adrian CreditAttribution: adrian commentedi'd also vote for this being a 3.0 thing, but willing to relent for 3.1
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedOK, 3.0 it is. I'm happy if you two can review and commit this. I'll try to provide feedback but don't wait for me.
Comment #11
greg.1.anderson CreditAttribution: greg.1.anderson commentedOkay, thanks. I'll wait for Adrian to review; feel free to commit if you think it's ready, or bounce it back to me if you want changes.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedI did some quick testing with this and it seems to work as before. IMO, its ready. Lets wait a day for Adrian's review.
Comment #13
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis is the same as #6, except there is a trivial change:
drush site-alias aliasname --full
prints "$aliases['aliasname'] = ..." instead of "$options['site-aliases']['aliasname'] = ...".Comment #14
adrian CreditAttribution: adrian commentedThis has been rolled into :
#733256: Aliases should be loaded from a central location rather than drushrc.php