`CRM_Core_DAO::getFieldValue()` should default to current `domain_id`
Okay, I'll admit I'm at a loss as to how to solve this one - the DB abstraction layer seems, well, inscrutably abstract to me. Nevertheless:
Whilst setting up CiviCRM multisite, I discovered that CRM_Core_DAO::getFieldValue()
is not aware of the current domain_id
.
This has been solved for two of the Extensions I've been using (which retrieve entries from the civicrm_navigation
table) by analysing the incoming parameters to hook_civicrm_navigationMenu
for correct values. See, for example:
However, it seemed to me that there's a more general issue amongst Extensions because the majority use this DB lookup method to find the ID of a top-level menu item. See, for example:
All of the above Extensions will fail to target menu items properly in CiviCRM multisite when the domain_id
is not the default. More specifically, the following search returns Extensions which target the top-level "Administer" menu item in particular - using the DB lookup method:
https://github.com/search?p=2&q=%24administerMenuId+%3D+CRM_Core_DAO&type=Code
From the similarity of the code, it would seem as though this DB lookup method has propagated through the Extensions ecosystem as the "canonical" way to do this sort of thing. So it seems there are two routes forward:
- Educate Extension authors on how to retrieve the menu item from the array that's passed to
hook_civicrm_navigationMenu
callbacks for the correct value - Make
CRM_Core_DAO::getFieldValue()
default to currentdomain_id
when appropriate
With Option 1, the problem would (eventually) be solved for menus - but it would remain wherever getFieldValue()
is used for data that is different per domain_id
.
With Option 2, well, that's where I get lost