jDownloads Support Forum

jDownloads for Joomla 4.x and 5.x => jDownloads 4.0 => General => Topic started by: gryff on 19.09.2023 10:14:53

Title: Error 404 since version 4.0.29 for single category
Post by: gryff on 19.09.2023 10:14:53
There are two Joomla sites with jDownloads installed. One is on pure Joomla, the other one uses Helium Gantry 5. On the first site no issues were found when upgrading jDownloads from 4.0.28 to 4.0.29 and 4.0.30.
However, the second site on Gantry 5 when upgrading from 4.0.28 to 4.0.29 gives a 404 error in menu items with a link to jDownloads. When logging into frontend as superuser all menu items are available, no errors.

jDownloads 4.0.30.
PHP Built On FreeBSD webs 13.2-RELEASE-p2 FreeBSD 13.2-RELEASE-p2 GENERIC i386
Database Type mysql
Database Version 10.11.5-MariaDB
Database Collation latin1_swedish_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption None
PHP Version 8.2.9
Web Server nginx/1.24.0
WebServer to PHP Interface fpm-fcgi
Joomla! Version Joomla! 4.3.4 Stable [ Bora ] 22-August-2023 16:00 GMT
User Agent Mozilla/5.0 (X11; FreeBSD amd64; rv:109.0) Gecko/20100101 Firefox/117.0
Framework: Gantry 5
Site Theme: Helium (v5.5.16 / g5_helium)

I found the problem with the /components/com_jdownloads/src/Helper/LegacyRouter.php file. It has been updated in version 4.0.29.

4.0.30
        // Check again, as we need a link to the download overview. A link from another component would be invalid.
        if ($menuItemGiven && isset($menuItem) && $menuItem->component != 'com_jdownloads'){
            // Invalid menu item
            $menuitems = $this->router->menu->getItems(array(), array());
            foreach ($menuitems as $menuitem){
                if ($menuitem->link == 'index.php?option=com_jdownloads&view=categories'){
                    $menuItem = $this->router->menu->getItem($menuitem->id);
                    $query['Itemid'] = $menuItem->id;
                    break;
                }
            }
           
4.0.28           
        // Check again
        if ($menuItemGiven && isset($menuItem) && $menuItem->component != 'com_jdownloads'){
            $menuItemGiven = false;
            unset($query['Itemid']);

The code "//Invalid menu item" was added. When I update to 4.0.30, I replace the LegacyRouter.php file with the 4.0.28 file and the error disappears. But I don't know the purpose of this code and so I'm not sure I won't have some side issues because of this.

Can I use this solution or is there an alternative?
Title: Re: Error 404 since version 4.0.29 for single category
Post by: gryff on 28.09.2023 07:42:43
There is the same problem with version 4.0.31. I need to copy back old LegacyRouter.php (4.0.28) to resolve the problem.
Title: Re: Error 404 since version 4.0.29 for single category
Post by: Arno on 28.09.2023 08:10:55
Okay, I will check this again in the next few days. Version 4.0.32 has fixed another bug.

Edit:
I have tested it on the jDownloads test website and could not see any problem:
https://jd40.jdownloads.org/single-download-category/category/18-video

So as you say, it seems only to be a problem together with Gantry 5 framework.  ::)
Title: Re: Error 404 since version 4.0.29 for single category
Post by: gryff on 28.09.2023 10:29:44
Thank you Arno,

I would like to know the purpose of modifying LegacyRouter.php 4.0.28 so I can understand what my replacement with the old file could lead to when upgrading the jDownlods version.