[Developer Tool] New event listener: app_pre_setup - ability to group data registry entries to fetch

DragonByte Tech

Well-known member
At the moment, there is no way to tell XF2 to group a bunch of data registry entries into a single query. This means that if you have multiple add-ons installed that all use their own prefix system, or their own custom fields, then you are adding X number of additional queries to fetch each single xf_data_registry entry.

The change necessary would be extremely small.

In \XF\App find:
PHP:
$preLoadExtra = isset($options['preLoad']) ? $options['preLoad'] : [];
$this->preLoadData($preLoadExtra);

Add below:
PHP:
$preLoadExtra = [];
$this->fire('app_pre_setup', [$this, &$preLoadExtra]);

if (!empty($preLoadExtra)
{
    try
    {
        $this->registry()->get($preLoadExtra);
    }
    catch (\Exception $e) {}
}

Adding this above app_setup is essential since that's where we tend to fetch our data registry entries. This change would not break BC in any way that I can tell, as add-ons that have not yet been updated to take this feature into account would continue to load their data registry entries as normal.

Thanks!
 
Upvote 7
Top Bottom