Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong Preview link on CMS pages grid #4214

Merged
merged 1 commit into from
Sep 21, 2024

Conversation

Caprico85
Copy link
Contributor

Description (*)

If you have a CMS page where the identifier has 4 or more levels (e.g. test/page/foo/bar), the preview link on the CMS page grid will not work.

The preview link only shows the first 3 levels, where the URL key has 4 levels.

image

The preview link is generated in Mage_Adminhtml_Block_Cms_Page_Grid_Renderer_Action. This class uses Mage::getModel('core/url')->getUrl(...) to generate the link. getUrl(...) calls Mage_Core_Model_Url::setReoutePath(), which tries to parse the URL with the usual module/controller/action structure and cuts off the fourth level.

Using getDirectUrl(...) instead of getUrl(...) fixes this as getDirectUrl(...) takes the URL as is, not cutting off the fourth level.

Manual testing scenarios (*)

  1. Create a new CMS page. Set its identifier to test/page/foo/bar (or any other URL at least 4 levels deep).
  2. Click the preview link on the CMS page grid.
  3. You will get to the 404 page.
  4. Check the URL of the link. It will be 'test/page/foo', not 'test/page/foo/bar' as specified in the identifier.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the Component: Adminhtml Relates to Mage_Adminhtml label Sep 20, 2024
@ADDISON74
Copy link
Contributor

I confirm this bug with the latest OpenMage version + Magento Sample Data.

The About Us page has the URL key "about-magento-demo-store". Here are different scenarios increasing the path with one level

URL Key Preview
about-magento-demo-store/1 OK
about-magento-demo-store/1/2 OK
about-magento-demo-store/1/2/3 Wrong

For the last scenario, instead of being displayed in the status bar as "about-magento-demo-store/1/2/3" it is displayed as "about-magento-demo-store/1/2", 3 is missing. By increasing the levels number, the URL will remain the same limited to two levels.

Copy link
Contributor

@ADDISON74 ADDISON74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it works as expected. Screenshot attached bellow for a 10-level URL.

screenshot3

Copy link
Contributor

@sreichel sreichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some tests too ...

@sreichel sreichel merged commit e7b47ab into OpenMage:main Sep 21, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants