From a489f20f17b46f92617d6272242e49146ab4c2ac Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 24 Nov 2020 22:28:46 +0800 Subject: [PATCH] MDL-69145 core: Set the default filterset join type to ALL * Plus minor PHPDoc type fix for the JOINTYPE_DEFAULT constants --- lib/table/classes/local/filter/filter.php | 2 +- lib/table/classes/local/filter/filterset.php | 9 ++++++--- lib/upgrade.txt | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/table/classes/local/filter/filter.php b/lib/table/classes/local/filter/filter.php index eda6039d6e3..2c9b94bcc5a 100644 --- a/lib/table/classes/local/filter/filter.php +++ b/lib/table/classes/local/filter/filter.php @@ -41,7 +41,7 @@ use Iterator; */ class filter implements Countable, Iterator, JsonSerializable { - /** @var in The default filter type (ANY) */ + /** @var int The default filter type (ANY) */ const JOINTYPE_DEFAULT = 1; /** @var int None of the following match */ diff --git a/lib/table/classes/local/filter/filterset.php b/lib/table/classes/local/filter/filterset.php index 0afddeb4557..be86f881a18 100644 --- a/lib/table/classes/local/filter/filterset.php +++ b/lib/table/classes/local/filter/filterset.php @@ -40,8 +40,8 @@ use moodle_exception; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class filterset implements JsonSerializable { - /** @var in The default filter type (ANY) */ - const JOINTYPE_DEFAULT = 1; + /** @var int The default filter type (ALL) */ + const JOINTYPE_DEFAULT = 2; /** @var int None of the following match */ const JOINTYPE_NONE = 0; @@ -53,7 +53,7 @@ abstract class filterset implements JsonSerializable { const JOINTYPE_ALL = 2; /** @var int The join type currently in use */ - protected $jointype = self::JOINTYPE_DEFAULT; + protected $jointype = null; /** @var array The list of combined filter types */ protected $filtertypes = null; @@ -90,6 +90,9 @@ abstract class filterset implements JsonSerializable { * @return int */ public function get_join_type(): int { + if ($this->jointype === null) { + $this->jointype = self::JOINTYPE_DEFAULT; + } return $this->jointype; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 3cb62ad57a8..d270501d348 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -7,6 +7,8 @@ information provided here is intended especially for developers. * Final deprecation i_dock_block() in behat_deprecated.php * Final deprecation of get_courses_page. Function has been removed and core_course_category::get_courses() should be used instead. +* \core_table\local\filter\filterset::JOINTYPE_DEFAULT is being changed from 1 (ANY) to 2 (ALL). Filterset implementations + can override the default filterset join type by overriding \core_table\local\filter\filterset::get_join_type() instead. === 3.10 === * PHPUnit has been upgraded to 8.5. That comes with a few changes: -- 2.43.0