Skip to content

Commit

Permalink
Merge branch 'MDL-70014' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Apr 4, 2022
2 parents 37f37a4 + fa47604 commit 8db56ae
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions admin/tool/customlang/locallib.php
Expand Up @@ -36,7 +36,7 @@ class tool_customlang_utils {
* Rough number of strings that are being processed during a full checkout.
* This is used to estimate the progress of the checkout.
*/
const ROUGH_NUMBER_OF_STRINGS = 16500;
const ROUGH_NUMBER_OF_STRINGS = 32000;

/** @var array cache of {@link self::list_components()} results */
private static $components = null;
Expand Down Expand Up @@ -91,9 +91,22 @@ public static function list_components() {
public static function checkout($lang, progress_bar $progressbar = null) {
global $DB;

// For behat executions we are going to load only a few components in the
// language customisation structures. Using the whole "en" langpack is
// too much slow (leads to Selenium 30s timeouts, especially on slow
// environments) and we don't really need the whole thing for tests. So,
// apart from escaping from the timeouts, we are also saving some good minutes
// in tests. See MDL-70014 and linked issues for more info.
$behatneeded = ['core', 'core_langconfig', 'tool_customlang'];

// make sure that all components are registered
$current = $DB->get_records('tool_customlang_components', null, 'name', 'name,version,id');
foreach (self::list_components() as $component) {
// Filter out unwanted components when running behat.
if (defined('BEHAT_SITE_RUNNING') && !in_array($component, $behatneeded)) {
continue;
}

if (empty($current[$component])) {
$record = new stdclass();
$record->name = $component;
Expand All @@ -103,7 +116,7 @@ public static function checkout($lang, progress_bar $progressbar = null) {
$record->version = $version;
}
$DB->insert_record('tool_customlang_components', $record);
} elseif ($version = get_component_version($component)) {
} else if ($version = get_component_version($component)) {
if (is_null($current[$component]->version) or ($version > $current[$component]->version)) {
$DB->set_field('tool_customlang_components', 'version', $version, array('id' => $current[$component]->id));
}
Expand Down

0 comments on commit 8db56ae

Please sign in to comment.