From 83128d1bf9285f5473366116be87af6576e82c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Sun, 1 Oct 2023 14:19:01 +0200 Subject: [PATCH] Bugfix: Omit PHP deprecation warnings on PHP 8.2, solves #411 --- CHANGES.md | 1 + classes/table/flavours_overview.php | 10 ++++++++++ classes/table/smartmenus_items.php | 15 +++++++++++++++ classes/table/smartmenus_menus.php | 10 ++++++++++ layout/includes/blockregions.php | 5 +++++ smartmenus/menulib.php | 14 +++++++------- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9eea7583cfc..74a8859309d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2023-10-01 - Bugfix: Omit PHP deprecation warnings on PHP 8.2, solves #411. * 2023-10-01 - Test: Run Moodle Plugin CI with PHP 8.2 as well. * 2023-10-01 - Bugfix: Smart menus did not support multilanguage filters, solves #376. * 2023-09-28 - Release: Make sure that Smart Menu SCSS does not affect installations which do not use smart menus, solves #380. diff --git a/classes/table/flavours_overview.php b/classes/table/flavours_overview.php index b8f9eea3d54..cd7367dfe9f 100644 --- a/classes/table/flavours_overview.php +++ b/classes/table/flavours_overview.php @@ -42,6 +42,16 @@ */ class flavours_overview extends \table_sql { + /** + * @var int $count Flavours count. + */ + private $count; + + /** + * @var int $totalflavours Total flavours count. + */ + private $totalflavours; + /** * Setup table. * diff --git a/classes/table/smartmenus_items.php b/classes/table/smartmenus_items.php index 5d6816ee2e9..e862f95041a 100644 --- a/classes/table/smartmenus_items.php +++ b/classes/table/smartmenus_items.php @@ -38,6 +38,21 @@ */ class smartmenus_items extends \table_sql { + /** + * @var int $count Smart menu items count. + */ + private $count; + + /** + * @var int $totalmenuitems Total menu items count. + */ + private $totalmenuitems; + + /** + * @var int $menuid Menu ID. + */ + private $menuid; + /** * Setup table. * diff --git a/classes/table/smartmenus_menus.php b/classes/table/smartmenus_menus.php index 264b690268c..d804952ec73 100644 --- a/classes/table/smartmenus_menus.php +++ b/classes/table/smartmenus_menus.php @@ -38,6 +38,16 @@ */ class smartmenus_menus extends \table_sql { + /** + * @var int $count Smart menu menus count. + */ + private $count; + + /** + * @var int $totalmenus Total menu count. + */ + private $totalmenus; + /** * Setup table. * diff --git a/layout/includes/blockregions.php b/layout/includes/blockregions.php index 1ebaa48e2bf..8c7fd4b39fc 100644 --- a/layout/includes/blockregions.php +++ b/layout/includes/blockregions.php @@ -39,6 +39,11 @@ */ class additionalregions { + /** + * @var array $regions List of page regions. + */ + private $regions; + /** * Constructor. * Get the all regions in theme_boost_union_get_additional_regions function. diff --git a/smartmenus/menulib.php b/smartmenus/menulib.php index e790ea5c119..a3f59410907 100644 --- a/smartmenus/menulib.php +++ b/smartmenus/menulib.php @@ -443,7 +443,7 @@ public static function purge_cache_session_cohort(int $cohortid, int $userid) { if ($menus = self::find_condition_used_menus($cohortid)) { // Remove the menus cache for the user. $menus = array_column($menus, 'id'); - array_walk($menus, ['self', 'remove_user_cachemenu'], $userid); + array_walk($menus, [self::class, 'remove_user_cachemenu'], $userid); } if ($items = self::find_condition_used_menuitems($cohortid)) { @@ -451,8 +451,8 @@ public static function purge_cache_session_cohort(int $cohortid, int $userid) { $menus = array_unique(array_column($items, 'menu')); $items = array_column($items, 'id'); // Remove the menus and item cache for the user. - array_walk($menus, ['self', 'remove_user_cachemenu'], $userid); - array_walk($items, ['self', 'remove_user_cacheitem'], $userid); + array_walk($menus, [self::class, 'remove_user_cachemenu'], $userid); + array_walk($items, [self::class, 'remove_user_cacheitem'], $userid); } } @@ -472,7 +472,7 @@ public static function purge_cache_session_roles(int $roleid, int $userid) { if ($menus = self::find_condition_used_menus($roleid, 'roles')) { // Remove the menus cache for the user. $menus = array_column($menus, 'id'); - array_walk($menus, ['self', 'remove_user_cachemenu'], $userid); + array_walk($menus, [self::class, 'remove_user_cachemenu'], $userid); } if ($items = self::find_condition_used_menuitems($roleid, 'roles')) { @@ -480,8 +480,8 @@ public static function purge_cache_session_roles(int $roleid, int $userid) { $menus = array_unique(array_column($items, 'menu')); $items = array_column($items, 'id'); // Remove the menus and item cache for the user. - array_walk($menus, ['self', 'remove_user_cachemenu'], $userid); - array_walk($items, ['self', 'remove_user_cacheitem'], $userid); + array_walk($menus, [self::class, 'remove_user_cachemenu'], $userid); + array_walk($items, [self::class, 'remove_user_cacheitem'], $userid); } } @@ -497,7 +497,7 @@ public static function purge_cache_dynamic_courseitems() { // List of items to purge. $items = array_column($items, 'id'); // Remove the menus items for the user. - array_walk($items, ['self', 'purge_item_cache']); + array_walk($items, [self::class, 'purge_item_cache']); } }