- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.3k
 
Closed
Labels
Milestone
Description
One of my organization's DBA's had created an SQL refactoring page containing many thousands of UPDATE statements, which broke Bookstack search any time someone searched for the term "update". I tracked down the timeout to the search term highlighting function, as it does not appear to have any limit to how many terms it will search for.
This is understandable, as there should not be multi-thousand hit documents uploaded in this manner, but unfortunately once it happened it was not obvious where the problem was.
I believe one of two options (or both) would be a good way to make this a bit more manageable.
- Add a limit to the number of instances of a term to hightlight, maybe 20 to 30, and move on to the next document once this limit is reached. This would be rather easy to implement as an additional condition to the while statement.
 - Flag documents passing this limit, or a much higher limit, to indicate to users and admins that this particular search result has an extreme number of hits for the given search term. This is clearly much more work, both in logic and UI adjustment.
 
| protected function getMatchPositions(string $text, array $terms): array | 
I fully understand that this:
is absolute insanity to put in a wiki page, but unfortunately people always find a way...