mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-50408 tool_log: Extra deprecation tip
Adding a debugging message and returning alternative data to keep backwards compatibility as get_readers is a widely used function.
This commit is contained in:
parent
17abbfba1f
commit
5c73688b4a
@ -106,7 +106,40 @@ class manager implements \core\log\manager {
|
||||
if (empty($interface) || ($reader instanceof $interface)) {
|
||||
$return[$plugin] = $reader;
|
||||
}
|
||||
// TODO MDL-49291 These conditions should be removed as part of the 2nd stage deprecation.
|
||||
if ($reader instanceof \core\log\sql_internal_reader) {
|
||||
debugging('\core\log\sql_internal_reader has been deprecated in favour of \core\log\sql_internal_table_reader.' .
|
||||
' Update ' . get_class($reader) . ' to use the new interface.', DEBUG_DEVELOPER);
|
||||
} else if ($reader instanceof \core\log\sql_select_reader) {
|
||||
debugging('\core\log\sql_select_reader has been deprecated in favour of \core\log\sql_reader. Update ' .
|
||||
get_class($reader) . ' to use the new interface.', DEBUG_DEVELOPER);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO MDL-49291 This section below (until the final return) should be removed as part of the 2nd stage deprecation.
|
||||
$isselectreader = (ltrim($interface, '\\') === 'core\log\sql_select_reader');
|
||||
$isinternalreader = (ltrim($interface, '\\') === 'core\log\sql_internal_reader');
|
||||
if ($isselectreader || $isinternalreader) {
|
||||
|
||||
if ($isselectreader) {
|
||||
$alternative = '\core\log\sql_reader';
|
||||
} else {
|
||||
$alternative = '\core\log\sql_internal_table_reader';
|
||||
}
|
||||
|
||||
if (count($return) === 0) {
|
||||
// If there are no classes implementing the provided interface and the provided interface is one of
|
||||
// the deprecated ones, we return the non-deprecated alternatives. It should be safe as the new interface
|
||||
// is adding a new method but not changing the existing ones.
|
||||
debugging($interface . ' has been deprecated in favour of ' . $alternative . '. Returning ' . $alternative .
|
||||
' instances instead. Please call get_readers() using the new interface.', DEBUG_DEVELOPER);
|
||||
$return = $this->get_readers($alternative);
|
||||
} else {
|
||||
debugging($interface . ' has been deprecated in favour of ' . $alternative .
|
||||
'. Please call get_readers() using the new interface.', DEBUG_DEVELOPER);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user