From a96488e33a449b4114c482b8e5746ddbea232945 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Tue, 9 Jul 2024 10:11:09 +0100 Subject: [PATCH] MDL-82359 Navigation: ignore navadduserpostslinks if no forum The admin setting navadduserpostslinks (default on) causes debug warnings due to missing language strings on every page while logged in if forum is uninstalled. This is not the worst problem if running without forum installed, because you can just turn off the admin setting, but it makes it impossible to run Behat tests. This change means that the option does nothing if forum is uninstalled. This is a small change just to make it work without significantly altering anything. --- lib/navigationlib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 24a175bb3214b..1721ce23bffc1 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2589,7 +2589,8 @@ protected function load_for_user($user=null, $forceforcontext=false) { } } - if (!empty($CFG->navadduserpostslinks)) { + // Only if the forum links are enabled and forum is installed... + if (!empty($CFG->navadduserpostslinks) && \core_component::get_component_directory('mod_forum') !== null) { // Add nodes for forum posts and discussions if the user can view either or both // There are no capability checks here as the content of the page is based // purely on the forums the current user has access too. @@ -5201,7 +5202,8 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr $profilenode = $mainpage->add(get_string('profile'), new moodle_url('/user/profile.php', array('id' => $user->id)), self::TYPE_SETTING, null, 'myprofile'); - if (!empty($CFG->navadduserpostslinks)) { + // Only if the forum links are enabled and forum is installed... + if (!empty($CFG->navadduserpostslinks) && \core_component::get_component_directory('mod_forum') !== null) { // Add nodes for forum posts and discussions if the user can view either or both // There are no capability checks here as the content of the page is based // purely on the forums the current user has access too.