Skip to content

Commit 306dad1

Browse files
committed
Speedup - use module id from json file, do not read modules dir every time
1 parent d29f10a commit 306dad1

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

modules/oxcom/oxcom-omc/controllers/admin/omc_main.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class omc_main extends oxAdminView
3030
protected $_allModules = null;
3131
protected $_allTags = array();
3232
protected $_currSortKey = '';
33+
protected $_aModulesInDir = null;
3334
/**
3435
* Filter ioly modules for OXID
3536
* @var array
@@ -482,13 +483,16 @@ public function getActiveModuleSubshops($moduleOxid)
482483
$aSubshopsActive = array();
483484
$oConfig = oxRegistry::getConfig();
484485
$aShopIds = oxRegistry::getConfig()->getShopIds();
485-
/**
486-
* @var oxmodulelist $oModuleList
487-
*/
488-
$oModuleList = oxNew('oxModuleList');
489-
$sModulesDir = $oConfig->getModulesDir();
490-
$aModules = $oModuleList->getModulesFromDir($sModulesDir);
491-
if (in_array($moduleOxid, array_keys($aModules))) {
486+
if ($this->_aModulesInDir === null) {
487+
/**
488+
* @var oxmodulelist $oModuleList
489+
*/
490+
$oModuleList = oxNew('oxModuleList');
491+
$sModulesDir = $oConfig->getModulesDir();
492+
$this->_aModulesInDir = $oModuleList->getModulesFromDir($sModulesDir);
493+
494+
}
495+
if (in_array($moduleOxid, array_keys($this->_aModulesInDir))) {
492496
foreach ($aShopIds as $sShopId) {
493497
// set shopId
494498
$oConfig->setShopId($sShopId);
@@ -606,6 +610,11 @@ public function isModuleActiveAjax()
606610
*/
607611
public function getModuleOxid($moduleId, $moduleVersion)
608612
{
613+
// check if there is a module id in the json file...
614+
if (($moduleId = $this->_ioly->getJsonValueFromPackage($moduleId, $moduleVersion, "id")) != '' && is_array($moduleId)) {
615+
return $moduleId[0];
616+
}
617+
// if not, read the metadata.php file to get the id ...
609618
$aFiles = $this->_ioly->getFileList($moduleId, $moduleVersion);
610619
if ($aFiles && is_array($aFiles)) {
611620
foreach (array_keys($aFiles) as $filePath) {

0 commit comments

Comments
 (0)