[BUG]: Error 500 in admin list view: setMultiFilterQuery() generates IN () SQL syntax error when array filter state is [''] #1310

Open
opened 2026-06-01 14:04:49 +00:00 by Markus · 2 comments
Member

What Happened?

After compiling and installing my component, I went to the list view in backend to list all items I have in my component, but this throws the following error:
Call Stack

Function Location

1 () JROOT/administrator/components/com_ratebook/src/View/Entries/HtmlView.php:227
2 eloop\Component\Ratebook\Administrator\View\Entries\HtmlView->display() JROOT/libraries/src/MVC/Controller/BaseController.php:697
3 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_ratebook/src/Controller/DisplayController.php:52
4 eloop\Component\Ratebook\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730
5 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
6 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
7 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
8 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:206
9 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:320
10 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
11 require_once() JROOT/administrator/index.php:32

Steps to reproduce the Bug

Create an admin view with a field of type list (e.g. a make/brand selector) and
mark it as an array filter in JCB.
Compile the component.
Open the admin backend list view and apply a filter, then reset/clear it.
→ PHP fatal error / blank page due to SELECT ... WHERE a.myfield IN ().

Which Joomla version are you compiling in?

6.1.0

Which PHP version are you compiling in?

8.3

Which Joomla versions are you targeting?

6.1.x

Which PHP version are you targeting?

8.3

Which Web server is JCB running on?

Apache/2.4.67 (Debian)

Which Relational Database is JCB running on?

10.5.29-MariaDB-0+deb11u1 Debian 11

Which OS is JCB running on?

Debian 11

Which JCB version are you using?

Version: 6.1.5

Where in JCB did this issue occur?

Joomla Components(admin_views)

On which browsers did you encounter the issue?

Firefox

Additional Comments

I had Claud Code have a look at the situation. I'm not sure, if this is true or helpful, but this is, what it came up with:

Summary

The setMultiFilterQuery() method in Interpretation.php generates admin view model
filter code that causes a fatal SQL syntax error (IN ()) whenever an array-type
filter is reset in the backend list view.

Affected File

libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php
Method: setMultiFilterQuery() (approx. line 12368)

Root Cause

When a backend list filter is reset, Joomla stores the filter state as ['']
(array containing one empty string). ArrayHelper::check(['']) returns 1
(truthy), so the array branch is entered. The generated array_map closure
maps '' → null implicitly (neither is_numeric('') nor StringHelper::check('')
is true, and there is no else branch). There is no subsequent array_filter()
to remove these nulls and no !empty() guard before the whereIn clause.
Result: implode(',', [null]) → '' → IN () → SQL syntax error, page crashes.

Generated Code (buggy)

} elseif (VDM\Joomla\Utilities\ArrayHelper::check($_myfield)) {
    $_myfield = array_map(function ($val) use (&$db) {
        if (is_numeric($val)) { ... return (int)$val; }
        elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); }
        // no else → implicit null return for empty strings!
    }, $_myfield);
    // no array_filter, no empty() check!
    $query->where('a.myfield IN (' . implode(',', $_myfield) . ')');
}

### What Happened? After compiling and installing my component, I went to the list view in backend to list all items I have in my component, but this throws the following error: Call Stack # Function Location 1 () JROOT/administrator/components/com_ratebook/src/View/Entries/HtmlView.php:227 2 eloop\Component\Ratebook\Administrator\View\Entries\HtmlView->display() JROOT/libraries/src/MVC/Controller/BaseController.php:697 3 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_ratebook/src/Controller/DisplayController.php:52 4 eloop\Component\Ratebook\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730 5 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143 6 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361 7 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150 8 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:206 9 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:320 10 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58 11 require_once() JROOT/administrator/index.php:32 ### Steps to reproduce the Bug Create an admin view with a field of type list (e.g. a make/brand selector) and mark it as an array filter in JCB. Compile the component. Open the admin backend list view and apply a filter, then reset/clear it. → PHP fatal error / blank page due to SELECT ... WHERE a.myfield IN (). ### Which Joomla version are you compiling in? 6.1.0 ### Which PHP version are you compiling in? 8.3 ### Which Joomla versions are you targeting? 6.1.x ### Which PHP version are you targeting? 8.3 ### Which Web server is JCB running on? Apache/2.4.67 (Debian) ### Which Relational Database is JCB running on? 10.5.29-MariaDB-0+deb11u1 Debian 11 ### Which OS is JCB running on? Debian 11 ### Which JCB version are you using? Version: 6.1.5 ### Where in JCB did this issue occur? Joomla Components(admin_views) ### On which browsers did you encounter the issue? Firefox ### Additional Comments I had Claud Code have a look at the situation. I'm not sure, if this is true or helpful, but this is, what it came up with: ## Summary The `setMultiFilterQuery()` method in `Interpretation.php` generates admin view model filter code that causes a fatal SQL syntax error (`IN ()`) whenever an array-type filter is reset in the backend list view. ## Affected File `libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php` Method: `setMultiFilterQuery()` (approx. line 12368) ## Root Cause When a backend list filter is reset, Joomla stores the filter state as `['']` (array containing one empty string). `ArrayHelper::check([''])` returns `1` (truthy), so the array branch is entered. The generated `array_map` closure maps `''` → **`null`** implicitly (neither `is_numeric('')` nor `StringHelper::check('')` is true, and there is no `else` branch). There is no subsequent `array_filter()` to remove these nulls and no `!empty()` guard before the `whereIn` clause. Result: `implode(',', [null])` → `''` → `IN ()` → **SQL syntax error, page crashes**. ## Generated Code (buggy) ```php } elseif (VDM\Joomla\Utilities\ArrayHelper::check($_myfield)) { $_myfield = array_map(function ($val) use (&$db) { if (is_numeric($val)) { ... return (int)$val; } elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } // no else → implicit null return for empty strings! }, $_myfield); // no array_filter, no empty() check! $query->where('a.myfield IN (' . implode(',', $_myfield) . ')'); }
Markus added the Bug label 2026-06-01 14:04:49 +00:00
Owner

Hi @kommid,

Thank you for reporting this issue.

I have tested this on my testing system and can confirm that it is a valid bug. The problem occurs when the list field's related filter is also set as a multiple select filter.

I was able to reproduce the issue on my side by adding the list view to a component as described, and then changing the filter to multiple. When the filter is set to single, it works correctly. However, when it is set to multiple, the list view breaks.

This appears to be related to the multi-filter query handling, likely in the class responsible for setting the multi-filter query, which still needs some refactoring.

We will look into this further and provide feedback as soon as we have made progress or have a fix ready.

Thanks again for raising this.

Hi @kommid, Thank you for reporting this issue. I have tested this on my testing system and can confirm that it is a valid bug. The problem occurs when the list field's related filter is also set as a multiple select filter. I was able to reproduce the issue on my side by adding the list view to a component as described, and then changing the filter to multiple. When the filter is set to single, it works correctly. However, when it is set to multiple, the list view breaks. This appears to be related to the multi-filter query handling, likely in the class responsible for setting the multi-filter query, which still needs some refactoring. We will look into this further and provide feedback as soon as we have made progress or have a fix ready. Thanks again for raising this.
Owner

Hi @kommid this issue should be fixed now with the new v6.2.0 release. I've tested it from many different angles now and I'm not able reproduce the issue any more. Please also test it from your side as well. We can close this issue, if no further problems arise.

Hi @kommid this issue should be fixed now with the new [v6.2.0 release](https://git.vdm.dev/joomla/pkg-component-builder/releases/tag/v6.2.0). I've tested it from many different angles now and I'm not able reproduce the issue any more. Please also test it from your side as well. We can close this issue, if no further problems arise.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1310