Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
cf9004f
fix: set cache when env loader overrides data
Dec 29, 2024
4d7b3ba
feat?: call env helper on config get
Feb 8, 2025
523c484
feat?: backend: show data from env
Feb 8, 2025
66c4842
feat?: backend: disable field when ENV data is available
Feb 8, 2025
8de8438
Update app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
sreichel Feb 8, 2025
64d66f1
Update app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php
sreichel Feb 8, 2025
7163a29
feat?: backend: do not log on invalid stores - creates infinite loop
Feb 9, 2025
d8630be
feat: move env variables "str_starts_with"
Feb 17, 2025
c9256b4
feat: add env flag to disable/enable feature
Feb 17, 2025
53ae4e7
fix: fix tests
Feb 17, 2025
8ddd602
feat: set disabled, set scope label
Feb 17, 2025
a390c50
feat: remove checkbox to override
Feb 17, 2025
234a77d
chore: remove inline helper variable name
Feb 17, 2025
0a82291
Update tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php
pquerner Feb 17, 2025
0e9588a
Update tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php
pquerner Feb 17, 2025
cd34290
Update app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php
pquerner Feb 17, 2025
95c67a0
Update app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
pquerner Feb 17, 2025
2980da6
Update tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php
pquerner Feb 17, 2025
a44450d
Update app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
pquerner Feb 18, 2025
b18ab18
feat: add "hasPath" test
Feb 18, 2025
d4b19fc
feat: add "asArray" test
Feb 18, 2025
5bdea32
tests: add test cases
Feb 18, 2025
5db0883
Update app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php
pquerner Mar 9, 2025
bc8a222
fix: onStore(re)init the env vars would be lost
Mar 9, 2025
85cb4ff
envLoader: fix loading from scopes
Jun 16, 2025
4e70ac7
chore: run phpcs
Jun 16, 2025
df2e785
chore: phptan: add ignore line comment about internal method
Jun 16, 2025
d004ce7
envLoader: fix tests, fix scope default
Jun 16, 2025
3706ce5
chore: run rector:fix
Jun 16, 2025
18a9f22
Update tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php
sreichel Jun 19, 2025
52bfe3f
Update tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php
sreichel Jun 19, 2025
1fb4b43
sonar update
sreichel Jun 19, 2025
e940eac
fix
sreichel Jun 19, 2025
99794ba
phpstan L10
sreichel Jun 20, 2025
8a9cc9a
update
sreichel Jul 7, 2025
d176292
fix: run php-cs-fixer
Oct 23, 2025
a03fd9e
fix? phpstan?
Oct 23, 2025
c1b559f
Merge branch 'main' into fix/environmentLoader
sreichel Oct 26, 2025
9b03b4a
chore: run rector fix
Oct 26, 2025
043015c
Merge branch 'main' into fix/environmentLoader
sreichel Oct 27, 2025
ee8e69b
fix config
sreichel Oct 28, 2025
eb5376c
refactor
sreichel Oct 28, 2025
e5d352c
Merge branch 'main' into fix/environmentLoader
sreichel Oct 29, 2025
20104fc
Merge remote-tracking branch 'pquerner/fix/environmentLoader' into fi…
sreichel Oct 29, 2025
f63fd1c
update
sreichel Oct 29, 2025
daffbbe
update
sreichel Oct 29, 2025
29f6d15
added cypress test
sreichel Oct 29, 2025
6fd76be
Merge pull request #4 from sreichel/fix/environmentLoader
sreichel Oct 29, 2025
fd19a2e
Refactor web environment configuration in cypress.yml
sreichel Oct 29, 2025
c130005
Simplify ddev config command in workflow
sreichel Oct 29, 2025
ff3793d
Update registration success message in tests
sreichel Oct 30, 2025
75d9a31
Update cypress/e2e/openmage/backend/system/config/general/general.cy.js
sreichel Oct 30, 2025
491bac5
Update app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
sreichel Oct 30, 2025
ebc05f2
Update cypress/support/openmage/backend/system/config/general/general.js
sreichel Oct 30, 2025
8a887d1
fix: websites do not allow "-" character, but A-Z0-9_, starting with …
Oct 30, 2025
29700dc
fix: superflous website tests and testing suite bootstrap
Oct 30, 2025
188b270
chore: linter fixes
Oct 30, 2025
2ccce23
chore: run rector:fix
Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
autostart: false

