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

Highlight plugin breaks links with #fragment in search results #43417

Closed
MSGroupFM opened this issue May 2, 2024 · 2 comments
Closed

Highlight plugin breaks links with #fragment in search results #43417

MSGroupFM opened this issue May 2, 2024 · 2 comments

Comments

@MSGroupFM
Copy link

MSGroupFM commented May 2, 2024

Steps to reproduce the issue

My finder plugin indexes paragraphs of content and links to headings with the specified anchors. But if you enable the highlight_terms parameter in the finder settings, then the links will not lead to a fragment of the article.

Indexed links look like:
index.php?option=com_content&view=article&id=56#anchor

Expected result

In finder search results i expected links with SEF:
/pages/article-alias?0=highlight&1=WyJcdTA0MzdcdTA0MzBcdTA0MzJcdTA0MzVcdTA0MzRcdTA0MzVcdTA0M2RcdTA0MzhcdTA0NGYiXQ==#anchor

Actual result

/pages/article-alias#anchor&highlight=WyJcdTA0MzdcdTA0MzBcdTA0MzJcdTA0MzVcdTA0MzRcdTA0MzVcdTA0M2RcdTA0MzhcdTA0NGYiXQ==

Query with highlight is simply added to the end of the link

System information (as much as possible)

Joomla! 5.1.0
PHP 8.2

Additional comments

Fix this with code in file plugins/system/highlight/src/Extension/Highlight.php

Old code
$item->route .= '&highlight=' . base64_encode(json_encode(\array_slice($query->highlight, 0, 10)));

New code
$uri = new Uri($item->route); $uri->setQuery(array_merge($uri->getQuery(true), ['highlight' => base64_encode(json_encode(\array_slice($query->highlight, 0, 10)))])); $item->route = $uri->toString(['path', 'query', 'fragment']);

@chmst
Copy link
Contributor

chmst commented May 6, 2024

Thanks for reporting! Would you like to make PR by Yourself?

@Fedik Fedik added the bug label May 6, 2024
@Hackwar
Copy link
Member

Hackwar commented May 6, 2024

Please test #43398 which fixes this.

@Hackwar Hackwar closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants