Skip to content

Commit

Permalink
Merge pull request #162 from vippsas/publication-2.4.45
Browse files Browse the repository at this point in the history
VIPPS-426: Issue - unknown version for plugin
  • Loading branch information
voleye authored Apr 25, 2023
2 parents 14193be + 551b497 commit 8f51710
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 38 deletions.
48 changes: 11 additions & 37 deletions Model/ModuleMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\Config;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Module\ModuleListInterface;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -44,16 +41,6 @@ class ModuleMetadata implements ModuleMetadataInterface
*/
private $version;

/**
* @var ComponentRegistrar
*/
private $componentRegistrar;

/**
* @var ReadFactory
*/
private $readFactory;

/**
* ProductMetadataInterface
*/
Expand All @@ -65,36 +52,31 @@ class ModuleMetadata implements ModuleMetadataInterface
private $cache;

/**
* @var SerializerInterface
* @var LoggerInterface
*/
private $serializer;
private $logger;

/**
* @var LoggerInterface
* @var ModuleListInterface
*/
private $logger;
private $moduleList;

/**
* Metadata constructor.
*
* @param ResourceInterface $resource
* @param ProductMetadataInterface $systemMetadata
* @param CacheInterface $cache
* @param ModuleListInterface $moduleList
* @param LoggerInterface $logger
*/
public function __construct(
ComponentRegistrarInterface $componentRegistrar,
ReadFactory $readFactory,
SerializerInterface $serializer,
ProductMetadataInterface $systemMetadata,
CacheInterface $cache,
ModuleListInterface $moduleList,
LoggerInterface $logger
) {
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;
$this->systemMetadata = $systemMetadata;
$this->cache = $cache;
$this->serializer = $serializer;
$this->logger = $logger;
$this->moduleList = $moduleList;
}

/**
Expand Down Expand Up @@ -156,22 +138,14 @@ private function getModuleVersion(): string
if ($this->version) {
return (string) $this->version;
}

$this->version = (string) $this->cache->load(self::VERSION_CACHE_KEY);
if ($this->version) {
return $this->version;
}

$path = $this->componentRegistrar->getPath(
ComponentRegistrar::MODULE,
'Vipps_Payment'
);

try {
$directoryRead = $this->readFactory->create($path);
$composerJsonData = $directoryRead->readFile('composer.json');
$data = $this->serializer->unserialize($composerJsonData);
$this->version = $data['version'] ?? 'UNKNOWN';
$this->version = (string)$this->moduleList->getOne('Vipps_Payment')['setup_version'];
} catch (\Throwable $t) {
$this->logger->error($t);
$this->version = 'UNKNOWN';
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
~ IN THE SOFTWARE.
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vipps_Payment" setup_version="2.4.44">
<module name="Vipps_Payment" setup_version="2.4.45">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 8f51710

Please sign in to comment.