Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordizzy <diosmosis@users.noreply.github.com>2022-04-04 19:35:22 +0300
committerGitHub <noreply@github.com>2022-04-04 19:35:22 +0300
commitfaf6e2704249ca36a5df910f959ed3e912a6731a (patch)
treefa3013bb0ae1fa72a7c2fe8a8778bd10d547d8bf
parentdd5b4ffbb9fe1d0f30ec2ab54112d475923e0006 (diff)
Try to reduce failed cache write random UI test failures (#19040)
* try to avoid random filesystem cache write failure during UI tests by retrying * update ui-test.php * forgot return
-rw-r--r--config/environment/ui-test.php25
-rw-r--r--config/global.php2
-rw-r--r--core/Twig.php4
3 files changed, 29 insertions, 2 deletions
diff --git a/config/environment/ui-test.php b/config/environment/ui-test.php
index 49126b20b6..9373ffb8b4 100644
--- a/config/environment/ui-test.php
+++ b/config/environment/ui-test.php
@@ -10,6 +10,31 @@ return array(
'tests.ui.url_normalizer_blacklist.api' => array(),
'tests.ui.url_normalizer_blacklist.controller' => array(),
+ 'twig.cache' => function (\Psr\Container\ContainerInterface $container) {
+ $templatesPath = $container->get('path.tmp.templates');
+ return new class($templatesPath) extends \Twig\Cache\FilesystemCache {
+ public function write(string $key, string $content): void
+ {
+ $retryCount = 3;
+
+ $attempts = 0;
+ while ($attempts < $retryCount) {
+ try {
+ parent::write($key, $content);
+ return;
+ } catch (\Exception $ex) {
+ if (!preg_match('/^Failed to write cache file/', $ex->getMessage())) {
+ throw $ex;
+ }
+
+ usleep(50);
+ ++$attempts;
+ }
+ }
+ }
+ };
+ },
+
'Piwik\Config' => \DI\decorate(function (\Piwik\Config $config) {
$config->General['cors_domains'][] = '*';
$config->General['trusted_hosts'][] = '127.0.0.1';
diff --git a/config/global.php b/config/global.php
index 1e43a2e479..d93adad66f 100644
--- a/config/global.php
+++ b/config/global.php
@@ -35,6 +35,8 @@ return array(
'view.clearcompiledtemplates.enable' => true,
+ 'twig.cache' => DI\string('path.tmp.templates'),
+
'Matomo\Cache\Eager' => function (ContainerInterface $c) {
$backend = $c->get('Matomo\Cache\Backend');
$cacheId = $c->get('cache.eager.cache_id');
diff --git a/core/Twig.php b/core/Twig.php
index abf3549af2..5bbf10eaaa 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -134,13 +134,13 @@ class Twig
$chainLoader = new ChainLoader($loaders);
// Create new Twig Environment and set cache dir
- $templatesCompiledPath = StaticContainer::get('path.tmp.templates');
+ $cache = StaticContainer::get('twig.cache');
$this->twig = new Environment($chainLoader,
array(
'debug' => true, // to use {{ dump(var) }} in twig templates
'strict_variables' => true, // throw an exception if variables are invalid
- 'cache' => $templatesCompiledPath,
+ 'cache' => $cache,
)
);
$this->twig->addExtension(new DebugExtension());