Merge branch 'MDL-67515-311' of git://github.com/vmdef/moodle into MOODLE_311_STABLE

This commit is contained in:
Sara Arjona 2021-03-02 11:21:27 +01:00
commit 56630bd392

View file

@ -39,7 +39,7 @@ class tool_customlang_utils {
const ROUGH_NUMBER_OF_STRINGS = 16500;
/** @var array cache of {@link self::list_components()} results */
protected static $components = null;
private static $components = null;
/**
* This class can not be instantiated
@ -54,10 +54,11 @@ class tool_customlang_utils {
*/
public static function list_components() {
if (self::$components === null) {
$list['moodle'] = 'core';
$coresubsystems = core_component::get_core_subsystems();
ksort($coresubsystems); // should be but just in case
ksort($coresubsystems); // Should be but just in case.
foreach ($coresubsystems as $name => $location) {
$list[$name] = 'core_' . $name;
}
@ -74,8 +75,9 @@ class tool_customlang_utils {
}
}
}
return $list;
self::$components = $list;
}
return self::$components;
}
/**
@ -211,14 +213,18 @@ class tool_customlang_utils {
return false;
}
// get all customized strings from updated components
list($insql, $inparams) = $DB->get_in_or_equal(self::list_components());
// Get all customized strings from updated valid components.
$sql = "SELECT s.*, c.name AS component
FROM {tool_customlang} s
JOIN {tool_customlang_components} c ON s.componentid = c.id
WHERE s.lang = ?
AND (s.local IS NOT NULL OR s.modified = 1)
AND c.name $insql
ORDER BY componentid, stringid";
$strings = $DB->get_records_sql($sql, array($lang));
array_unshift($inparams, $lang);
$strings = $DB->get_records_sql($sql, $inparams);
$files = array();
foreach ($strings as $string) {
@ -336,11 +342,9 @@ EOF
* @return string|boolean filename eg 'moodle.php' or 'workshop.php', false if not found
*/
protected static function get_component_filename($component) {
if (is_null(self::$components)) {
self::$components = self::list_components();
}
$return = false;
foreach (self::$components as $legacy => $normalized) {
foreach (self::list_components() as $legacy => $normalized) {
if ($component === $normalized) {
$return = $legacy.'.php';
break;