diff --git a/blocks/classes/local/views/secondary.php b/blocks/classes/navigation/views/secondary.php
similarity index 96%
rename from blocks/classes/local/views/secondary.php
rename to blocks/classes/navigation/views/secondary.php
index c23e857a5f7..43acdadf8c8 100644
--- a/blocks/classes/local/views/secondary.php
+++ b/blocks/classes/navigation/views/secondary.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace core_block\local\views;
+namespace core_block\navigation\views;
/**
* Class secondary
diff --git a/lib/blocklib.php b/lib/blocklib.php
index 9c4f2badbfc..f6fc929087d 100644
--- a/lib/blocklib.php
+++ b/lib/blocklib.php
@@ -1684,12 +1684,20 @@ class block_manager {
* Convenience function to check whether a block is implementing a secondary nav class and return it
* initialised to the calling function
*
+ * @todo MDL-74939 Remove support for old 'local\views\secondary' class location
* @param block_base $block
* @return \core\navigation\views\secondary
*/
protected function get_secondarynav(block_base $block): \core\navigation\views\secondary {
- $class = "core_block\\local\\views\\secondary";
- if (class_exists("block_{$block->name()}\\local\\views\\secondary")) {
+ $class = "core_block\\navigation\\views\\secondary";
+ if (class_exists("block_{$block->name()}\\navigation\\views\\secondary")) {
+ $class = "block_{$block->name()}\\navigation\\views\\secondary";
+ } else if (class_exists("block_{$block->name()}\\local\\views\\secondary")) {
+ // For backwards compatibility, support the old location for this class (it was in a
+ // 'local' namespace which shouldn't be used for core APIs).
+ debugging("The class block_{$block->name()}\\local\\views\\secondary uses a deprecated " .
+ "namespace. Please move it to block_{$block->name()}\\navigation\\views\\secondary.",
+ DEBUG_DEVELOPER);
$class = "block_{$block->name()}\\local\\views\\secondary";
}
$secondarynav = new $class($this->page);
diff --git a/lib/pagelib.php b/lib/pagelib.php
index 26cc6e5f86d..04bba10aff9 100644
--- a/lib/pagelib.php
+++ b/lib/pagelib.php
@@ -867,13 +867,22 @@ class moodle_page {
/**
* Returns the secondary navigation object
+ *
+ * @todo MDL-74939 Remove support for old 'local\views\secondary' class location
* @return secondary
*/
protected function magic_get_secondarynav() {
if ($this->_secondarynav === null) {
$class = 'core\navigation\views\secondary';
// Try and load a custom class first.
- if (class_exists("mod_{$this->activityname}\\local\\views\\secondary")) {
+ if (class_exists("mod_{$this->activityname}\\navigation\\views\\secondary")) {
+ $class = "mod_{$this->activityname}\\navigation\\views\\secondary";
+ } else if (class_exists("mod_{$this->activityname}\\local\\views\\secondary")) {
+ // For backwards compatibility, support the old location for this class (it was in a
+ // 'local' namespace which shouldn't be used for core APIs).
+ debugging("The class mod_{$this->activityname}}\\local\\views\\secondary uses a deprecated " .
+ "namespace. Please move it to mod_{$this->activityname}\\navigation\\views\\secondary.",
+ DEBUG_DEVELOPER);
$class = "mod_{$this->activityname}\\local\\views\\secondary";
}
diff --git a/lib/upgrade.txt b/lib/upgrade.txt
index 89285a3313c..903b32b332b 100644
--- a/lib/upgrade.txt
+++ b/lib/upgrade.txt
@@ -12,6 +12,9 @@ information provided here is intended especially for developers.
an event exists with the given criteria (see MDL-72723 for details).
- Breaking: 3rd party log readers implementing interface sql_reader will need to implement get_events_select_exists()
* Added $strictness parameter to persistent `get_record` method, optionally allowing caller to ensure record exists
+* For plugins that override secondary navigation, the namespace for the custom secondary navigation class has
+ changed. It was (for example) mod_mymodule\local\views\secondary but is now
+ mod_mymodule\navigation\views\secondary. The old location will continue to work, but is deprecated.
=== 4.0 ===
diff --git a/mod/assign/classes/local/views/secondary.php b/mod/assign/classes/navigation/views/secondary.php
similarity index 97%
rename from mod/assign/classes/local/views/secondary.php
rename to mod/assign/classes/navigation/views/secondary.php
index 4b490964c15..e7a83770c10 100644
--- a/mod/assign/classes/local/views/secondary.php
+++ b/mod/assign/classes/navigation/views/secondary.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_assign\local\views;
+namespace mod_assign\navigation\views;
use core\navigation\views\secondary as core_secondary;
diff --git a/mod/feedback/classes/local/views/secondary.php b/mod/feedback/classes/navigation/views/secondary.php
similarity index 98%
rename from mod/feedback/classes/local/views/secondary.php
rename to mod/feedback/classes/navigation/views/secondary.php
index 2aaa9d39eeb..e61d5aef411 100644
--- a/mod/feedback/classes/local/views/secondary.php
+++ b/mod/feedback/classes/navigation/views/secondary.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_feedback\local\views;
+namespace mod_feedback\navigation\views;
use core\navigation\views\secondary as core_secondary;
use settings_navigation;
diff --git a/mod/glossary/classes/local/views/secondary.php b/mod/glossary/classes/navigation/views/secondary.php
similarity index 97%
rename from mod/glossary/classes/local/views/secondary.php
rename to mod/glossary/classes/navigation/views/secondary.php
index 83e2edd46e8..0c1b7fec585 100644
--- a/mod/glossary/classes/local/views/secondary.php
+++ b/mod/glossary/classes/navigation/views/secondary.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_glossary\local\views;
+namespace mod_glossary\navigation\views;
use core\navigation\views\secondary as core_secondary;
diff --git a/mod/label/classes/local/views/secondary.php b/mod/label/classes/navigation/views/secondary.php
similarity index 98%
rename from mod/label/classes/local/views/secondary.php
rename to mod/label/classes/navigation/views/secondary.php
index bba9e330302..64be842fd86 100644
--- a/mod/label/classes/local/views/secondary.php
+++ b/mod/label/classes/navigation/views/secondary.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_label\local\views;
+namespace mod_label\navigation\views;
use core\navigation\views\secondary as core_secondary;
use settings_navigation;
diff --git a/mod/quiz/classes/local/views/secondary.php b/mod/quiz/classes/navigation/views/secondary.php
similarity index 98%
rename from mod/quiz/classes/local/views/secondary.php
rename to mod/quiz/classes/navigation/views/secondary.php
index e9be56666a4..89a6d3f17a9 100644
--- a/mod/quiz/classes/local/views/secondary.php
+++ b/mod/quiz/classes/navigation/views/secondary.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_quiz\local\views;
+namespace mod_quiz\navigation\views;
use core\navigation\views\secondary as core_secondary;