Closed (fixed)
Project:
Drush
Version:
8.x-6.x-dev
Component:
Core Commands
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
27 May 2013 at 13:38 UTC
Updated:
26 Jun 2013 at 16:30 UTC
Jump to comment: Most recent file
See the following little function for merging aliases at includes/sitealias.inc:
// array_merge_recursive is too much; we only want to run
// array_merge on the common top-level keys of the array.
function _sitealias_array_merge($a, $b) {
$result = $a;
foreach($b as $key => $value) {
if (array_key_exists($key, $result)) {
$result[$key] = array_merge($result[$key], $b[$key]);
}
else {
$result[$key] = $value;
}
}
return $result;
}
The following statement assumes that all keys that exist in both site aliases contain arrays:
if (array_key_exists($key, $result)) {
$result[$key] = array_merge($result[$key], $b[$key]);
}
This makes that if $site_alias_b redefines a key in $site_alias_a whose contents are not an array you get the following warnings when that site alias is loaded:
array_merge(): Argument #1 is not an array sitealias.inc:673 [warning]
A patch is being posted in the following comment to address this.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | drush-site-alias-merge-warnings-2005196-4.patch | 3.43 KB | juampynr |
| #1 | drush-site-alias-merge-warnings-2005196-1.patch | 1.64 KB | juampynr |
Comments
Comment #1
juampynr commentedAttaching patch. I also documented the function.
Comment #2
moshe weitzman commentedComment #3
greg.1.anderson commentedThis looks good, but it could use a test.
Comment #3.0
greg.1.anderson commentedUpdated issue summary.
Comment #4
juampynr commentedHere you are. You can test it by doing the following:
The above won't throw any warnings and the test will pass. Try now undoing the changes that this patch does at phpunit includes/sitealias.inc and run the test again:
Comment #5
juampynr commentedDoh! Attaching patch.
Comment #6
greg.1.anderson commentedCommitted. Thanks.
Comment #7.0
(not verified) commentedRemoved mention about custom keys.