From b6d08ad1d7fe2e440b81bdf672e2589d25e9933b Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 11 Jun 2024 12:44:38 +0800 Subject: [PATCH] MDL-81960 core: Update namespace of progress_trace classes --- .upgradenotes/MDL-81960-2024061004043644.yml | 26 +++++++++++++++++-- lib/classes/output/progress_trace.php | 7 +++++ .../combined_progress_trace.php | 11 +++++++- .../error_log_progress_trace.php | 9 +++++++ .../html_list_progress_trace.php | 9 +++++++ .../progress_trace/html_progress_trace.php | 9 +++++++ .../progress_trace/null_progress_trace.php | 9 +++++++ .../progress_trace/progress_trace_buffer.php | 11 +++++++- .../progress_trace/text_progress_trace.php | 9 +++++++ 9 files changed, 96 insertions(+), 4 deletions(-) diff --git a/.upgradenotes/MDL-81960-2024061004043644.yml b/.upgradenotes/MDL-81960-2024061004043644.yml index 964e907be25..c371a6aff54 100644 --- a/.upgradenotes/MDL-81960-2024061004043644.yml +++ b/.upgradenotes/MDL-81960-2024061004043644.yml @@ -2,6 +2,28 @@ issueNumber: MDL-81960 notes: core: - message: >- - The `\moodle_url` class has been renamed to `\core\url` and now supports - autoloading. Existing uses are currently unaffected. + The following classes have been renamed and now support autoloading. + Existing classes are currently unaffected. + + | Old class name | New class name | + + | --- | --- | + + | `\moodle_url` | `\core\url` | + + | `\progress_trace` | `\core\output\progress_trace` | + + | `\combined_progress_trace` | `\core\output\progress_trace\combined_progress_trace` | + + | `\error_log_progress_trace` | `\core\output\progress_trace\error_log_progress_trace` | + + | `\html_list_progress_trace` | `\core\output\progress_trace\html_list_progress_trace` | + + | `\html_progress_trace` | `\core\output\progress_trace\html_progress_trace` | + + | `\null_progress_trace` | `\core\output\progress_trace\null_progress_trace` | + + | `\progress_trace_buffer` | `\core\output\progress_trace\progress_trace_buffer` | + + | `\text_progress_trace` | `\core\output\progress_trace\text_progress_trace` | type: improved diff --git a/lib/classes/output/progress_trace.php b/lib/classes/output/progress_trace.php index fdd5d5ecac1..8a590b0aebc 100644 --- a/lib/classes/output/progress_trace.php +++ b/lib/classes/output/progress_trace.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output; + /** * Progress trace class. * @@ -42,3 +44,8 @@ abstract class progress_trace { public function finished() { } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(progress_trace::class, \progress_trace::class); diff --git a/lib/classes/output/progress_trace/combined_progress_trace.php b/lib/classes/output/progress_trace/combined_progress_trace.php index 88b34839f48..7027440a473 100644 --- a/lib/classes/output/progress_trace/combined_progress_trace.php +++ b/lib/classes/output/progress_trace/combined_progress_trace.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * Special type of trace that can be used for redirecting to multiple other traces. * @@ -21,7 +25,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @package core */ -class combined_progress_trace extends progress_trace { +class combined_progress_trace extends \progress_trace { /** * Constructs a new instance. * @@ -50,3 +54,8 @@ class combined_progress_trace extends progress_trace { } } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(combined_progress_trace::class, \combined_progress_trace::class); diff --git a/lib/classes/output/progress_trace/error_log_progress_trace.php b/lib/classes/output/progress_trace/error_log_progress_trace.php index 2715864bc4d..c3f17d87da7 100644 --- a/lib/classes/output/progress_trace/error_log_progress_trace.php +++ b/lib/classes/output/progress_trace/error_log_progress_trace.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * This subclass of progress_trace outputs to error log. * @@ -41,3 +45,8 @@ class error_log_progress_trace extends progress_trace { error_log($this->prefix . str_repeat(' ', $depth) . $message); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(error_log_progress_trace::class, \error_log_progress_trace::class); diff --git a/lib/classes/output/progress_trace/html_list_progress_trace.php b/lib/classes/output/progress_trace/html_list_progress_trace.php index b110ea22ae0..4c21c79a869 100644 --- a/lib/classes/output/progress_trace/html_list_progress_trace.php +++ b/lib/classes/output/progress_trace/html_list_progress_trace.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * HTML List Progress Tree * @@ -59,3 +63,8 @@ class html_list_progress_trace extends progress_trace { } } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(html_list_progress_trace::class, \html_list_progress_trace::class); diff --git a/lib/classes/output/progress_trace/html_progress_trace.php b/lib/classes/output/progress_trace/html_progress_trace.php index d2772e0a09c..eda3587068e 100644 --- a/lib/classes/output/progress_trace/html_progress_trace.php +++ b/lib/classes/output/progress_trace/html_progress_trace.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * This subclass of progress_trace outputs as HTML. * @@ -31,3 +35,8 @@ class html_progress_trace extends progress_trace { flush(); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(html_progress_trace::class, \html_progress_trace::class); diff --git a/lib/classes/output/progress_trace/null_progress_trace.php b/lib/classes/output/progress_trace/null_progress_trace.php index 4579b5837cb..6f9af4e60ef 100644 --- a/lib/classes/output/progress_trace/null_progress_trace.php +++ b/lib/classes/output/progress_trace/null_progress_trace.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * This subclass of progress_trace does not ouput anything. * @@ -29,3 +33,8 @@ class null_progress_trace extends progress_trace { ): void { } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(null_progress_trace::class, \null_progress_trace::class); diff --git a/lib/classes/output/progress_trace/progress_trace_buffer.php b/lib/classes/output/progress_trace/progress_trace_buffer.php index 4bf56c1c7e9..dd9be00eb3a 100644 --- a/lib/classes/output/progress_trace/progress_trace_buffer.php +++ b/lib/classes/output/progress_trace/progress_trace_buffer.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * Special type of trace that can be used for catching of output of other traces. * @@ -21,7 +25,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @package core */ -class progress_trace_buffer extends progress_trace { +class progress_trace_buffer extends \progress_trace { /** @var string output buffer */ protected string $buffer = ''; @@ -83,3 +87,8 @@ class progress_trace_buffer extends progress_trace { return $this->buffer; } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(progress_trace_buffer::class, \progress_trace_buffer::class); diff --git a/lib/classes/output/progress_trace/text_progress_trace.php b/lib/classes/output/progress_trace/text_progress_trace.php index b9ed47c3962..94652ab489a 100644 --- a/lib/classes/output/progress_trace/text_progress_trace.php +++ b/lib/classes/output/progress_trace/text_progress_trace.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace core\output\progress_trace; + +use core\output\progress_trace; + /** * This subclass of progress_trace outputs to plain text. * @@ -30,3 +34,8 @@ class text_progress_trace extends progress_trace { mtrace(str_repeat(' ', $depth) . $message); } } + +// Alias this class to the old name. +// This file will be autoloaded by the legacyclasses autoload system. +// In future all uses of this class will be corrected and the legacy references will be removed. +class_alias(text_progress_trace::class, \text_progress_trace::class);