No Code Attached Yet bug
avatar MSGroupFM
MSGroupFM
2 May 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']);

avatar MSGroupFM MSGroupFM - open - 2 May 2024
avatar joomla-cms-bot joomla-cms-bot - change - 2 May 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 May 2024
avatar MSGroupFM MSGroupFM - change - 2 May 2024
The description was changed
avatar MSGroupFM MSGroupFM - edited - 2 May 2024
avatar MSGroupFM MSGroupFM - change - 2 May 2024
The description was changed
avatar MSGroupFM MSGroupFM - edited - 2 May 2024
avatar chmst
chmst - comment - 6 May 2024

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

avatar Fedik Fedik - change - 6 May 2024
Labels Added: bug
avatar Fedik Fedik - labeled - 6 May 2024
avatar Hackwar Hackwar - change - 6 May 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-05-06 16:15:57
Closed_By Hackwar
avatar Hackwar Hackwar - close - 6 May 2024
avatar Hackwar
Hackwar - comment - 6 May 2024

Please test #43398 which fixes this.

Add a Comment

Login with GitHub to post a comment