codefog / contao-news_categories

Extend the Contao news module with categories
MIT License
31 stars 25 forks source link

5.3.0 Cannot open filter category + one more error #256

Closed grashalm4u closed 8 months ago

grashalm4u commented 8 months ago

Hello Kamill,

I've been using your extension contao-news_categories for a long time and I'm very happy that it exists. Thank you for that! Recently I've been using Contao 5.3.0, your extension in version 4.0.3 with PHP 8.2.13. I noticed the following things (errors?):

1) When I select a filter category in the frontend, I get the following error code in debug mode:

vendor/codefog/contao-news_categories/src/FrontendModule/NewsModule.php:235 My site then also displays an error page in the frontend.

2) The template nav_newscategories inserts numerous spaces in front of the respective category in the string that "href" creates.

You can see error 1 if you go to my site: https://die-schreibmaus.de/meine-texte.html click on one of the two green filter buttons and then make a selection in the pull-down menu.

It would be great if you could take a look soon.

The schreibmaus Lothar sends you kind regards

fritzmg commented 8 months ago

You did not post the actual error ;) Also use the debug mode and post the complete stack trace.

grashalm4u commented 8 months ago

These are the error lines in var/logs:

[2024-02-19T12:59:15.218870+01:00] request.INFO: Matched route "tl_page.618". {"route":"tl_page.618","route_parameters":{"_token_check":true,"_controller":"Contao\FrontendIndex::renderPage","_scope":"frontend","_locale":"de","_format":"html","_canonical_route":"tl_page.618","parameters":"/category/schoenes","pageModel":{"Contao\PageModel":[]},"_route":"tl_page.618","_route_object":{"Contao\CoreBundle\Routing\Page\PageRoute":[]}},"request_uri":"https://die-schreibmaus.de/meine-texte/category/schoenes.html","method":"GET"} {"request_uri":"https://die-schreibmaus.de/meine-texte/category/schoenes.html","request_method":"GET"} [2024-02-19T12:59:16.054673+01:00] request.CRITICAL: Uncaught PHP Exception TypeError: "array_merge(): Argument #1 must be of type array, int given" at NewsModule.php line 235 {"exception":"[object] (TypeError(code: 0): array_merge(): Argument #1 must be of type array, int given at /www/htdocs/w007154e/contao-y/vendor/codefog/contao-news_categories/src/FrontendModule/NewsModule.php:235)"} {"request_uri":"https://die-schreibmaus.de/meine-texte/category/schoenes.html","request_method":"GET"} [2024-02-19T12:59:16.085890+01:00] messenger.INFO: Sending message Contao\CoreBundle\Messenger\Message\SearchIndexMessage with contao_prio_low sender using Contao\CoreBundle\Messenger\Transport\AutoFallbackTransport {"class":"Contao\CoreBundle\Messenger\Message\SearchIndexMessage","alias":"contao_prio_low","sender":"Contao\CoreBundle\Messenger\Transport\AutoFallbackTransport"} {"request_uri":"https://die-schreibmaus.de/meine-texte/category/schoenes.html","request_method":"GET"} [2024-02-19T12:59:16.086141+01:00] messenger.INFO: Received message Contao\CoreBundle\Messenger\Message\SearchIndexMessage {"class":"Contao\CoreBundle\Messenger\Message\SearchIndexMessage"} {"request_uri":"https://die-schreibmaus.de/meine-texte/category/schoenes.html","request_method":"GET"} [2024-02-19T12:59:16.087414+01:00] messenger.INFO: Message Contao\CoreBundle\Messenger\Message\SearchIndexMessage handled by Contao\CoreBundle\Messenger\MessageHandler\SearchIndexMessageHandler::invoke {"class":"Contao\CoreBundle\Messenger\Message\SearchIndexMessage","handler":"Contao\CoreBundle\Messenger\MessageHandler\SearchIndexMessageHandler::invoke"} {"request_uri":"https://die-schreibmaus.de/meine-texte/category/schoenes.html","request_method":"GET"}

