Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Facets results is sorted incorrectly then there are more then one sort processor enabled.
Results are sorted with last processor.
That's is because all processors in build stage are running by in self and sort processors rewrite previous results.
All sort processor's callbacks should be applied for result item pair. And the first value which is not equal 0 should be returned to apply sort.
Maybe we need new stage - sorting. After build stage run sorting with enabled processors.
Comment | File | Size | Author |
---|---|---|---|
#88 | facet_s_results_sorting-2656668-1.patch | 31.5 KB | borisson_ |
#66 | facet_s_results_sorting-2656668-66.patch | 70.43 KB | borisson_ |
Comments
Comment #2
borisson_Writing a testcase to test the expected behavior.
Comment #3
borisson_I'm actually not sure what the expected result for the third added test here should be. At least there's a way to test this now. That's great.
Setting to NR so the bot can take a look at the patch, but we first need to have some consensus on how to resolve this.
Comment #6
borisson_Comment #7
borisson_The test added here should be moved to the
ProcessorIntegrationTest
, introduced in #2680301: Expand processor test coverage..We should also still figure out how to fix this issue.
Comment #8
borisson_I did what I said in #7. Moved tests.
Comment #11
borisson_We discussed this and I'll post a patch with some work tomorrow.
Comment #12
borisson_Just checking in some work. Unit tests already pass again. Everything else is still very much broken.
Comment #15
borisson_This fixes more of the tests, still not ready to actually review.
Comment #18
borisson_Saving works again, but there's a problem in the config that I can't figure out yet.
Trying to figure out how to fix that. I still have to figure out how to do multiple sorts.
Comment #21
Evaldas UžkurasMaybe we should save processors config directly to processors instead of created new dimension in array with key 'settings',
I have added a proposal, how to make it.
Using that way, we can get config's value using:
Comment #22
Evaldas UžkurasI have made the proposal for applying multiple sorts.
Maybe it would be helpful.
Comment #23
borisson_Not sure about #21, I'll look at that suggestion tomorrow.
#22 looked great and I implemented that and adapted the unit tests as well.
Comment #26
borisson_Comment #27
borisson_Comment #32
borisson_#27 doesn't look like it'll help. So the next patch'll be based on #26.
Comment #33
borisson_I spent more time on this, but I can't figure out how to fix those config errors.
I changed some small things for coding standards in the patch.
Comment #36
borisson_I rolled a new patch after the last commits, still no idea how to resolve the config errors.
Comment #39
borisson_Adding to the plugin_type file
Comment #42
borisson_reroll.
Comment #45
borisson_This is the correct patch, that was a search api patch.
Comment #48
borisson_Needed a reroll, so let's try again.
Comment #51
borisson_Rerolling is not my strongest suit.
Comment #54
borisson_We should be back to only having config errors.
Comment #57
borisson_Comment #60
borisson_I can't figure it out, but this line is not needed, so removing that. Still the same fails.
Comment #61
borisson_Marking this with higher priority. It's a big config change that needs to be fixed.
Comment #62
StryKaizerComment #63
borisson_This needed a rebase.
Comment #66
borisson_Another reroll.
Comment #69
StryKaizerFollowing code is another approuch, no seperate sorting plugin used here.
This should work, no tests fixxed yet, needs work. Also tests from #66 should be ported in this patch if we pick this route.
Comment #72
borisson_Ported test from #66, fixed unit tests as well.
Comment #73
borisson_Comment #78
borisson_I don't see the fail in testResultSorting locally.
Comment #81
StryKaizerComment #82
borisson_This looks great, but since this is such a big change, I'll leave it open for a couple of days for additional feedback. I love how the last patch is less than half the size of the one in #66 and that is deletes a bunch of code as well.
Comment #83
claudiu.cristeaMinors.
Let's investigate this in a separate issue and refer the new issue in the @todo. I think it's important to find out what's going on with that as it might affect other functionalities.
Until fixing
getProcessorsByStage()
: Let's move this outsideforeach () {...}
. It doesn't make sense to call that method on every processor. We get the list once, before foreach.We try to not call any function/method during throwing an exception because that can cause other unexpected errors, obscuring the main exception. Just use the string in double quotes an inject variables with {}. Probably
"The processor {$processor->getPluginDefinition()['id']} has a build definition but doesn't implement the required BuildProcessorInterface interface"
?Is this module in BC mode? Hope not, otherwise we break other modules implementing this interface.
Comment #84
borisson_#83:
3. Oh, I didn't realize that, we should do that in other places as well.
4. We've released 2 alpha versions and haven't promised to keep bc yet, so we're good on that front.
Comment #85
claudiu.cristeaApart from #83, I tested the patch and works as expected.
Comment #86
borisson_#83
Thanks for the review @claudiu.cristea!
Comment #87
claudiu.cristea@borisson_, thank you.
Hm. I still believe that this comment is valuable. Why? Because after #2722267: Fix Facet::getProcessorsByStage is fixed we need to get back here and fix this (probably in a follow-up). So, I would keep the @todo comment and add also a
@see https://www.drupal.org/node/2722267
. In this case we need to indent the 2nd line of the @todo comment by 2 spaces.Comment #88
borisson_Sure, that makes sense.
Comment #89
claudiu.cristeaComment #91
borisson_Comitted and pushed, thanks for the patches and reviews!