Skip meta pages whose route requires mandatory parameters in sitemap#196
Open
boo-code wants to merge 1 commit into
Open
Skip meta pages whose route requires mandatory parameters in sitemap#196boo-code wants to merge 1 commit into
boo-code wants to merge 1 commit into
Conversation
getMetaLink() calls Link::getPageLink() for every configurable meta page. When a meta page maps to a route that requires a mandatory parameter (e.g. a module search route needing an id), Dispatcher::createUrl() throws a PrestaShopException, which aborted the entire sitemap generation. Such routes cannot be represented in a sitemap without a specific value, so catch the exception and skip the page, letting generation continue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getMetaLink()builds a sitemap entry for every configurable meta page viaLink::getPageLink($meta['page'], ...). When a meta page maps to a route that requires a mandatory parameter (e.g. a module search route needing an id),Dispatcher::createUrl()throws aPrestaShopException, which aborted the entire sitemap generation. This PR catches that exception and skips the offending page so generation continues. Such routes cannot be represented in a sitemap without a specific parameter value, so skipping them is the expected behaviour.module-pm_advancedsearch-searchresultsrequiringid_search), then generate the sitemap from the gsitemap configuration page. Before this PR generation fails withDispatcher::createUrl() miss required parameter ...; after it the sitemap is generated and the route is silently skipped. This is reproducible with a core route too:Link::getPageLink('upload', null, $idLang)throws (theuploadroute requiresfile) — with the fix,getMetaLink()skips it and returns normally instead of aborting.