Skip to content

Conversation

@nattywebdev
Copy link

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 nattywebdev marked this pull request as draft November 27, 2023 14:29
…n() (correction)

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.

This is a corrected fix - first attempt introduced a typo on line 262
@nattywebdev nattywebdev marked this pull request as ready for review November 27, 2023 14:45
@nattywebdev
Copy link
Author

Line 262 now corrected.

@nattywebdev
Copy link
Author

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
Copy link
Author

Patch submitted as
#4

  • although subsequent testing shows this doesn't allow correct sorting.

@argiepiano
Copy link

argiepiano commented Nov 28, 2023

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

  • Original: $a receives the value of $a[$field], or 0 if it's not set
  • Your version: $a receives the value of $a->$field or 0 if it's not set. Since $a is an array (not an object), this will result in the new $a being assigned 0 always.

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
Copy link
Author

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
Copy link

@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
Copy link

Closing this in favor of #6

@argiepiano argiepiano closed this Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants