jDownloads Support Forum

Older Versions => jDownloads 3.2 (Support ended) => Bugs => Topic started by: dr236 on 11.05.2016 00:42:24

Title: Suggested patch for jdownloadshelper.php in admin - [Fixed in 3.2.45]
Post by: dr236 on 11.05.2016 00:42:24
When JDownloads checks for new directories within its download area (and automatically creates corresponding categories), the helper method searchdir() within administrator/components/com_jdownloads/helpers/jdownloadshelper.php runs
natcasesort($dirlist)
so the directory list is nicely sorted.
Unfortunately, this has no real effect, as natcasesort preserves the key=>value association of the array, and all subsequent loops through $dirlist use keys 0..count($dirlist)-1.
Something like this (trivial) patch
--------------------
--- jdownloadshelper.php.orig   2016-05-10 22:02:05.529879084 +0000
+++ jdownloadshelper.php    2016-05-10 22:22:01.212591241 +0000
@@ -1898,7 +1898,8 @@
            closedir ( $handle ) ;
        }
        if ( $d == 0 ) {
-           natcasesort ( $dirlist ) ;
+           natcasesort($dirlist);
+           $dirlist = array_values($dirlist);
        }
        return ( $dirlist ) ;
    }
--------------------

fixes this for me.

Thanks,
David
Title: Re: Suggested patch for jdownloadshelper.php in admin
Post by: Arno on 22.05.2016 11:44:56
Hi David,
thanks for the fix. ;)