Skip to content

Commit

Permalink
[BUGFIX] Cast pageType and suggestPageType to int in SearchFormViewHe…
Browse files Browse the repository at this point in the history
…lper

Problem:
Calling the `s:searchForm` ViewHelper with the `pageType` or `suggestPageType` argument with a value from a typoscript setting will lead to a TypeError

```html
<s:searchForm pageType="{settings.pageType}" suggestPageType="{settings.suggestPageType}">
```

`TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::setTargetPageType(): Argument #1 ($targetPageType) must be of type int, string given, called in /var/www/html/private/typo3conf/ext/solr/Classes/ViewHelpers/SearchFormViewHelper.php`

Solution:
Cast both arguments to int

Fixes: TYPO3-Solr#3927
Ports: TYPO3-Solr#3728
  • Loading branch information
dkd-kaehm committed May 7, 2024
1 parent 7a48f74 commit 394528f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Classes/ViewHelpers/SearchFormViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected function getSuggestUrl(?array $additionalFilters, int $pageUid): strin
$suggestUrl = $uriBuilder
->reset()
->setTargetPageUid($pageUid)
->setTargetPageType($this->arguments['suggestPageType'])
->setTargetPageType((int)$this->arguments['suggestPageType'])
->setArguments([$pluginNamespace => ['additionalFilters' => $additionalFilters]])
->build();

Expand All @@ -250,7 +250,7 @@ protected function buildUriFromPageUidAndArguments($pageUid): string
return $uriBuilder
->reset()
->setTargetPageUid((int)$pageUid)
->setTargetPageType($this->arguments['pageType'] ?? 0)
->setTargetPageType((int)($this->arguments['pageType'] ?? 0))
->setNoCache($this->arguments['noCache'] ?? false)
->setArguments($this->arguments['additionalParams'] ?? [])
->setCreateAbsoluteUri($this->arguments['absolute'] ?? false)
Expand Down

0 comments on commit 394528f

Please sign in to comment.