Search "Within this topic" works for admin but does not work for regular members

Started by gasman, April 08, 2024, 05:45:01 AM

Previous topic - Next topic

gasman

Hi all

I posted this a year ago, and it is still a problem

My users get zero results when they use the quick search restricted to "In This Topic".

Forum: good-music-guide.com/community
SMF 2.1.4

I have search allowed for guests, all users

Search is set to Fulltext index, and the index is created. I have enabled Force the Use of a Search Index.

All users can search the "Entire Forum", and within "This Board". 

Admin can search within "This Topic" and get good results. 

The Problem: Other users get zero results when searched within "This Topic", despite using the same search words as Admin.

All boards and all topics are visible to all users and guest.

Why does search within "This Topic" work for admin but not other users?

Cheers

Doug Heffernan

I got this error message when I tried to search in a topic.

You are not allowed to access this section.

shawnb61

Yep, confirmed.  I think this is a bug.

Guests get the not allowed message.

Regular users get a no results message.

Admins get proper results.
A question worth asking is born in experience & driven by necessity. - Fripp

Kindred

I believe this was reported ages ago.... 

yup
https://github.com/SimpleMachines/SMF/issues/7870


it got closed as not reproducible -- but I KNOW that I was able to reproduce this on 2.1.3 and 2.1.4 (can't find the original report on this site - but I knew it had made it to github at some point)


edit: found it
https://www.simplemachines.org/community/index.php?topic=584342.0
https://www.simplemachines.org/community/index.php?topic=586646.0

https://www.simplemachines.org/community/index.php?topic=585596.0
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

shawnb61

I bet folks tested using their admin accounts....

The only one that works... 
A question worth asking is born in experience & driven by necessity. - Fripp

gasman

Yep, Search "this topic" works fine for Admin. But I logout of Admin and logging as a regular user, and I get no results for search within "This Topic" on my forum.

Interestingly, it works fine on this SMF Community forum, and I'm just a regular member.

GoinNutz

I searched around and could not find any newer topics on this and I think I have something to add that might possibly be useful.

I've tested this on two different forums - one is an old forum that goes back to the SMF 1.x days and has been continuously updated to each new version since then up to the current 2.1.4, and another that is a fresh clean install starting with 2.1.4

The Search "This topic" bug wherein it works for admin users but doesn't work for regular users only happens on the old forum that started out on SMF 1.x and is now running 2.1.4

On the fresh new 2.1.4  the Search "This topic" works for both admin and regular users alike.

This makes me think that maybe the bug is somehow related to some of the code from older versions of SMF that might be getting carried through over the course of upgrades. But since I'm not a programmer by any stretch, it's just a hunch.

I wonder has anyone else tested it on a clean fresh 2.1.4 install and still encountered the issue?

Kindred

Thing is, THIS site has been upgraded through literally every version......
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

This site also has a bunch of non standard changes, including to search, that make such claims suspect.
Holder of controversial views, all of which my own.


Kindred

Oh, that wasn't a claim so much as a statement.  I already know that this is a confirmed bug (I confirmed it on my own sites, including my fresh installed 2.1 site)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GoinNutz

Thanks for chiming-in guys. How strange that this bug does not occur on all SMF 2.1.x sites but obviously enough that people have reported and reproduced it. I've simply been trying to find some correlation and thought maybe I was onto something when I discovered it happens on one of the SMF sites I manage and not the other, and the main differences between the two. Neither of them have any mods installed and are basically "out of the box" SMF's.

shawnb61

A question worth asking is born in experience & driven by necessity. - Fripp

shawnb61

Pretty sure it's not tied to the php or mysql version.  My test copy (php 8.3, mysql 8.4; I also tried php 7.4) shows the same behavior as production (php 8.2, mysql 8.0 percona).  My forum uses a custom index. 

In my forum, it doesn't always fail...  But there are patterns...

- It fails for certain terms in certain topics/boards, for non-admins & guests, in a repeatable fashion.
    - The same user may get proper search results on any other board, for any other search term.
    - The same user may get proper search results using a different search term in the same topic or board.
    - If the same user performs a forum-level search, the results for that topic/board appear to be missing... (!!!)
    - New posts with the same term in the same topic/board do not show up either...  (I.e., it's not just migrated data.)
    - Guests are allowed to search, & may get a "You are not allowed to access this section" error first time thru - specifically for the problem query in the problem topic/board.  If guests have otherwise passed the required captcha, they may instead just get a no matching search results message.
- The words are indexed properly, or it would fail for the admin, too.  They look fine in the db in the custom search index.
- Board permissions match all the other public boards - nothing unique about them.
- Clearing cache makes no difference.

Sure feels like a query/join issue.  Something along the lines of one of the posts with that term is in an off-limits board for that user, and it's bubbling up & affecting the query somehow.  It's possible this doesn't affect folks using 3rd party search tools, e.g., this forum uses Sphinx, IIRC...
A question worth asking is born in experience & driven by necessity. - Fripp

shawnb61

There is a proposed fix for this up on GitHub:
https://github.com/SimpleMachines/SMF/pull/8332/commits/e52ac37a9efcd458ae4ae8392ce8b818e125c461

As usual, when the real fix goes in via an official patch, you'd need to reverse any temporary fixes before applying the patch.
A question worth asking is born in experience & driven by necessity. - Fripp

shawnb61

Reporting back that we've been using fix noted above on our forum in prod & it has been working fine.

This bug kind of blew up on our forum once folks noticed it...  Repeated backstage discussions...  It became a thing... 

The bottom line is that, for non-admins, if post moderation is active, searching within a topic excludes all posts made by other people where the message id is greater than the forum's largest topic id. 

On my forum, the largest topic id, when used as a message id, points to a post from March, 2012.  So searching within a topic excluded all posts after March, 2012.

The post moderation check is intended to exclude unapproved posts from user results, unless the post or the topic was created by the user doing the search.  I.e., if you try to reproduce this by making some posts & terms, and do a search, the search will be successful because it will always return your own posts/topics (approved or not).  And of course the filter does not apply to admins.  I think this is why folks had a hard time reproducing this.

This bug goes all the way back to 2.0 and affects all SMF search types.  For a deeper explanation, e.g., why I believe SMF did that check in such an odd way, see https://github.com/SimpleMachines/SMF/issues/7870.
A question worth asking is born in experience & driven by necessity. - Fripp

Advertisement: