news icon indicating copy to clipboard operation
news copied to clipboard

News Search Form returns 404 &cHash empty

Open Tonyt8 opened this issue 1 year ago • 6 comments

Bug Report

Current Behavior Using the News Search form: I enter a search term, click "start search". I receive a Page Not Found The page did not exist or was inaccessible. Reason: Request parameters could not be validated (&cHash empty)

Expected behavior/output To return a list of news items that use the word entered in the search term.

Environment

  • TYPO3 version: 12.4.8
  • news version: 11.2.0
  • The Official TYPO3 Introduction Package
  • bootstrap_package version: 14.0.7
  • Is your TYPO3 installation set up with Composer (Composer Mode): no
  • OS: Windows 11 and 10

Possible Solution I have no idea

Additional context I have tried using many different route enhancers options. I have not found anything to solve the issue. With older versions of news and Typo3 with a similar set up as this I have used the news search form many time with success. To test this issue I setup a clean Typo3 install. Using Typo3 12.4.8 I setup an empty site. Next: with extension manager, installed the The Official TYPO3 Introduction Package. Next: with extension manager, installed the news extension. Only using the default language I added some news categories and news tags. I added a few news items using the categories and tags I had previously made Set up some news pages and storage in the standard way. List and detail pages work perfectly. The human readable URL's work nicely. I set up a news search page, to which I added the news search form plugin and the news search results plugin to the page. I also tested by sending the search form results to a separate news search results page with the news search results plugin both version gave the same 404 Page Not Found. I tried various route enhancers options. I'm stuck and don't know what to try next. Can you help?

Thanks. Regards, Tony

Tonyt8 avatar Dec 01 '23 20:12 Tonyt8

Hi, I also have the problem with version 11.3.0 of News Have you found a fix?

Thanks, Zoïa

zkrechowiec avatar Jan 02 '24 14:01 zkrechowiec

@Tonyt8 @zkrechowiec Problem is: News template uses method="get":

<n:searchForm object="{search}" name="search" pageUid="{settings.listPid}" method="get">

Just remove this attribute and method will be "post":

<n:searchForm object="{search}" name="search" pageUid="{settings.listPid}">

Caused by TYPO3 CMS setting

$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError'] = true;

Also wrong in current version: https://github.com/georgringer/news/blob/main/Resources/Private/Templates/News/SearchForm.html#L12 FYI @georgringer

SventB avatar Jan 07 '24 16:01 SventB

@Tonyt8 @zkrechowiec TYPO3 throws that error when there is no cHash available AND the given GET-Parameters are not excluded from cHash comparison.

You could therefore set $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = '^tx_news_pi1[search]'; in your extensions ext_localconf.php to exclude all parameters starting with above string from the cHash comparison. This should preserve parameters used for filtering results in the URL compared to using POST.

crinis avatar Jan 30 '24 10:01 crinis

Hi SventB and Crinis,

Thank you to you both for your help and advice which I will try. Regards, Tony

Tonyt8 avatar Jan 31 '24 10:01 Tonyt8

Hi SventB and Crinis, To confirm the news search worked well after I followed your instructions. Thank you very much for your help. Tony

Tonyt8 avatar Feb 28 '24 11:02 Tonyt8

Same here for news 11.4.1 with TYPO3 12.4.10

einpraegsam avatar Apr 26 '24 11:04 einpraegsam