jDownloads Support Forum

jDownloads for Joomla 4.x and 5.x => jDownloads 4.0 => Bugs! => Topic started by: mj_jdl on 27.09.2023 22:27:16

Title: Public categories not accessible in 4.0.29 /error after update to 4.0.31[SOLVED]
Post by: mj_jdl on 27.09.2023 22:27:16
Hi all,

with our main installation of Joomla! 4.3.4 + jDownloads 4.0.29 I have the problem that public download categories aren't visible when not logged in. This used to work before, e.g. here
https://www.ias-observatory.org/index.php/de/publikationen/category/4-pub
(menu item single category)
Tested updating to jDownloads 4.0.31 in our staging environment, which results in downloads no longer accessible even to logged in users and showing the error message "implode() expects at most 2 arguments, 3 given" e.g. here
https://beta.ias-observatory.org/index.php/de/publikationen

Any solutions? Thanks. (The site was migrated from Joomla! 3 to 4 some time ago via jDownloads 3.9.) Alas, the previous jDownloads releases aren't available for for back tracking.

Martin

Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: Arno on 27.09.2023 22:30:34
Hi,
please update at first to 4.0.31.
Try it then again.
Should the problem be still üpresent, activate the Joomla debug option in config and try it again. Post then the more detailed debug information here or send it me as PM. Thanks.
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 27.09.2023 22:39:51
Thanks for the quick response. beta has already been updated to 4.0.31, here's with debug output:
https://beta.ias-observatory.org/index.php/de/publikationen

     implode() expects at most 2 arguments, 3 given

Call stack
#    Function    Location
1    ()    JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397
2    implode()    JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397
3    JDownloads\Component\JDownloads\Site\Helper\CategoriesHelper->_load()    JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:186
4    JDownloads\Component\JDownloads\Site\Helper\CategoriesHelper->get()    JROOT/components/com_jdownloads/src/Model/CategoriesModel.php:221
5    JDownloads\Component\JDownloads\Site\Model\CategoriesModel->getItems()    JROOT/libraries/src/MVC/View/AbstractView.php:146
6    Joomla\CMS\MVC\View\AbstractView->get()    JROOT/components/com_jdownloads/src/View/Categories/HtmlView.php:81
7    JDownloads\Component\JDownloads\Site\View\Categories\HtmlView->display()    JROOT/libraries/src/MVC/Controller/BaseController.php:645
8    Joomla\CMS\MVC\Controller\BaseController->display()    JROOT/components/com_jdownloads/src/Controller/DisplayController.php:123
9    JDownloads\Component\JDownloads\Site\Controller\DisplayController->display()    JROOT/libraries/src/MVC/Controller/BaseController.php:678
10    Joomla\CMS\MVC\Controller\BaseController->execute()    JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
11    Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()    JROOT/components/com_jdownloads/src/Dispatcher/Dispatcher.php:60
12    JDownloads\Component\JDownloads\Site\Dispatcher\Dispatcher->dispatch()    JROOT/libraries/src/Component/ComponentHelper.php:361
13    Joomla\CMS\Component\ComponentHelper::renderComponent()    JROOT/libraries/src/Application/SiteApplication.php:208
14    Joomla\CMS\Application\SiteApplication->dispatch()    JROOT/libraries/src/Application/SiteApplication.php:249
15    Joomla\CMS\Application\SiteApplication->doExecute()    JROOT/libraries/src/Application/CMSApplication.php:293
16    Joomla\CMS\Application\CMSApplication->execute()    JROOT/includes/app.php:61
17    require_once()    JROOT/index.php:32
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 27.09.2023 22:56:41
Additional remark as this seems to be language related ... 'currentlang': the site is multi-lingual (DE, EN), but the download categories are not language specific, all set to Category Language = "Alle".
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: Arno on 28.09.2023 08:04:59
Bitte installiere die Version 4.0.32. Der Bug sollte damit behoben sein.
Danke.  :)

----------------------------------

Please install version 4.0.32. This should fix the bug.
Thank you.  :)
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 28.09.2023 09:46:13
Thanks for the quick turn-around, but now it's a different error:
https://beta.iasev.de/index.php/de/publikationen

     implode(): Argument #2 ($array) must be of type ?array, string given

