Fixed InvalidArgumentException: Unknown column display_group when no display groups defined

DragonByte Tech

Well-known member
Affected version
2.1.3
In \XF\Entity\AbstractField :: setupDefaultStructure there is support for no display_groups:

PHP:
        if ($options['groups'])
        {
            $firstOption = reset($options['groups']);
            $structure->columns['display_group'] = ['type' => self::STR, 'default' => $firstOption,
                'allowedValues' => $options['groups'],
                'api' => true
            ];
        }
And yet, if you choose not to use this feature, both the findFieldsForList and getFieldCacheData functions in \XF\Repository\AbstractField will fail.

It seems silly to have to either define a single display group (making it not really an option), or having to copy those two functions just to get rid of the display_group sort.

If you don't want to make any changes to the repository, please consider adding a fallback to setupDefaultStructure perhaps like so:
PHP:
        if ($options['groups'])
        {
            $firstOption = reset($options['groups']);
            $structure->columns['display_group'] = ['type' => self::STR, 'default' => $firstOption,
                'allowedValues' => $options['groups'],
                'api' => true
            ];
        }
        else
        {
            $structure->columns['display_group'] = ['type' => self::STR, 'default' => 'default',
                'allowedValues' => ['default'],
                'api' => true
            ];
        }
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.4).

Change log:
Make \XF\Repository\AbstractField display group agnostic
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
This is still an issue in 2.1.5.

In \XF\Repository\AbstractField

This: if (empty($this->em->getEntityStructure($this->getClassIdentifier())->columns['display_group']))
Should be: if (!empty($this->em->getEntityStructure($this->getClassIdentifier())->columns['display_group']))
 
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.1.6).

Change log:
Fix incorrect logic in AbstractField for entity structures that may not support display grouping.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom