Details
-
Type: Improvement
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: 4.7.28
-
Fix Version/s: None
-
Component/s: CiviCRM API
-
Labels:None
-
Versioning Impact:Major (incompatible API change)
-
Documentation Required?:Developer Doc
-
Funding Source:Needs Funding
-
Verified?:No
Description
api.Extension.getremote (and probably api.Extension.get) returns compatibility version as a scalar if there is only one value and an array if more than one. For example:
{ "id": 2, "key": "nz.co.fuzion.extendedreport", ... "compatibility": { "ver": "4.7" }, ... }, { "id": 3, "key": "ca.bidon.reporterror", ... "compatibility": { "ver": [ "4.4", "4.5", "4.6", "4.7" ] }, ... },
This leads to ugly downstream code like:
// Ensure extension.compatibility.ver is an array.
extension.compatibility.ver = (typeof extension.compatibility.ver == 'string' ? [extension.compatibility.ver] : extension.compatibility.ver);
It would be preferable for the first item in the above snippet to be represented as follows:
{ "id": 2, "key": "nz.co.fuzion.extendedreport", ... "compatibility": { "ver": ["4.7"] }, ... },
Then downstream developers would know always to expect an array.