processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

processwire.com search breaks on Enter key

Open artfulrobot opened this issue 2 years ago • 7 comments

Not sure if you accept bug reports on your website here, so do with it as you will.

  1. Visit https://processwire.com
  2. Click Search
  3. Type something, press Enter
  4. Expected: search results page. Actual: raw JSON blob output to browser.

Screencast:

pw-search

Example web page shown after searching latte and hitting Enter:

{"total":4,"start":0,"limit":8,"items":[{"name":"Modules","type":"","url":"\/search\/?t=Modules&q=latte","header":true},{"id":1748,"name":"TemplateLatteReplace","title":"TemplateLatteReplace","subtitle":"Latte template engine support for ProcessWire.","summary":"Latte template engine support for ProcessWire.","type":"rolandtoth","icon":"","url":"\/modules\/template-latte-replace\/"},{"id":2228,"name":"WireframeRendererLatte","title":"WireframeRendererLatte","subtitle":"Latte renderer for the Wireframe output framework.","summary":"Latte renderer for the Wireframe output framework.","type":"Teppo","icon":"","url":"\/modules\/wireframe-renderer-latte\/"},{"id":2290,"name":"TemplateEngineLatte","title":"TemplateEngineLatte","subtitle":"Latte templates for the TemplateEngineFactory","summary":"Latte templates for the TemplateEngineFactory","type":"daun","icon":"","url":"\/modules\/template-engine-latte\/"},{"name":"Forums","type":"","url":"\/search\/?t=Forums&q=latte","header":true},{"name":"Search forums for \u201clatte\u201d","subtitle":"","summary":"","type":"","url":"https:\/\/processwire.com\/talk\/search\/?q=latte"}]}

artfulrobot avatar Oct 03 '23 13:10 artfulrobot

Related: #1516

elabx avatar Oct 03 '23 16:10 elabx

@artfulrobot This has been reported, but I haven't been able to consistently duplicate it. If I go there now and try to duplicate with "something" or "latte", the search works properly. I'll track it down sooner or later. :)

ryancramerdesign avatar Oct 06 '23 14:10 ryancramerdesign

I just tried and it's happening every time I try - tested at least 10 times in a row. Probably not very helpful though I know :)

adrianbj avatar Oct 06 '23 14:10 adrianbj

@adrianbj anything in the browser console? I'm guessing something makes a js error and that's the cause of this. But it's actually working for me (now I don't need to search for anything :laughing: )

FWIW, I tried on both Firefox and Ungoogled-Chromium yesterday - both gave same result (the json)

artfulrobot avatar Oct 06 '23 14:10 artfulrobot

No JS errors. I think it might be related to the number of items that are returned. Searches with lots of results consistenly work fine. So I am wondering if it's related to the speed of the AJAX request (returning results before you can hit the enter key).

adrianbj avatar Oct 06 '23 14:10 adrianbj

Actually, I don't think that makes sense because you can even test directly with this URL in the browser: https://processwire.com/search/?q=latte

That returns the JSON for me every time, but:

https://processwire.com/search/?q=tracy

always loads the page properly.

adrianbj avatar Oct 06 '23 14:10 adrianbj

Yes, it was repeatable for me in chromium today. No console errors.

I think it's caching. Because I note that theres an ajax doing GET ?query=x request, which is exactly the same as the browser navigates to (when it works). The Network panel of the dev tools shows that it fails when the request is returned from disk[sic] cache.

One solution might be to append another query param for ajax requests for search matches (e.g. &justDoingAQuickSearch).

Perhaps @ryancramerdesign is working on it now, because now my ajax response is giving an error in the console:

parsererror - SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

artfulrobot avatar Oct 06 '23 15:10 artfulrobot

@ryancramerdesign https://processwire.com/talk/topic/20596-new-post-new-pw-website-ready/?do=findComment&comment=245197

matjazpotocnik avatar Oct 21 '24 14:10 matjazpotocnik

Not sure if this site is using ProCache (I would bet so!), maybe the .htaccess is missing "q" in the rules that let's you bypass if queries are present in the request? Then if at any point the cache expires, the first json request gets saved as the static cache. At leas this has happened to me haha.

elabx avatar Oct 21 '24 14:10 elabx