Skip to content

Commit 624bb47

Browse files
committed
Merge remote-tracking branch 'origin/MC-19115' into hb-combined-pr
2 parents 7063e2a + a098f4f commit 624bb47

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
9+
<default>
10+
<admin>
11+
<usage>
12+
<enabled>
13+
1
14+
</enabled>
15+
</usage>
16+
</admin>
17+
</default>
18+
</config>

lib/internal/Magento/Framework/App/ProductMetadata.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
/**
1616
* Class ProductMetadata
17+
*
1718
* @package Magento\Framework\App
1819
*/
1920
class ProductMetadata implements ProductMetadataInterface
@@ -28,6 +29,11 @@ class ProductMetadata implements ProductMetadataInterface
2829
*/
2930
const PRODUCT_NAME = 'Magento';
3031

32+
/**
33+
* Magento version cache key
34+
*/
35+
const VERSION_CACHE_KEY = 'mage-version';
36+
3137
/**
3238
* Product version
3339
*
@@ -47,11 +53,21 @@ class ProductMetadata implements ProductMetadataInterface
4753
private $composerInformation;
4854

4955
/**
56+
* @var CacheInterface
57+
*/
58+
private $cache;
59+
60+
/**
61+
* ProductMetadata constructor.
5062
* @param ComposerJsonFinder $composerJsonFinder
63+
* @param \Magento\Framework\App\CacheInterface $cache
5164
*/
52-
public function __construct(ComposerJsonFinder $composerJsonFinder)
53-
{
65+
public function __construct(
66+
ComposerJsonFinder $composerJsonFinder,
67+
CacheInterface $cache = null
68+
) {
5469
$this->composerJsonFinder = $composerJsonFinder;
70+
$this->cache = $cache ?? ObjectManager::getInstance()->get(CacheInterface::class);
5571
}
5672

5773
/**
@@ -61,13 +77,16 @@ public function __construct(ComposerJsonFinder $composerJsonFinder)
6177
*/
6278
public function getVersion()
6379
{
80+
$versionFromCache = $this->cache->load(self::VERSION_CACHE_KEY);
81+
$this->version = $this->version ?: $versionFromCache;
6482
if (!$this->version) {
6583
if (!($this->version = $this->getSystemPackageVersion())) {
6684
if ($this->getComposerInformation()->isMagentoRoot()) {
6785
$this->version = $this->getComposerInformation()->getRootPackage()->getPrettyVersion();
6886
} else {
6987
$this->version = 'UNKNOWN';
7088
}
89+
$this->cache->save($this->version, self::VERSION_CACHE_KEY, [Config::CACHE_TAG]);
7190
}
7291
}
7392
return $this->version;

0 commit comments

Comments
 (0)