backdrop-contrib / filebrowser

The FileBrowser module displays contents of a given directory as a node on your Backdrop site - do not use together with Filebrowser AJAX module
GNU General Public License v2.0
0 stars 3 forks source link

Issue 2 filebrowser.theme.inc uses deprecated function create_function() #4

Closed nattywebdev closed 10 months ago

nattywebdev commented 10 months ago

Remove create_function(); Replace inline style for file/folder icon with class 'icon'

This fixes issue 2 related to deprecated php function create_function for php later than 7.2. Taken from patches provided for Drupal version of the module and adapted for Backdrop - see: https://www.drupal.org/project/filebrowser/issues/3061756

Also addresses separate issue related to display of file/folder icons: containing table cell (td) had width set as % and this is replaced by a class added to the cell.

nattywebdev commented 10 months ago

Line 262 now corrected.

nattywebdev commented 10 months ago

When showing a list of files and/or folders, clicking on any of the headings to sort doesn't work correctly. The display order changes, but it is hard to see what the order is - it's certainly not (say) alphabetical order of file or folder names. Same for Size and Date columns.

This is not a problem in the unpatched version, so the cause is my fix. I'd value any insight into the cause by @argiepiano ...

nattywebdev commented 10 months ago

Patch submitted as https://github.com/backdrop-contrib/filebrowser/pull/4

argiepiano commented 10 months ago

@nattywebdev it looks like your patch changes the assignment of $a and $b, which are used for comparison:

This is true for $b as well. While I haven't tried this myself, see if this solves your problem:

            $sorter = function ($a, $b) use ($field) {
              $a = isset($a[$field]) ? $a[$field] : 0;
              $b = isset($b[$field]) ? $b[$field] : 0;
              return $a-$b;
            };

and

            $sorter = function ($a, $b) use ($field) {
              $a = isset($a[$field]) ? $a[$field]  : '';
              $b = isset($b[$field]) ? $b[$field]: '';
              return -strcmp(backdrop_strtolower($a), backdrop_strtolower($b));
            };
nattywebdev commented 10 months ago

I've made those changes and now the sorting works correctly. I've created another PR - or should it be an update to this one?

argiepiano commented 10 months ago

@nattywebdev it's better to keep pushing changes to the same PR rather than open a new PR.

At this point this is fine - you can go ahead and close this PR in favor of #6

argiepiano commented 10 months ago

Closing this in favor of #6