# install DDEV configuration
- run: ddev config --project-type=magento --php-version=8.1 --webserver-type=${{ matrix.webserver }} --web-environment="MAGE_IS_DEVELOPER_MODE=1"
- run: ddev config --project-type=magento --php-version=8.1 --webserver-type=${{ matrix.webserver }} --web-environment="MAGE_IS_DEVELOPER_MODE=1,OPENMAGE_CONFIG_OVERRIDE_ALLOWED=1,OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME=ENV name default,OPENMAGE_CONFIG__WEBSITES__BASE__GENERAL__STORE_INFORMATION__PHONE=ENV phone website,OPENMAGE_CONFIG__STORES__GERMAN__GENERAL__STORE_INFORMATION__ADDRESS=ENV address store"

# install composer dependencies
- run: ddev composer install
Expand Down
41 changes: 39 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge

public const SCOPE_STORES = 'stores';

public const SCOPE_ENV = 'env';

/**
* Config data array
*
Expand Down Expand Up @@ -73,6 +75,7 @@ public function __construct()
self::SCOPE_DEFAULT => Mage::helper('adminhtml')->__('[GLOBAL]'),
self::SCOPE_WEBSITES => Mage::helper('adminhtml')->__('[WEBSITE]'),
self::SCOPE_STORES => Mage::helper('adminhtml')->__('[STORE VIEW]'),
self::SCOPE_ENV => Mage::helper('adminhtml')->__('[ENV]'),
];
}

Expand Down Expand Up @@ -380,7 +383,7 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
}
}

$field = $fieldset->addField($id, $fieldType, [
$elementFieldData = [
'name' => $name,
'label' => $label,
'comment' => $comment,
Expand All @@ -396,7 +399,15 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
'scope_label' => $this->getScopeLabel($element),
'can_use_default_value' => $this->canUseDefaultValue((int) $element->show_in_default),
'can_use_website_value' => $this->canUseWebsiteValue((int) $element->show_in_website),
]);
];
if ($this->isOverwrittenByEnvVariable($path)) {
$elementFieldData['scope_label'] = $this->_scopeLabels[self::SCOPE_ENV];
$elementFieldData['disabled'] = 1;
$elementFieldData['can_use_default_value'] = 0;
$elementFieldData['can_use_website_value'] = 0;
}

$field = $fieldset->addField($id, $fieldType, $elementFieldData);
$this->_prepareFieldOriginalData($field, $element);

if (isset($element->validate)) {
Expand Down Expand Up @@ -645,6 +656,32 @@ public function getScope()
return $scope;
}

/**
* Returns true if element was overwritten by ENV variable
*/
public function isOverwrittenByEnvVariable(string $path): bool
{
/** @var Mage_Core_Helper_EnvironmentConfigLoader $environmentConfigLoaderHelper */
$environmentConfigLoaderHelper = Mage::helper('core/environmentConfigLoader');

$scope = $this->getScope();
$store = Mage::app()->getRequest()->getParam('store');
$website = Mage::app()->getRequest()->getParam('website');

if ($store && $website) {
$path = "$scope/$store/$path";
return $environmentConfigLoaderHelper->hasPath($path);
}

if ($website) {
$path = "$scope/$website/$path";
return $environmentConfigLoaderHelper->hasPath($path);
}

$path = "$scope/$path";
return $environmentConfigLoaderHelper->hasPath($path);
}

/**
* Retrieve label for scope
*
Expand Down
8 changes: 8 additions & 0 deletions app/code/core/Mage/Adminhtml/Model/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ protected function _getPathConfig($path, $full = true)
}
}

if (!$full) {
/** @var Mage_Core_Helper_EnvironmentConfigLoader $environmentConfigLoaderHelper */
$environmentConfigLoaderHelper = Mage::helper('core/environmentConfigLoader');
$store = $this->getStore();
$envConfig = $environmentConfigLoaderHelper->getAsArray($store);
$config = array_merge($config, $envConfig);
}

return $config;
}

Expand Down
Loading
Loading