Fixed Admin search might show link to unreachable option

Kirby

Well-known member
Affected version
2.3.0
PHP:
public function actionView(ParameterBag $params)
{
    $option = $this->assertOptionExists($params['option_id']);
    $relation = $option->Relations->first();
    $group = $relation ? $relation->OptionGroup : null;

    return $this->redirect(
        $group ? $this->buildLink('options/groups', $group) . '#' . $option->option_id : $this->buildLink('options')
    );
}

If the option is shown in multiple groups and the first group belongs to an Add-on that is disabled only an error will be displayed although the option might still be accessible via other groups:
1721654130608.webp

Suggested Fix
Check the relations if the Add-on the group belogs to is enabled until one is found that is enabled (or all groups have been checked) before redirecting.

Code:
--- src/XF/Admin/Controller/OptionController.php    Mon Jul 22 15:23:17 2024
+++ src/XF/Admin/Controller/OptionController.php    Mon Jul 22 15:26:30 2024
@@ -412,3 +412,9 @@
 
-        $relation = $option->Relations->first();
+        foreach ($option->Relations as $relation)
+        {
+            if (!$relation->OptionGroup->AddOn || !$relation->OptionGroup->AddOn->active)
+            {
+                continue;
+            }
+        }
         $group = $relation ? $relation->OptionGroup : null;
 
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.1).

Change log:
Redirect to the first active option group when viewing an option
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom