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

404 when searching (caused by cHash error due to enforceValidation) #149

Closed
MrMooky opened this issue Mar 21, 2023 · 10 comments
Closed

404 when searching (caused by cHash error due to enforceValidation) #149

MrMooky opened this issue Mar 21, 2023 · 10 comments

Comments

@MrMooky
Copy link

MrMooky commented Mar 21, 2023

I have an odd issue and I'm not sure whether this is related to my (regular) setup, or ke_search.

When opening the search page, eg. domain.de/suche I see a few results and also the search bar. When I type something into the search field and submit, I get the 404 page. The url then is domain.de/suche/?tx_kesearch_pi1%5Bsword%5D=test.

TYPO3 11.5.25
PHP 8.1.13
Extension is up-to-date

Any idea what the cause might be?

@MrMooky
Copy link
Author

MrMooky commented Mar 21, 2023

Was caused by this setting in my local conf:

'cacheHash' => [
    'enforceValidation' => true,
],

@MrMooky MrMooky closed this as completed Mar 21, 2023
@christianbltr
Copy link
Member

Thanks for pointing to this issue. I will reopen this because ke_search should work also if the option "enforceValidation" is enabled.

This option has been introduced in 10.4.35/11.5.23/12.2 and is recommended to be enabled and is enabled by default for new installations, see
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/FE.html#enforcevalidation

@christianbltr christianbltr reopened this Mar 24, 2023
@secured
Copy link

secured commented May 12, 2023

is there a status update on this yet?

@schlotzz
Copy link

This behaviour also occured on my installation.

  • TYPO3 v12.4.1
  • ke_search 5.0.0
  • PHP 8.1.18

Disabling enforceValidation did the job, but as stated by @christianbltr is not an optimal solution.

Is there any information I can provide to proceed with this issue?

@christianbltr christianbltr changed the title 404 when searching 404 when searching (caused by cHash error due to enforceValidation) Jun 2, 2023
@christianbltr
Copy link
Member

It is not possible to calculate a cHash because ke_search uses a form to send data and the form options are modified by the user.

As far as I understand the correct solution would be to use the

[FE][cHashExcludedParameters]

option to exclude the ke_search parameters from cHash calculation as described in

https://stackoverflow.com/questions/56787705/how-to-handel-the-chash-on-a-get-form

Does that work in your case?

From the ke_search point of view the only thing to do would be to add this information in the documentation, including a list of parameters which should be excluded.

@schlotzz
Copy link

@christianbltr Thanks a lot for pointing that out. I didn't know about this configuration option, yet.

Adding the following code to my ext_localconf.php did work for me instead of disabling enforceValidation.

$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'] = array_merge(
    $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'],
    [
        'tx_kesearch_pi1[sortByField]',
        'tx_kesearch_pi1[sortByDir]',
        'tx_kesearch_pi1[resetFilters]',
        'tx_kesearch_pi1[page]',
        'tx_kesearch_pi1[sword]', // must be changed if "plugin.tx_kesearch_pi1.searchWordParameter" has been set
        'tx_kesearch_pi1[page]',
    ]
);

Don't forget to add your custom filters.

@christianbltr
Copy link
Member

Thanks for providing your solution. It's now integrated into ke_search and a new documentation page explains how to add parameters if the search word parameter has been changed or filters are used:

https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Avoid404Error.rst

@schlotzz
Copy link

Thanks for integrating the solution and adding a documentation.

@Hawkeye1909
Copy link

Hi @christianbltr! I have a follow-up question on this topic: how do you exclude the filters?

With the solution you added, you exclude 'tx_kesearch_pi1[filter]' among others. However, the individual filters generate parameters of the pattern 'tx_kesearch_pi1[filter_#uid#]' or 'tx_kesearch_pi1[filter_#uid##option#]' (where #option# depends on the filter type). So the existing solution is not enough and I added '^tx_kesearch_pi1[filter' at my sitepackage. But in principle '^tx_kesearch_pi1' would actually also be sufficient to exclude all search parameters, wouldn't it?

@christianbltr
Copy link
Member

Currently you will need to manually exclude the filters, each option separately, see the example in
https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Avoid404Error.rst#example

That is quite inconvenient, therefore I opened #187 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants