Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-22155: Search suggest not working in private wikis #3117

Merged
merged 4 commits into from
May 17, 2024

Conversation

pjeanjean
Copy link
Contributor

Jira URL

https://jira.xwiki.org/browse/XWIKI-22155

Changes

Description

  • Refactor searchSuggest.js by moving its Velocity code to XWiki.SearchSuggestCode

Clarifications

The Velocity code that returns the sources for search suggest can't work properly from a webjar because the context user is not propagated. The refactor fixes this issue.

Screenshots & Video

N/A

Executed Tests

The patch was applied manually to an instance with the main wiki private.

Expected merging strategy

  • Prefers squash: Yes

* Extract Velocity code from searchSuggest.js to XWiki.SearchSuggestCode
Copy link
Contributor

@michitux michitux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks good, I'm wondering about a few things:

  1. Would it be possible to also replace the few remaining Velocity calls by using the JavaScript localization API? Then Velocity parsing could be disabled.
  2. Is creating a wiki page to get the JSON our best practice, in particular if we load them on every request? Also, most likely, the sources are only needed on very few page loads. I wonder if it would make sense to delay loading the sources until results shall actually be requested. This would improve performance, reduce data transfer, improve sustainability, ...

* Remove all remaining Velocity code from searchSuggest.js
* Improve security
* Replace JQuery with fetch API
@pjeanjean
Copy link
Contributor Author

Is creating a wiki page to get the JSON our best practice, in particular if we load them on every request?

It made sense to me when I started considering that the list of available sources could be dynamic and tied to the user rights. I'm interested if you have other suggestions.

@michitux
Copy link
Contributor

It made sense to me when I started considering that the list of available sources could be dynamic and tied to the user rights. I'm interested if you have other suggestions.

I don't think the sources are actually tied to rights, it is just that in a private wiki no documents are accessible and thus also the sources aren't accessible. Otherwise, all sources are just stored in one document and this document should - under normal circumstances - not be restricted in any way.

What I was more wondering is if implementing such a data source as document is our best practice or if, e.g., a REST API would better match our current best practices (but I really don't know).

* Fix removed escaping
* Clean javascript.vm
@surli surli merged commit 5b4051e into xwiki:master May 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants