ext-solr icon indicating copy to clipboard operation
ext-solr copied to clipboard

[BUG] 404 response for frontend-search-suggestions requests with TYPO3 core default settings

Open schluchzi opened this issue 1 year ago • 6 comments

Hello dear developer team,

I am running TYPO3 v12.4.9 with the extension apache-solr-for-typo3/solr in version 12.0.1.

After hours of searching, I found the cause of the following problem: If I activate the suggestions for the search and then type in letters, the requests are returned with the status code 404 (you can see this very well in the Chrome DevTools in the network tab). After a little trial and error, I found out that the "_" is not included in the "TYPO3_CONF_VARS=>FE=>cacheHach=>excludedParameters". The "_" is included with the timestamp(?) at the end of the requested URL.

The first solution was to include the "_" in the "excludedParameters".

I then found another solution where the TYPO3 core default value in "TYPO3_CONF_VARS=>FE=>pageNotFoundOnCHashError" causes problems. If the value is set to false, the middleware "PageArgumentValidator" does not even query the "pageNotFoundOnCHashError". This means that the 404 error does not occur. Unfortunately, the value from the core is set to true by default.

Is this error already known, or is there a setting for it somewhere? Or is this not an error and is it intentional?

I would appreciate a short feedback on this.

Greetings Luca

schluchzi avatar Dec 13 '23 15:12 schluchzi

@schluchzi Thanks for reporting that issue. The issue is not known and is not intended to behave that way. I did not recognized that behavior on https://github.com/TYPO3-Solr/solr-ddev-site on last touch on suggestion on EXT:solr 12.0.0. Is the EXT:solr suggest JS used in your project or own implementation?

@dmitryd, you was on suggest component in last few days. Can you please try to reproduce that in your project?

dkd-kaehm avatar Dec 13 '23 18:12 dkd-kaehm

on solr-ddev-site following settings are currently set:

  • pageNotFoundOnCHashError = 1
excludedParameters
0 = L
1 = mtm_campaign
2 = mtm_keyword
3 = mtm_kwd
4 = mtm_source
5 = mtm_medium
6 = mtm_content
7 = mtm_cid
8 = mtm_group
9 = mtm_placement
10 = pk_campaign
11 = pk_kwd
12 = _stg_debug
13 = utm_source
14 = utm_medium
15 = utm_campaign
16 = utm_term
17 = utm_content
18 = utm_id
19 = utm_source_platform
20 = utm_creative_format
21 = utm_marketing_tactic
22 = gtm_debug
23 = _gl
24 = gad
25 = gclid
26 = dclid
27 = fbclid
28 = msclkid
29 = hsa_acc
30 = hsa_ad
31 = hsa_cam
32 = hsa_grp
33 = hsa_kw
34 = hsa_mt
35 = hsa_net
36 = hsa_src
37 = hsa_tgt
38 = hsa_ver
39 = hsa_ol
40 = hsa_la
41 = _hsenc
42 = _hsmi
43 = __hssc
44 = __hstc
45 = __hsfp
46 = hsCtaTracking
47 = submissionGuid
q = q
^tx_solr[ = ^tx_solr[
^tx_solr__ = ^tx_solr__

The responses are all 200:

grafik

@schluchzi some other setting by-side of pageNotFoundOnCHashError is responsible in your instance for that trouble. Please try to find out it on comparing your instance with solr-ddev-site.

dkd-kaehm avatar Dec 13 '23 18:12 dkd-kaehm

I checked, I have no such issue with suggest. This setting ONLY works if cHash is given and it is wrong. There is no cHash for suggest requests out of the box. So I believe this is a local implementation issue.

dmitryd avatar Dec 14 '23 09:12 dmitryd

@schluchzi Please post the links of sugests here.

dkd-kaehm avatar Dec 14 '23 09:12 dkd-kaehm

@dkd-kaehm I compared the settings an found a combination, that creates the bug.

When the settings "TYPO3_CONF_VARS=>FE=>pageNotFoundOnCHashError" and "TYPO3_CONF_VARS=>FE=>cacheHash=>enforceValidation" are "true", then the suggest requests fail.

When I checked the default value of "enforceValdation", I saw, that it is set to "false" as default value. (https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/FE.html#enforcevalidation)

That's not what I expected, because I didn't change this value to "true" by my own. So I searched in my whole Project for the "enforceValidation". This search result showed me the file "typo3/cms-core/Configuration/FactoryConfiguration.php", where the value of "enforceValidation" is set to true, when using the TYPO3 installer. So all that in short, the TYPO3 default value of "enforceValidation" is false, but the TYPO3 installer sets the value to "true".

I hope, with that Information you can reproduce the errors and create a solution, where the suggestions don't fail with a basic and fresh installed TYPO3. Even if this is actually more of a core bug

schluchzi avatar Dec 18 '23 13:12 schluchzi

I can confirm this behaviour with Typo3 12.4 and enforceValidation configuration set to true.

Excluding the _ parameter with $exclusions[] = '_'; in Classes/System/Configuration/ExtensionConfiguration.php does the trick

derMatze82 avatar Apr 12 '24 12:04 derMatze82