Skip to content

[BUG] Pages with extreme quanities of a search term cause search formatting to timeout #5863

@Mikrz

Description

@Mikrz

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.

  1. 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.
  2. 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:

Image

is absolute insanity to put in a wiki page, but unfortunately people always find a way...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions