Fixed Add-on controls unnecessarily load complete template/phrase/option records

Painbaker

Well-known member
Licensed customer
Affected version
2.3.13
Opening an add-on’s controls menu calls XF\Admin\Controller\AddOnController::actionControls(), which executes:
Code:
		$templates = $this->finder(TemplateFinder::class)
			->where('addon_id', $addOn->addon_id)
			->fetch()
			->groupBy('type');
SQL:
SELECT *
FROM xf_template
WHERE addon_id = 'OzzModz/KnowledgeBase';
All matching templates including template and template_parsed are loaded only to determine whether public/ email /admin templates exist

On large installations query can take dozens of seconds

Suggested fix: Retrieve only the available types:

SQL:
SELECT DISTINCT type
FROM xf_template
WHERE addon_id = ?

Also adding an index on (addon_id, type)
the standard table schema has no index with addon_id[/CODE]
 
The phrase lookup has a similar issue
Code:
        $phraseFinder = $this->finder(PhraseFinder::class);
        $phrases = $phraseFinder->where('addon_id', $addOn->addon_id)->fetch();
        $hasPhrases = ($phrases->count() > 0);


and options:


Code:
            $optionRepo = $this->repository(OptionRepository::class);

            /** @var ArrayCollection $options */
            [$null, $options] = $optionRepo->getGroupsAndOptionsForAddOn($addOn->addon_id);

            $hasOptions = ($options->count() > 0);
 
Last edited:
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.14).

Change log:
Make the add-on controls menu open faster on sites with many templates, phrases or options
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom