[6.1] [webservices] use logic and when filter multiple tag values
Pull Request for Issue #46241 .
Summary of Changes
This change adds support for a tag_mode filter to the Articles list in com_content so callers can choose whether tag filtering should use OR (any) or AND (all) semantics. It also exposes the new filter via the API controller.
What this does
- Adds a new model state key filter.tag_mode (default: "any") to ArticlesModel.
- Implements "all" tag mode: when tag_mode=all and multiple tag IDs are provided, an article must have all of the specified tags to be included (AND semantics).
- Preserves the existing behavior as the default: tag_mode=any (OR semantics).
- Exposes the tag_mode parameter in the API controller (ArticlesController::displayList) and cleans input with the request filter.
Testing Instructions
GET api/index.php/v1/content/articles?filter[tag][]=2&filter[tag][]=3&filter[tag_mode]=all
Manual tests performed for:
- Single tag with default behavior (any)
- Multiple tags with tag_mode=any (OR)
- Multiple tags with tag_mode=all (AND)
- Missing/invalid tag_mode falling back to default
Actual result BEFORE applying this Pull Request
only logic OR
Expected result AFTER applying this Pull Request
Adds logic AND
Link to documentations
Please select:
-
[ ] Documentation link for docs.joomla.org:
-
[ ] No documentation changes for docs.joomla.org needed
-
[ ] Pull Request link for manual.joomla.org:
-
[ ] No documentation changes for manual.joomla.org needed
I tried to test this PR but got a 500 error response. I am an API novice so it could be something to do with my set up. This is my stack trace:
{"errors":[{"code":500,"title":"Internal server error","detail":"RuntimeException: Unable to load renderer class module in /Users/ceford/Sites/joomla-cms6/libraries/src/Document/Factory.php:101\nStack trace:\n #0 /Users/ceford/Sites/joomla-cms6/libraries/src/Document/Document.php(1128): Joomla\CMS\Document\Factory->createRenderer(Object(Joomla\CMS\Document\JsonapiDocument), 'module')\n #1 /Users/ceford/Sites/joomla-cms6/plugins/content/loadmodule/src/Extension/LoadModule.php(223): Joomla\CMS\Document\Document->loadRenderer('module')\n #2 /Users/ceford/Sites/joomla-cms6/plugins/content/loadmodule/src/Extension/LoadModule.php(154): Joomla\Plugin\Content\LoadModule\Extension\LoadModule->loadModule('tags_similar', 'Similar Tags Mo...', 'html5')\n #3 /Users/ceford/Sites/joomla-cms6/libraries/vendor/joomla/event/src/Dispatcher.php(454): Joomla\Plugin\Content\LoadModule\Extension\LoadModule->onContentPrepare(Object(Joomla\CMS\Event\Content\ContentPrepareEvent))\n #4 /Users/ceford/Sites/joomla-cms6/libraries/src/Application/EventAware.php(111): Joomla\Event\Dispatcher->dispatch('onContentPrepar...', Object(Joomla\CMS\Event\Content\ContentPrepareEvent))\n #5 /Users/ceford/Sites/joomla-cms6/api/components/com_content/src/View/Articles/JsonapiView.php(200): Joomla\CMS\Application\WebApplication->triggerEvent('onContentPrepar...', Array)\n #6 /Users/ceford/Sites/joomla-cms6/libraries/src/MVC/View/JsonApiView.php(127): Joomla\Component\Content\Api\View\Articles\JsonapiView->prepareItem(Object(stdClass))\n #7 /Users/ceford/Sites/joomla-cms6/api/components/com_content/src/View/Articles/JsonapiView.php(153): Joomla\CMS\MVC\View\JsonApiView->displayList()\n #8 /Users/ceford/Sites/joomla-cms6/libraries/src/MVC/Controller/ApiController.php(269): Joomla\Component\Content\Api\View\Articles\JsonapiView->displayList()\n #9 /Users/ceford/Sites/joomla-cms6/api/components/com_content/src/Controller/ArticlesController.php(107): Joomla\CMS\MVC\Controller\ApiController->displayList()\n #10 /Users/ceford/Sites/joomla-cms6/libraries/src/MVC/Controller/BaseController.php(730): Joomla\Component\Content\Api\Controller\ArticlesController->displayList()\n #11 /Users/ceford/Sites/joomla-cms6/libraries/src/Dispatcher/ApiDispatcher.php(61): Joomla\CMS\MVC\Controller\BaseController->execute('displaylist')\n #12 /Users/ceford/Sites/joomla-cms6/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\ApiDispatcher->dispatch()\n #13 /Users/ceford/Sites/joomla-cms6/libraries/src/Application/ApiApplication.php(433): Joomla\CMS\Component\ComponentHelper::renderComponent('com_content')\n #14 /Users/ceford/Sites/joomla-cms6/libraries/src/Application/ApiApplication.php(116): Joomla\CMS\Application\ApiApplication->dispatch()\n #15 /Users/ceford/Sites/joomla-cms6/libraries/src/Application/CMSApplication.php(320): Joomla\CMS\Application\ApiApplication->doExecute()\n #16 /Users/ceford/Sites/joomla-cms6/api/includes/app.php(50): Joomla\CMS\Application\CMSApplication->execute()\n #17 /Users/ceford/Sites/joomla-cms6/api/index.php(31): require_once('/Users/ceford/S...')\n #18 {main}"}]}
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46325.
do you have some {loadmoduleid xxx} or similar in one of your articles ?