Advanced search export: when location types' display names are different from their machine names, empty columns are exported
EDITED to be more accurate following further investigation into the symptoms.
This is a regression in the last couple versions of Civi (I see it on 5.3.1 and 5.4.0, as well as 5.5-rc and master).
Summary: When exporting from advanced search, if you select email/phone/address fields to export where the location type's display name is different from its machine name, the headers for those columns will be included in the export, but the cells in those columns will be blank.
To reproduce:
- Create a location type called "Field Office" with machine name "FieldOffice" or "FO"
- Create a contact with a "Field Office" email.
- Find that contact using advanced search and select the "export" task.
- Select "Individual - Email - Field Office" as a field to export.
- In the resulting CSV, there's a blank cell where the email address should be.
Notes: I also notice:
- the columns in the export are not in the same order as on the export column selection screen.
- exporting from Search Builder has a similar-but-different problem: if two location types are selected for export, only one of the columns will successfully be exported.
I see that quite a bit of work has gone into the Export code in recent releases and I suspect this regression happened as a result.
I'm interested in creating tests for this but I'd need someone to hold my hand through the process, as I have no recent experience doing that.