Skip to content

Commit

Permalink
[BUGFIX] Fix #48: if alias is set in the page properties, url generat…
Browse files Browse the repository at this point in the history
…ion ends with exception
  • Loading branch information
dmitryd committed Mar 5, 2016
1 parent a761184 commit 637d598
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Classes/Encoder/UrlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ protected function encodeFixedPostVars() {
* @return void
*/
protected function encodePathComponents() {
$this->fixPageId();
$cacheEntry = $this->cache->getPathFromCacheByPageId($this->rootPageId,
$this->sysLanguageUid,
$this->urlParameters['id'],
Expand Down Expand Up @@ -811,6 +812,20 @@ protected function fixEmptySegments(array &$segments) {
}
}

/**
* Fixes page id if it is not a direct numeric page id.
*/
protected function fixPageId() {
if (!MathUtility::canBeInterpretedAsInteger($this->urlParameters['id'])) {
// Seems to be an alias
$alias = $this->urlParameters['id'];
$this->urlParameters['id'] = $this->pageRepository->getPageIdFromAlias($alias);
if ($this->urlParameters['id'] === 0) {
throw new \Exception(sprintf('Page with alias "%s" does not exist.', $alias), 1457183797);
}
}
}

/**
* Obtains the value from the alias cache.
*
Expand Down

0 comments on commit 637d598

Please sign in to comment.