Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 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
1f4335d
Merge branch 'main' into fix/cms-error-message
kiatng Oct 19, 2025
4d420bb
Merge branch 'main' into fix/cms-error-message
sreichel Oct 22, 2025
0bd62a0
Apply suggestions from code review
sreichel Oct 22, 2025
a416ade
wording
sreichel Oct 22, 2025
e60e90b
Merge remote-tracking branch 'origin/fix/cms-error-message' into fix/…
sreichel Oct 22, 2025
4a8de02
tests
sreichel Oct 22, 2025
e8f9828
wording
sreichel Oct 26, 2025
9f72428
typo
sreichel Oct 26, 2025
c9c9c94
test
sreichel Oct 26, 2025
badbfc3
Merge branch 'main' into fix/cms-error-message
sreichel Oct 27, 2025
478f66d
Merge branch 'main' into fix/cms-error-message
sreichel Oct 30, 2025
b39d400
Merge branch 'main' into fix/cms-error-message
sreichel Oct 31, 2025
88f43e5
message for ENV config
sreichel Oct 31, 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
72 changes: 71 additions & 1 deletion app/code/core/Mage/Cms/Helper/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Cms
*/

use Mage_Adminhtml_Block_System_Config_Form as Form;

/**
* CMS Page Helper
*
Expand All @@ -29,6 +31,7 @@ class Mage_Cms_Helper_Page extends Mage_Core_Helper_Abstract
*
* @param string $pageId
* @return bool
* @throws Mage_Core_Exception
*/
public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId = null)
{
Expand All @@ -41,8 +44,9 @@ public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId =
* @param string $pageId
* @param bool $renderLayout
* @return bool
* @throws Mage_Core_Exception
*/
protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true)
protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true)
{
$page = Mage::getSingleton('cms/page');
if (!is_null($pageId) && $pageId !== $page->getId()) {
Expand Down Expand Up @@ -129,6 +133,7 @@ protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pag
* @param string $pageId
* @param bool $renderLayout
* @return bool
* @throws Mage_Core_Exception
*/
public function renderPageExtended(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true)
{
Expand All @@ -140,6 +145,7 @@ public function renderPageExtended(Mage_Core_Controller_Varien_Action $action, $
*
* @param string $pageId
* @return string|null
* @throws Mage_Core_Model_Store_Exception
*/
public function getPageUrl($pageId = null)
{
Expand Down Expand Up @@ -176,4 +182,68 @@ 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 Form::SCOPE_* $scope
* @throws Mage_Core_Exception
*/
public static function getScopeInfoFromConfigScope(string $scope, string $scopeId): string
{
return match ($scope) {
Form::SCOPE_ENV => Mage::helper('cms')->__('Environment Config'),
Form::SCOPE_DEFAULT => Mage::helper('cms')->__('Default Config'),
Form::SCOPE_WEBSITES => Mage::app()->getWebsite($scopeId)->getName(),
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);
}
}
19 changes: 14 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')),
'You cannot delete this page as it is used to <a href="%s">configure</a> %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')),
'You cannot disable this page as it is used to <a href="%s">configure</a> %s.',
Mage::helper('adminhtml')::getUrl('adminhtml/system_config/edit', ['section' => 'web']),
Mage_Cms_Helper_Page::getValidateConfigErrorMessage($isUsedInConfig),
),
);
}
Expand Down Expand Up @@ -111,6 +113,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object)
/**
* @param Mage_Cms_Model_Page $object
* @inheritDoc
* @throws Zend_Db_Exception
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
Expand Down Expand Up @@ -185,6 +188,7 @@ protected function _afterLoad(Mage_Core_Model_Abstract $object)
* @param mixed $value
* @param Mage_Cms_Model_Page $object
* @return Zend_Db_Select
* @throws Exception
*/
protected function _getLoadSelect($field, $value, $object)
{
Expand Down Expand Up @@ -236,6 +240,7 @@ protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = n
/**
* Check for unique of identifier of page to selected store(s).
*
* @param Mage_Cms_Model_Page $object
* @return bool
*/
public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object)
Expand Down Expand Up @@ -282,7 +287,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 Expand Up @@ -326,6 +333,7 @@ public function checkIdentifier($identifier, $storeId)
*
* @param string|int $identifier
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
public function getCmsPageTitleByIdentifier($identifier)
{
Expand Down Expand Up @@ -418,6 +426,7 @@ public function setStore($store)
* Retrieve store model
*
* @return Mage_Core_Model_Store
* @throws Mage_Core_Model_Store_Exception
*/
public function getStore()
{
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,8 @@
"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 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 upload file.","Cannot upload file."
"Collapse All","Collapse All"
"Content","Content"
Expand Down Expand Up @@ -124,4 +122,6 @@
"Unable to find a block to delete.","Unable to find a block to delete."
"Unable to find a page to delete.","Unable to find a page to delete."
"WYSIWYG Options","WYSIWYG Options"
"You cannot delete this page as it is used to <a href=""%s"">configure</a> %s.","You cannot delete this page as it is used to <a href=""%s"">configure</a> %s."
"You cannot disable this page as it is used to <a href=""%s"">configure</a> %s.","You cannot disable this page as it is used to <a href=""%s"">configure</a> %s."
"px.","px."
4 changes: 2 additions & 2 deletions cypress/e2e/openmage/backend/cms/page.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe(`Checks admin system "${test.index.title}"`, () => {
test.edit.__buttons.saveAndContinue.click();

const success = 'The page has been saved.';
const warning = 'Cannot disable page, it is used in configuration';
const warning = 'You cannot disable this page as it is used to configure';
validation.hasWarningMessage(warning);
validation.hasSuccessMessage(success);
utils.screenshot(cy.openmage.validation._messagesContainer, 'message.cms.page.disableActivePage');
Expand All @@ -71,7 +71,7 @@ describe(`Checks admin system "${test.index.title}"`, () => {
test.index.clickGridRow('no-route');
test.edit.__buttons.delete.click();

const message = 'Cannot delete page';
const message = 'You cannot delete this page as it is used to configure';
const screenshot = 'message.cms.page.deleteActivePage';
validation.hasErrorMessage(message, { screenshot: true, filename: screenshot });
});
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.

Loading
Loading