Call stack
#    Function    Location
1    ()    JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397
2    implode()    JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397
3    JDownloads\Component\JDownloads\Site\Helper\CategoriesHelper->_load()    JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:186
4    JDownloads\Component\JDownloads\Site\Helper\CategoriesHelper->get()    JROOT/components/com_jdownloads/src/Model/CategoriesModel.php:221
[...]

Removing this piece of code solves both the original problem and the error:
//        if ($this->_options['currentlang'] !== 0) {
//            $subQueryCat->where(
//                $db->quoteName('cat.language')
//                . ' IN (' . implode(',', $this->_options['currentlang']));
//        }
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 28.09.2023 10:01:38
Did some debugging:
$this->_options['currentlang'] is a string "de-DE" or "en-GB"
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: dollman on 28.09.2023 11:28:31


Hi! Since Update today to 4.0.32 I have the same problem!!

implode(): Argument #2 ($array) must be of type ?array, string given

Call stack
#   Function   Location
1   ()   JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397
2   implode()   JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397
3   JDownloads\Component\JDownloads\Site\Helper\CategoriesHelper->_load()   JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:186
4   JDownloads\Component\JDownloads\Site\Helper\CategoriesHelper->get()   JROOT/components/com_jdownloads/src/Helper/RouteHelper.php:108
5   JDownloads\Component\JDownloads\Site\Helper\RouteHelper::getOtherRoute()   JROOT/plugins/content/jdownloads/jdownloads.php:1389
6   jd_file_fill_downloadok()   JROOT/plugins/content/jdownloads/jdownloads.php:546
7   jd_file_createdownload()   JROOT/plugins/content/jdownloads/jdownloads.php:272
8   jd_file_callback()   
9   preg_replace_callback()   JROOT/plugins/content/jdownloads/jdownloads.php:200
10   PlgContentJDownloads->onContentPrepare()   JROOT/libraries/src/Plugin/CMSPlugin.php:284
11   Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}()   JROOT/libraries/vendor/joomla/event/src/Dispatcher.php:486
12   Joomla\Event\Dispatcher->dispatch()   JROOT/libraries/src/MVC/View/AbstractView.php:249
13   Joomla\CMS\MVC\View\AbstractView->dispatchEvent()   JROOT/components/com_content/src/View/Article/HtmlView.php:227
14   Joomla\Component\Content\Site\View\Article\HtmlView->display()   JROOT/libraries/src/MVC/Controller/BaseController.php:645
15   Joomla\CMS\MVC\Controller\BaseController->display()   JROOT/components/com_content/src/Controller/DisplayController.php:121
16   Joomla\Component\Content\Site\Controller\DisplayController->display()   JROOT/libraries/src/MVC/Controller/BaseController.php:678
17   Joomla\CMS\MVC\Controller\BaseController->execute()   JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
18   Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()   JROOT/components/com_content/src/Dispatcher/Dispatcher.php:56
19   Joomla\Component\Content\Site\Dispatcher\Dispatcher->dispatch()   JROOT/libraries/src/Component/ComponentHelper.php:361
20   Joomla\CMS\Component\ComponentHelper::renderComponent()   JROOT/libraries/src/Application/SiteApplication.php:208
21   Joomla\CMS\Application\SiteApplication->dispatch()   JROOT/libraries/src/Application/SiteApplication.php:249
22   Joomla\CMS\Application\SiteApplication->doExecute()   JROOT/libraries/src/Application/CMSApplication.php:293
23   Joomla\CMS\Application\CMSApplication->execute()   JROOT/includes/app.php:61
24   require_once()   JROOT/index.php:32
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: ColinM on 28.09.2023 12:37:09
Hi
I confirm that as mj_jdl discovered then a temporary fix is commenting out lines 394 to 397 of JROOT/components/com_jdownloads/src/Helper/CategoriesHelper.php:397 solves the multilang associatiom problem.

//        if ($this->_options['currentlang'] !== 0) {
//            $subQueryCat->where(
//                $db->quoteName('cat.language')
//                . ' IN (' . implode(',', $this->_options['currentlang']));
//        }

Colin
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: dollman on 28.09.2023 13:26:20
Yes, this works - Thank You!
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: Arno on 28.09.2023 21:36:47
Sorry again for my mistake.  :-\
I am today on the road and not in my office. So I can not test anything today.
But I will publish in the next hour another try.  ::) :-\
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 29.09.2023 11:39:29
No problem and thanks for looking into this. To help with the debugging: in my case cat.language is "*" and currentlang is either "de-DE" or "en-GB".
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: Arno on 29.09.2023 22:47:54
Have you not tried the latest version 4.0.33?
Please test this and post here your result (with activated System - Language Filter plugin).
Thanks.
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 30.09.2023 13:06:40
Sorry, didn't notice the 33 update until now. It now "sort of" works, with a very strange phenomenon.
Staging Website https://beta.iasev.de/index.php/de/

