diff --git a/admin/tool/customlang/locallib.php b/admin/tool/customlang/locallib.php index acdeb5356e7..2e5df0e84e7 100644 --- a/admin/tool/customlang/locallib.php +++ b/admin/tool/customlang/locallib.php @@ -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 = 30000; /** @var array cache of {@link self::list_components()} results */ private static $components = null; @@ -91,9 +91,22 @@ class tool_customlang_utils { 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; @@ -103,7 +116,7 @@ class tool_customlang_utils { $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)); }