mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-65033 mod_forum: Modified sort sql for cross db support
This commit is contained in:
parent
26a94308ee
commit
30513f9740
@ -217,7 +217,19 @@ class discussion_list extends db_table_vault {
|
||||
}
|
||||
}
|
||||
|
||||
$favouritesort = ($includefavourites ? ", {$this->get_favourite_alias()}.id DESC" : "");
|
||||
$favouritesort = '';
|
||||
if ($includefavourites) {
|
||||
$favalias = $this->get_favourite_alias();
|
||||
// Since we're joining on the favourite table any discussion that isn't favourited will have
|
||||
// null in the favourite columns. Nulls behave differently in the sorting for different databases.
|
||||
// We can ensure consistency between databases by explicitly deprioritising any null favourite field
|
||||
// using a case statement.
|
||||
$favouritesort = ", CASE WHEN {$favalias}.id IS NULL THEN 0 ELSE 1 END DESC";
|
||||
// After the null favourite fields are deprioritised and appear below the favourited discussions we
|
||||
// need to order the favourited discussions by id so that the most recently favourited discussions
|
||||
// appear at the top of the list.
|
||||
$favouritesort .= ", {$favalias}.id DESC";
|
||||
}
|
||||
|
||||
return "{$alias}.pinned DESC $favouritesort , {$keyfield} {$direction}";
|
||||
}
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2019040402; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2019040403; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2018112800; // Requires this Moodle version
|
||||
$plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user