Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c5b768
Improved error message for CMS page delete
sreichel Oct 5, 2025
3595f78
Added basic cypress test
sreichel Oct 5, 2025
9c37f13
Improved config sort order
sreichel Oct 5, 2025
291970d
rename
sreichel Oct 5, 2025
0d4401e
update tests
sreichel Oct 5, 2025
adf183e
doc
sreichel Oct 5, 2025
4a82b2d
[skip-ci] typo
sreichel Oct 5, 2025
b4bd7b0
Merge branch 'main' into fix/cms-error-message
sreichel Oct 5, 2025
ce58c3a
locale fix
sreichel Oct 5, 2025
ec3a7ad
fix disable page
sreichel Oct 5, 2025
2f9f632
cypress screenshots
sreichel Oct 5, 2025
0de4657
Merge remote-tracking branch 'origin/fix/cms-error-message' into fix/…
sreichel Oct 5, 2025
d825873
bug fix
sreichel Oct 5, 2025
e630a0c
Update app/code/core/Mage/Cms/Model/Resource/Page.php
sreichel Oct 5, 2025
c3ea0aa
Update cypress/support/openmage/config/paths.js
sreichel Oct 5, 2025
1165a81
Update tests
sreichel Oct 5, 2025
3ed8490
template fix
sreichel Oct 5, 2025
5ac59d3
Update app/code/core/Mage/Cms/Model/Resource/Page.php
sreichel Oct 5, 2025
ed627be
Update app/code/core/Mage/Cms/Model/Resource/Page.php
sreichel Oct 5, 2025
831e142
Update app/code/core/Mage/Cms/Helper/Page.php
sreichel Oct 5, 2025
da5681f
Update store and website names in data provider
sreichel Oct 5, 2025
3f0e211
Refactor getScopeInfoFromConfigScope method
sreichel Oct 5, 2025
49e1498
Merge branch 'main' into fix/cms-error-message
kiatng Oct 9, 2025
36647ce
Merge branch 'main' into fix/cms-error-message
sreichel Oct 13, 2025
72d919f
Merge remote-tracking branch 'origin/fix/cms-error-message' into fix/…
sreichel Oct 13, 2025
84c7906
Merge branch 'main' into fix/cms-error-message
sreichel Oct 13, 2025
8bcd591
removed od files
sreichel Oct 13, 2025
517a05d
updated css
sreichel Oct 13, 2025
b3555df
Merge branch 'main' into fix/cms-error-message
sreichel Oct 14, 2025
ad025c1
translation
sreichel Oct 14, 2025
f924b0f
rector
sreichel Oct 14, 2025
77893b9
Merge branch 'main' into fix/cms-error-message
sreichel Oct 15, 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
63 changes: 63 additions & 0 deletions app/code/core/Mage/Cms/Helper/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,67 @@ public static function getUsedInStoreConfigPaths(?array $paths = []): array

return $searchPaths;
}

/**
* @param self::XML_PATH_* $path
*/
public static function getConfigLabelFromConfigPath(string $path): string
{
return match ($path) {
self::XML_PATH_NO_ROUTE_PAGE => Mage::helper('cms')->__('No Route Page'),
self::XML_PATH_NO_COOKIES_PAGE => Mage::helper('cms')->__('No Cookies Page'),
self::XML_PATH_HOME_PAGE => Mage::helper('cms')->__('Home Page'),
default => $path,
};
}

/**
* @param Mage_Adminhtml_Block_System_Config_Form::SCOPE_* $scope
* @throws Mage_Core_Exception
*/
public static function getScopeInfoFromConfigScope(string $scope, string $scopeId): string
{
return match ($scope) {
Mage_Adminhtml_Block_System_Config_Form::SCOPE_DEFAULT => Mage::helper('cms')->__('Default Config'),
Mage_Adminhtml_Block_System_Config_Form::SCOPE_WEBSITES => Mage::app()->getWebsite($scopeId)->getName(),
Mage_Adminhtml_Block_System_Config_Form::SCOPE_STORES => sprintf(
'%s "%s"',
Mage::app()->getStore($scopeId)->getGroup()->getName(),
Mage::app()->getStore($scopeId)->getName(),
),
};
}

/**
* @throws Mage_Core_Exception
*/
public static function getValidateConfigErrorMessage(Mage_Core_Model_Resource_Db_Collection_Abstract $isUsedInConfig): string
{
$messages = [];

$data = $isUsedInConfig->getData();
foreach ($data as $key => $item) {
$path = $item['path'];
unset($item['config_id'], $item['path'], $item['updated_at'], $item['value']);
$data[$path][] = $item;
unset($data[$key], $key, $path);
}

foreach ($data as $path => $items) {
$scopes = [];
foreach ($items as $item) {
$scopes[] = self::getScopeInfoFromConfigScope($item['scope'], $item['scope_id']);
}

$messages[] = sprintf(
'"%s" (%s)',
self::getConfigLabelFromConfigPath($path),
implode(', ', $scopes),
);
}

unset($data, $path, $items, $item, $scopes);

return implode(', ', $messages);
}
}
14 changes: 9 additions & 5 deletions app/code/core/Mage/Cms/Model/Resource/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ protected function _beforeDelete(Mage_Core_Model_Abstract $object)
$object->setId(null);
Mage::throwException(
Mage::helper('cms')->__(
'Cannot delete page, it is used in "%s".',
implode(', ', $isUsedInConfig->getColumnValues('path')),
'Cannot delete page, it is used in <a href="%s">configuration</a> for %s.',
Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit', ['section' => 'web']),
Mage_Cms_Helper_Page::getValidateConfigErrorMessage($isUsedInConfig),
),
);
}
Expand Down Expand Up @@ -79,8 +80,9 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object)
$object->setIsActive(true);
Mage::getSingleton('adminhtml/session')->addWarning(
Mage::helper('cms')->__(
'Cannot disable page, it is used in configuration "%s".',
implode(', ', $isUsedInConfig->getColumnValues('path')),
'Cannot disable page, it is used in <a href="%s">configuration</a> for %s.',
Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit', ['section' => 'web']),
Mage_Cms_Helper_Page::getValidateConfigErrorMessage($isUsedInConfig),
),
);
}
Expand Down Expand Up @@ -282,7 +284,9 @@ protected function isValidPageIdentifier(Mage_Core_Model_Abstract $object)

public function getUsedInStoreConfigCollection(Mage_Cms_Model_Page $page, ?array $paths = []): Mage_Core_Model_Resource_Db_Collection_Abstract
{
$storeIds = (array) $page->getStoreId();
$storeId = (array) $page->getStoreId(); # null on save
$stores = (array) $page->getStores(); # null on delete
$storeIds = array_merge($storeId, $stores);
$storeIds[] = Mage_Core_Model_App::ADMIN_STORE_ID;
$config = Mage::getResourceModel('core/config_data_collection')
->addFieldToFilter('value', $page->getIdentifier())
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Cms/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<label>CMS Home Page</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_cms_page</source_model>
<sort_order>1</sort_order>
<sort_order>21</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand All @@ -26,7 +26,7 @@
<label>CMS No Route Page</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_cms_page</source_model>
<sort_order>2</sort_order>
<sort_order>22</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand All @@ -35,7 +35,7 @@
<label>CMS No Cookies Page</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_cms_page</source_model>
<sort_order>3</sort_order>
<sort_order>23</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand All @@ -44,7 +44,7 @@
<label>Show Breadcrumbs for CMS Pages</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>5</sort_order>
<sort_order>25</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand Down
4 changes: 2 additions & 2 deletions app/locale/en_US/Mage_Cms.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"CMS Static Block","CMS Static Block"
"CMS Static Block Default Template","CMS Static Block Default Template"
"Cannot create new directory.","Cannot create new directory."
"Cannot delete page, it is used in ""%s"".","Cannot delete page, it is used in ""%s""."
"Cannot delete page, it is used in <a href=""%s"">configuration</a> for %s.","Cannot delete page, it is used in <a href=""%s"">configuration</a> for %s."
"Cannot delete directory %s.","Cannot delete directory %s."
"Cannot delete root directory %s.","Cannot delete root directory %s."
"Cannot disable page, it is used in configuration ""%s"".","Cannot disable page, it is used in configuration ""%s""."
"Cannot disable page, it is used in <a href=""%s"">configuration</a> for %s.","Cannot disable page, it is used in <a href=""%s"">configuration</a> for %s."
"Cannot upload file.","Cannot upload file."
"Collapse All","Collapse All"
"Content","Content"
Expand Down
16 changes: 16 additions & 0 deletions skin/adminhtml/default/openmage/override.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion skin/adminhtml/default/openmage/override.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading