? ? Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
24 May 2018

This PR tries to fix #20252.

This PR introduces a new event, "onFinderResult", which takes a single result object and the search query object. This allows plugins to modify the results (for example changing MIME types, link types, adding additional data, etc.) and in this case it allows the highlight plugin to modify the URL of the link of the search result to add the highlight parameter. This decouples the highlight system plugin from com_finder.

The downside in this case is, that the URL, that is displayed below the search result, now also contains the highlight parameter. I would say that we should rework the output of the results anyway, but that would be the topic of another PR.
The FinderIndexerResult object has both an url and route attribute and we are now using url for display purposes and route for the links href.
I also tried to change a few of the calls to the new namespaced versions.

[UPDATE]
In further reviews, I also found out the issue why searchwords with utf8 characters are not properly highlighted. It turns out that OutputFilter::stringJSSafe() is not utf8 aware and I had to rewrite it. Now it properly encodes this into a utf8 escaped string.

[UPDATE]
Yet another update regarding the url and route: url is actually the ID of the item and thus can not be used. Instead I added cleanurl instead.

How to test

  • Test smart search and see the highlighting parameter in the URL of the search results.
  • Apply the patch and see that it works as before, except that the additional highlight parameter is in the URL below the result.
  • This PR mainly needs a codereview.
avatar Hackwar Hackwar - open - 24 May 2018
avatar Hackwar Hackwar - change - 24 May 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 May 2018
Category Front End com_finder Plugins
avatar Hackwar Hackwar - change - 24 May 2018
Labels Added: ?
avatar carlitorweb
carlitorweb - comment - 24 May 2018

I got this. This PR depend of other?
error-1055--joomla-4devtparent-id--isn-t-in-group-by---google-chrome

avatar Hackwar
Hackwar - comment - 24 May 2018

No, but there is another bug that is fixed in #20185. Looks like this strict query handling was disabled again in a later version of 4.0-dev. Idk. Maybe update your 4.0-dev branch to the current state? It works there...

avatar carlitorweb
carlitorweb - comment - 24 May 2018

I test now without this PR, and give the same error. So, is not this PR. And yes, the branch is up to the current state

avatar carlitorweb
carlitorweb - comment - 24 May 2018

Ok, the error I get is fixed here #20185. Beside code review will be good test this, but we need #20185 merged for that

avatar Hackwar
Hackwar - comment - 12 Jun 2018

#20185 has been merged in here. Happy testing. 😄

avatar carlitorweb
carlitorweb - comment - 18 Jun 2018

Got this:
Warning: Invalid argument supplied for foreach() in .....components\com_finder\tmpl\search\default_results.php on line 49

avatar carlitorweb
carlitorweb - comment - 18 Jun 2018

All work ok. Waiting for the fix of the error

avatar Hackwar
Hackwar - comment - 18 Jun 2018

This was a bug because of a conflict between the original code and #20185. In #20185 it was changed to "Items" and somehow that change was overwritten here. Should work now.

avatar carlitorweb carlitorweb - test_item - 18 Jun 2018 - Tested successfully
avatar carlitorweb
carlitorweb - comment - 18 Jun 2018

I have tested this item successfully on a52bd58


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20571.

avatar Hackwar Hackwar - change - 23 Jun 2018
The description was changed
avatar Hackwar Hackwar - edited - 23 Jun 2018
avatar Hackwar
Hackwar - comment - 23 Jun 2018

I've updated the PR and fixed some things. It would be nice if you could test this again and if we could get one more tester for this. 😄

avatar Quy
Quy - comment - 23 Jun 2018

The URLs don't match where the only difference should be the highlight query string.

http://localhost/joomla-cms-j4finder_highlighter/index.php/blog/5-your-modules?highlight=WyJqb29tbGEiXQ==

http://localhost/joomla-cms-j4finder_highlighter/index.php/component/content/article/5-your-modules
avatar Hackwar
Hackwar - comment - 23 Jun 2018

The issue here is, that FinderIndexerAdapter::getURL() returns the wrong URL. That method should actually be deprecated... We have to fix the finder plugins for that.

avatar Hackwar
Hackwar - comment - 26 Jun 2018

I've changed the way the URLs are produced, which should fix the issue that you had and also cleaned up the result layout. Please test again.

avatar Hackwar
Hackwar - comment - 26 Jun 2018

Please delay that. I made a mistake. I will report back when I fixed the issue.

avatar joomla-cms-bot joomla-cms-bot - change - 27 Jun 2018
Category Front End com_finder Plugins Administration com_finder Front End Plugins
avatar Hackwar
Hackwar - comment - 27 Jun 2018

Ok, I got this right now. I removed the FinderIndexerHelper::getContentPath() method, since we don't need that with the new router anymore. I also cleaned up the finder plugins and improved the comments there. Last but not least, I added a cleanURL attribute after unserialising the object in the model, where I simply copy the route attribute to this. That allows us to render the clean URL in the result layout and at the same time allow the highlighter plugin to add to the URL.

So please test and have a go. 😄

avatar joomla-cms-bot joomla-cms-bot - change - 27 Jun 2018
Category Front End com_finder Plugins Administration Administration com_finder Front End Libraries Plugins
avatar Hackwar Hackwar - change - 27 Jun 2018
The description was changed
avatar Hackwar Hackwar - edited - 27 Jun 2018
avatar Hackwar
Hackwar - comment - 27 Jun 2018

Since @infograf768 requested this, I also reviewed the highlighting of search words with utf8 chars in the search results page. It turns out that \Joomla\CMS\Filter\OutputFilter::stringJSSafe() is not utf8 aware and mangles all characters that are not ASCII. I rewrote that and now it should work fine for utf8. Looking for your test, @infograf768 😉

avatar infograf768
infograf768 - comment - 28 Jun 2018

@Hackwar
Indeed, the issue was whether in js or the method ( #20562 (comment) ).

You solved it here and utf8 is now correctly highlighted. 👍

Remains an issue here with terms surrounded by doublequotes or singlequotes. If one does not search WITH the quotes, i.e. for example 'frontale (term in text is 'frontale') then we have no suggestion. If I enter frontale no suggestion and no result but I am proposed to search for 'frontale'.
(That issue does not exist in com_search although highlighting is broken for com_search in 4.0. Works on 3.x)

avatar Hackwar
Hackwar - comment - 28 Jun 2018

The suggestions have nothing to do with highlighting. I hope no one now gets confused and delays this PR because you are bringing up unrelated bugs here.

avatar infograf768
infograf768 - comment - 28 Jun 2018

I sincereley hope not. As usual I test a few things when I test any of your PRs. Just consider it as a note about something to remember if it can be solved or not.

As I only tested the highlighting and not the hardcoupling issue, I can't set the my test as OK on issues.joomla.org

avatar carlitorweb
carlitorweb - comment - 28 Jun 2018

About search for specific phrases, we can continue this talk in #20384 , is where @Hackwar change this.

avatar carlitorweb carlitorweb - test_item - 28 Jun 2018 - Tested successfully
avatar carlitorweb
carlitorweb - comment - 28 Jun 2018

I have tested this item successfully on 9834dd9


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20571.

avatar infograf768 infograf768 - test_item - 29 Jun 2018 - Tested successfully
avatar infograf768
infograf768 - comment - 29 Jun 2018

I have tested this item successfully on 9834dd9

@laoneo @mbabker
This PR is fine concerning the highlighting of terms. But I have no idea about the decoupling.

Can you have a look at that aspect and set RTC/Merge if OK?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20571.

avatar Hackwar
Hackwar - comment - 29 Jun 2018

Since this is more or less broken code and potentially creates wrong URLs, this code will not work in 4.0 anymore. Plugins from 3.x can't use it anymore and shouldn't use it now already.Am 29.06.2018 07:56 schrieb Allon Moritz notifications@github.com:@laoneo commented on this pull request.

In plugins/finder/categories/categories.php:

@@ -304,8 +306,6 @@ protected function index(FinderIndexerResult $item, $format = 'html')
$item->route = ContentHelperRoute::getCategoryRoute($item->id, $item->language);
}

  •   $item->path = FinderIndexerHelper::getContentPath($item->route);
    

Is this removal necessary then or can J3 plugins still work with that code in place?

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

avatar laoneo
laoneo - comment - 29 Jun 2018

Is it then deprecated in J3?

avatar Hackwar
Hackwar - comment - 29 Jun 2018

I'm going to create a depreciation PR soon.Am 29.06.2018 09:26 schrieb Allon Moritz notifications@github.com:Is it then deprecated in J3?

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

avatar Hackwar
Hackwar - comment - 29 Jun 2018

PR for deprecation: #20934

avatar Hackwar Hackwar - change - 4 Jul 2018
The description was changed
avatar Hackwar Hackwar - edited - 4 Jul 2018
avatar carlitorweb
carlitorweb - comment - 6 Jul 2018

I have tested this item successfully on 55057f2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20571.

avatar carlitorweb carlitorweb - test_item - 6 Jul 2018 - Tested successfully
avatar infograf768 infograf768 - test_item - 6 Jul 2018 - Tested successfully
avatar infograf768
infograf768 - comment - 6 Jul 2018

I have tested this item successfully on 55057f2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20571.

avatar infograf768 infograf768 - change - 6 Jul 2018
Status Pending Ready to Commit
avatar infograf768
infograf768 - comment - 6 Jul 2018

RTC. Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20571.

avatar Hackwar
Hackwar - comment - 6 Jul 2018

Thank you!

avatar laoneo laoneo - change - 6 Jul 2018
Labels Added: ?
avatar laoneo laoneo - change - 6 Jul 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-07-06 14:24:13
Closed_By laoneo
avatar laoneo laoneo - close - 6 Jul 2018
avatar laoneo laoneo - merge - 6 Jul 2018

Add a Comment

Login with GitHub to post a comment