When the menu entry "Publikationen" points to jDownloads > "Alle Kategorien anzeigen (Standard)", entry "Allgemeine Informationen" to "Einzelne Kategorie anzeigen" (public category) this works as expected. When no user is logged in, only the PUBLIC jDownloads categories are shown.
If I switch the "Publikationen" entry to point to a single category with the very same name "Publikationen" (public category), then *both* the entry "Publikationen" and "Allgemeine Informationen" throw the following error:

404 Seite nicht gefunden

Call stack
#    Function    Location
1    ()    JROOT/libraries/src/Router/Router.php:155
2    Joomla\CMS\Router\Router->parse()    JROOT/libraries/src/Application/SiteApplication.php:746
3    Joomla\CMS\Application\SiteApplication->route()    JROOT/libraries/src/Application/SiteApplication.php:232
4    Joomla\CMS\Application\SiteApplication->doExecute()    JROOT/libraries/src/Application/CMSApplication.php:293
5    Joomla\CMS\Application\CMSApplication->execute()    JROOT/includes/app.php:61
6    require_once()    JROOT/index.php:32

If I login as any user with the "Registered" access level, both links work as expected.

Currently the menu entry "Publikationen" points to Link "index.php?option=com_jdownloads&view=category&catid=4"
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 30.09.2023 13:14:21
Addendum: which BTW is the very same behavior / original problem I get on our main Website with jDownloads 4.0.29!
https://www.ias-observatory.org/index.php/de/

Here I switched "Allgemeine Informationen" to show all categories. This also works as expected and shows only the public categories when not logged in.

(System - language filter is enabled, yes)
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 30.09.2023 14:33:11
Meanwhile I'm getting closer to the core of the behavior:

- If a link to all categories "index.php?option=com_jdownloads&view=categories" is present in any of the menus with access level *PUBLIC*, then links to single public categories, e.g. "index.php?option=com_jdownloads&view=category&catid=4" will work as expected for visitors (not logged in)

See https://beta.iasev.de/index.php/de/
catid=4 points to https://beta.iasev.de/index.php/de/publikationen/category/4-pub

This works even on the /en/ version of the site, even if the all categories link isn't shown there. ;-)

And it even works when I move the all categories link to the hidden original Joomla! main menu (overridden by the lang specific main menus)!!! ;-)

- If no such link is present, the single category links fails with 404 as shown above for visitors
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: ColinM on 02.10.2023 14:16:26
Hi
The problem was resolved by Arno in jD 4.0.33
https://www.jdownloads.com/index.php/downloads/download/6-jdownloads/70-jdownloads-4.html

Colin
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 02.10.2023 15:46:40
4.0.33 is installed on beta, 4.0.29 on the main site. Both show the same strange behavior. The intermediate error in .31 was fixed, yes.
But I'm still at a loss with the original problem.
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: ColinM on 03.10.2023 15:29:19
Hi
Site seems OK but you say if you change from a jD 'List All Categories' to say  a 'Single Category' menu item the site behaves incorrectly.

Do you have another jD 'List All Categories' menu item elsewhere as jD always needs a 'List All Categories' menu item.  Usually I set this one to be a hidden menu item   (In the Link Type tab set option 'Display in Menu' to No)
Colin
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: mj_jdl on 03.10.2023 16:20:25
Thanks, yes, if there's no "list all categories" in the menu system and the current access level then "single category" will fail.
The "list all categories" menu item can be invisible, but must be enabled (green tick mark).
For members already logged in, this isn't a problem, because a separate members menu will always contain the "list all categories" item.
Ok, so for now I have that work-around. But IMHO this really is a bug in jD, isn't it?
Title: Re: Public categories not accessible in 4.0.29 / error after update to 4.0.31
Post by: ColinM on 04.10.2023 10:10:25
Hi
This is not a workaround!  jD uses the List All Categories menu item as a 'navigation aid'. A suitable message about the need for the menu item is given when jD is first installed. 
jD has been using this approach since the very early days of Joomla. No doubt if jD was started afresh today a different scheme could be used.

Colin