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-20632: Page searched by its exact name is not found in a page picker for a macro parameter when its subtree is larger than 10 pages #2945

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Member

Choose a reason for hiding this comment

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

Small note but there's no unit test for this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there do not seem to be any unit tests for this class.

Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,20 @@ protected List<SearchResult> searchPages(List<SearchScope> searchScopes, String
.equals("space")) ? "" : ", doc." + orderField;
}

String addSpace = "";
if (searchScopes.contains(SearchScope.NAME)) {
// Join the space to get the last space name.
addSpace = "left join XWikiSpace as space on doc.space = space.reference";
}

if (space != null) {
f.format("select distinct doc.fullName, doc.space, doc.name, doc.language");
f.format(addColumn);
f.format(" from XWikiDocument as doc where doc.space = :space and ( ");
f.format(" from XWikiDocument as doc %s where doc.space = :space and ( ", addSpace);
} else {
f.format("select distinct doc.fullName, doc.space, doc.name, doc.language");
f.format(addColumn);
f.format(" from XWikiDocument as doc where ( ");
f.format(" from XWikiDocument as doc %s where ( ", addSpace);
}

/* Look for scopes related to pages */
Expand All @@ -196,8 +202,8 @@ protected List<SearchResult> searchPages(List<SearchScope> searchScopes, String
acceptedScopes++;
break;
case NAME:
String matchTerminalPage = "doc.name <> :defaultDocName and upper(doc.fullName) like :keywords";
String matchNestedPage = "doc.name = :defaultDocName and upper(doc.space) like :keywords";
String matchTerminalPage = "doc.name <> :defaultDocName and upper(doc.name) like :keywords";
String matchNestedPage = "doc.name = :defaultDocName and upper(space.name) like :keywords";
f.format("((%s) or (%s)) ", matchTerminalPage, matchNestedPage);
acceptedScopes++;
break;
Expand Down