Skip to content

Commit 70fee2c

Browse files
georgmaisseribernhardf
authored andcommitted
Improvement: Better sorting test if it's an associative array
1 parent ee955c5 commit 70fee2c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

classes/output/table.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,16 +760,18 @@ public function return_sort_columns(array $sortcolumns) {
760760

761761
global $SESSION;
762762

763-
if (empty($this->wbtable->sortablecolumns )) {
763+
if (empty($this->wbtable->sortablecolumns)) {
764764
return null;
765765
}
766766

767+
$isassociative = array_keys($this->wbtable->sortablecolumns) !== range(0, count($this->wbtable->sortablecolumns) - 1);
768+
767769
$sortarray['options'] = [];
768770
foreach ($this->wbtable->sortablecolumns as $key => $value) {
769771

770772
// If we have an assoziative array, we have localized values.
771773
// Else, we need to use the same value twice.
772-
if (!isset($this->wbtable->columns[$key])) {
774+
if (!$isassociative) {
773775
$key = $value;
774776
}
775777

0 commit comments

Comments
 (0)