Skip to content

Commit fdb3329

Browse files
authored
Modifying priority of version value (#500)
* Modifying priority of version value * Simplifying bool condition for dev case
1 parent 4d739d6 commit fdb3329

File tree

1 file changed

+14
-10
lines changed
  • app/code/Meta/BusinessExtension/Model/System

1 file changed

+14
-10
lines changed

app/code/Meta/BusinessExtension/Model/System/Config.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,21 @@ public function getAppId(): string
207207
*/
208208
public function getModuleVersion(): string
209209
{
210-
$this->version = (string)($this->version ?: $this->cache->load(self::VERSION_CACHE_KEY));
211-
if (!$this->version) {
212-
$installedPackages = $this->composerInformation->getInstalledMagentoPackages();
213-
$extensionVersion = $installedPackages[self::EXTENSION_PACKAGE_NAME]['version'] ?? null;
214-
if (!empty($extensionVersion)) {
215-
$this->version = $extensionVersion;
216-
} else {
217-
$this->version = 'dev';
218-
}
219-
$this->cache->save($this->version, self::VERSION_CACHE_KEY, [AppConfig::CACHE_TAG]);
210+
$cachedVersion = $this->cache->load(self::VERSION_CACHE_KEY);
211+
if ($cachedVersion) {
212+
// Once we've calculated the version for this session, default to the cached value.
213+
return $cachedVersion;
214+
}
215+
$installedPackages = $this->composerInformation->getInstalledMagentoPackages();
216+
// We are now setting the "DEV" version locally as well as via composer to facilitate logging.
217+
// If there is ever a conflict, we should prefer Composer's value.
218+
$officialExtensionVersion = $installedPackages[self::EXTENSION_PACKAGE_NAME]['version'] ?? null;
219+
if ($officialExtensionVersion) {
220+
$this->version = $officialExtensionVersion;
221+
} else {
222+
$this->version = (string)($this->version ?: 'dev');
220223
}
224+
$this->cache->save($this->version, self::VERSION_CACHE_KEY, [AppConfig::CACHE_TAG]);
221225
return $this->version;
222226
}
223227

0 commit comments

Comments
 (0)