- Affected version
- 2.1.17
When the execution order for a code extension or code event listener is the same, potential nondeterministic sorting between XF installs;
If
This means the interaction between various add-ons can be non-deterministic depending on the install order, which is a very unexpected experience.
Especially as these don't match
PHP:
public function getExtensionCacheData()
{
$extensions = $this->finder('XF:ClassExtension')
->whereAddOnActive(['disableProcessing' => true])
->where('active', 1)
->order(['execute_order'])
->fetch();
...
PHP:
public function getListenerCacheData()
{
$listeners = $this->finder('XF:CodeEventListener')
->whereAddOnActive(['disableProcessing' => true])
->where('active', 1)
->order(['event_id', 'execute_order'])
->fetch();
$cache = [];
...
PHP:
public function applyModificationsToTemplate($type, $title, $template, &$status = [])
{
$modifications = $this->finder('XF:TemplateModification')
->where([
'type' => $type,
'template' => $title,
'enabled' => 1
])
->whereAddOnActive()
->order('execution_order')
->fetch();
...
If
execute_order
/execution_order
has duplicate values, what happens is the rows with duplicate values tend to be sorted by the primary id which is a proxy for install order. However the sorting by primary id isn't guaranteed, and is different across installs.This means the interaction between various add-ons can be non-deterministic depending on the install order, which is a very unexpected experience.
Especially as these don't match
findTemplateModificationsForList
, findExtensionsForList
, findListenersForList
sorting behaviour.findExtensionsForList
should probably include execution_order
in it's sort.