Skip to content

Commit de729f3

Browse files
MAGETWO-58594: Static Assets deployment throws errors when redis is used for cache after PR 389
cache disabling for setup:static-content:deploy command
1 parent 4bb5467 commit de729f3

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function __construct(
9696
$this->objectManagerFactory = $objectManagerFactory;
9797
$this->validator = $validator;
9898
$this->objectManager = $objectManager;
99+
99100
parent::__construct();
100101
}
101102

@@ -415,7 +416,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
415416
}
416417
}
417418

418-
return $deployManager->deploy();
419+
try {
420+
$this->disableCache();
421+
return $deployManager->deploy();
422+
423+
} finally {
424+
$this->enableCache();
425+
}
419426
}
420427

421428
/**
@@ -476,4 +483,22 @@ private function prepareDeployableEntities($filesUtil)
476483

477484
return [$deployableLanguages, $deployableAreaThemeMap, $requestedThemes];
478485
}
486+
487+
private function disableCache()
488+
{
489+
$this->objectManager->configure([
490+
'preferences' => [
491+
\Magento\Framework\App\Cache::class => \Magento\Framework\App\Cache\Type\Dummy::class
492+
]
493+
]);
494+
}
495+
496+
private function enableCache()
497+
{
498+
$this->objectManager->configure([
499+
'preferences' => [
500+
\Magento\Framework\App\Cache::class => \Magento\Framework\App\Cache::class
501+
]
502+
]);
503+
}
479504
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\App\Cache\Type;
8+
9+
use \Magento\Framework\App\CacheInterface;
10+
11+
class Dummy implements CacheInterface
12+
{
13+
/**
14+
* Required by CacheInterface
15+
*
16+
* @return Null
17+
*/
18+
public function getFrontend()
19+
{
20+
return null;
21+
}
22+
23+
/**
24+
* Pretend to load data from cache by id
25+
*
26+
* @param string $identifier
27+
* @return null
28+
*/
29+
public function load($identifier)
30+
{
31+
return null;
32+
}
33+
34+
/**
35+
* Pretend to save data
36+
*
37+
* @param string $data
38+
* @param string $identifier
39+
* @param array $tags
40+
* @param int $lifeTime
41+
* @return bool
42+
*/
43+
public function save($data, $identifier, $tags = [], $lifeTime = null)
44+
{
45+
return false;
46+
}
47+
48+
/**
49+
* Pretend to remove cached data by identifier
50+
*
51+
* @param string $identifier
52+
* @return bool
53+
*/
54+
public function remove($identifier)
55+
{
56+
return true;
57+
}
58+
59+
/**
60+
* Pretend to clean cached data by specific tag
61+
*
62+
* @param array $tags
63+
* @return bool
64+
*/
65+
public function clean($tags = [])
66+
{
67+
return true;
68+
}
69+
}

0 commit comments

Comments
 (0)