And this is the content from stack trace:

TypeError: array_merge(): Argument #1 must be of type array, int given

at vendor/codefog/contao-news_categories/src/FrontendModule/NewsModule.php:235 at array_merge(1, '', 1708344240, '', 1708344240) (vendor/codefog/contao-news_categories/src/FrontendModule/NewsModule.php:235) at Codefog\NewsCategoriesBundle\FrontendModule\NewsModule->getInactiveCategories(array(72, 1, 2, 3, 14, 15, 16, 17, 18, 19, 36, 21, 22, 23, 6, 7, 8, 9, 10, 11, 12, 13, 71, 67, 66, 65, 26, 24, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64)) (vendor/codefog/contao-news_categories/src/FrontendModule/CumulativeFilterModule.php:54) at Codefog\NewsCategoriesBundle\FrontendModule\CumulativeFilterModule->compile() (vendor/contao/core-bundle/contao/modules/Module.php:213) at Contao\Module->generate() (vendor/codefog/contao-news_categories/src/FrontendModule/NewsModule.php:106) at Codefog\NewsCategoriesBundle\FrontendModule\NewsModule->generate() (vendor/contao/core-bundle/contao/library/Contao/Controller.php:413) at Contao\Controller::getFrontendModule(object(ModuleModel), 'main') (vendor/contao/core-bundle/contao/elements/ContentModule.php:59) at Contao\ContentModule->generate() (vendor/contao/core-bundle/contao/library/Contao/Controller.php:604) at Contao\Controller::getContentElement(object(ContentModel), 'main') (vendor/contao/core-bundle/contao/modules/ModuleArticle.php:191) at Contao\ModuleArticle->compile() (vendor/contao/core-bundle/contao/modules/Module.php:213) at Contao\Module->generate() (vendor/contao/core-bundle/contao/modules/ModuleArticle.php:69) at Contao\ModuleArticle->generate(false) (vendor/contao/core-bundle/contao/library/Contao/Controller.php:499) at Contao\Controller::getArticle(object(ArticleModel), false, false, 'main') (vendor/contao/core-bundle/contao/library/Contao/Controller.php:364) at Contao\Controller::getFrontendModule('0', 'main') (vendor/contao/core-bundle/contao/pages/PageRegular.php:171) at Contao\PageRegular->prepare(object(PageModel)) (vendor/contao/core-bundle/contao/pages/PageRegular.php:46) at Contao\PageRegular->getResponse(object(PageModel), true) (vendor/contao/core-bundle/contao/controllers/FrontendIndex.php:66) at Contao\FrontendIndex->renderPage(object(PageModel)) (vendor/symfony/http-kernel/HttpKernel.php:181) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)

aschempp commented 8 months ago

The error should be fixed in 4395d82476e156542f03fd4a8338cbacce48fb26 (version 4.0.4).

I don't understand the href problem, but please create a separate issue for that with more explanation if it still exists.

grashalm4u commented 8 months ago

Hi Andreas,

thanks for the quick revision! I can now select one or more filters and the active filters are listed, but selecting the filter categories has no effect on the display of news titles. Either all news titles are displayed, or none at all.

I also tested the whole thing again in a clean installation, but the list of news titles displayed always remains the same, regardless of which filters are activated. Is this still a bug in the current version 4.0.4, or am I doing something wrong?

Unfortunately I don't get any error message at all.

By the way, the incorrect display with several spaces in the generated link no longer appears since I installed version 4.0.4. This makes mistake number 2 from my last post unnecessary...

aschempp commented 8 months ago

You're welcome. Unfortunately, I was able to spot the code error by just reading the code. But I don't have a setup to reproduce the new error. If you could investigate that in the code (or have someone do that for you), we would be happy if you find the bug.

grashalm4u commented 8 months ago

Where exactly do I have to look? In the code of the template in question?