I'm not completely sure, haven't looked into this in detail (and also don't know this module that well), but it seems you're currently not checking whether the search server supports the search_api_facets feature before allowing the configuration of facets. (In D7, there was also search_api_facets_operator_or needed for creating "OR" facets.) It's only checked when altering the query – which is of coruse better than nothing, but a bit late.

Also, this module should somewhere define those features (or "that feature", if you want to make "OR" support mandatory), so implementing backends know what they're supposed to do. See the D7 code for an example/blueprint. You can, of course, also renamed the feature to just "facets", based on the new project name and code location – that's up to you. It's just that backend features should be properly defined somewhere – otherwise it becomes guesswork.

Tasks

Tasks we need to do to fix this issue completely:

  • Fix upgrade path
  • Reproduce test failures (UrlIntegrationTest + Functional\FacetSourceTest) (CentOS)
  • #135 Change the display ID as discussed in #110 and fix the test fails that introduced (#111)
CommentFileSizeAuthor
#170 search_api_integration-2772745-169.patch74.69 KBborisson_
#170 interdiff.txt1.97 KBborisson_
#168 search_api_integration-2772745-168.patch74.27 KBborisson_
#168 interdiff.txt1.7 KBborisson_
#161 search_api_integration-2772745-161.patch73.55 KBborisson_
#161 interdiff.txt1.38 KBborisson_
#159 search_api_integration-2772745-159.patch73.06 KBborisson_
#159 interdiff.txt1.69 KBborisson_
#158 search_api_integration-2772745-158.patch72.37 KBborisson_
#158 test-only.patch1.49 KBborisson_
#155 search_api_integration-2772745-155.patch71.09 KBborisson_
#155 interdiff.txt2.74 KBborisson_
#153 search_api_integration-2772745-153.patch70.61 KBborisson_
#153 interdiff.txt898 bytesborisson_
#152 interdiff-142-152.txt902 bytesdermario
#152 search_api_integration-2772745-152.patch70.04 KBdermario
#150 facets-upgrade-problem.png196.2 KBdermario
#145 interdiff-2772745-142-144.txt1 KBjespermb
#145 2772745-144.patch63.35 KBjespermb
#142 search_api_integration-2772745-142.patch70.02 KBborisson_
#142 interdiff.txt3.65 KBborisson_
#139 search_api_integration-2772745-139.patch62.84 KBborisson_
#139 interdiff.txt14.08 KBborisson_
#134 test-output.txt23.36 KBdermario
#132 search_api_integration-2772745-132.patch67.54 KBborisson_
#132 interdiff-107-132.txt1.5 KBborisson_
#131 interdiff-107-131.txt1.98 KBdermario
#131 search_api_integration-2772745-131.patch67.66 KBdermario
#129 interdiff-107-129.txt1.1 KBdermario
#129 search_api_integration-2772745-129.patch66.78 KBdermario
#128 interdiff-107-128.patch1.1 KBdermario
#128 search_api_integration-2772745-128.patch66.78 KBdermario
#126 search_api_integration-2772745-126.patch59.93 KBborisson_
#124 search_api_integration-2772745-124.patch67.49 KBborisson_
#119 search_api_integration-2772745-119.patch54.62 KBsukanya.ramakrishnan
#119 interdiff.txt1.17 KBsukanya.ramakrishnan
#118 search_api_integration-2772745-118.patch54.12 KBsukanya.ramakrishnan
#111 search_api_integration-2772745-111.patch67.32 KBborisson_
#111 interdiff.txt3.77 KBborisson_
#107 search_api_integration-2772745-107.patch59.93 KBborisson_
#107 interdiff.txt1.37 KBborisson_
#106 search_api_integration-2772745-104--reupload.patch61.3 KBborisson_
#104 search_api_integration-2772745-104.patch61.3 KBborisson_
#104 interdiff.txt1.17 KBborisson_
#101 search_api_integration-2772745-101.patch68.8 KBborisson_
#101 interdiff.txt3.25 KBborisson_
#98 search_api_integration-2772745-98.patch68.34 KBborisson_
#98 interdiff.txt5.76 KBborisson_
#97 search_api_integration-2772745-97.patch67.26 KBborisson_
#97 interdiff.txt1.93 KBborisson_
#95 search_api_integration-2772745-95.patch67.16 KBborisson_
#95 interdiff.txt3.45 KBborisson_
#94 2772745-94--search_api_facet_source_overhaul.patch65.95 KBdrunken monkey
#94 2772745-94--search_api_facet_source_overhaul--interdiff.txt3.18 KBdrunken monkey
#93 search_api_integration-2772745-93.patch65.78 KBborisson_
#93 interdiff.txt10.61 KBborisson_
#92 search_api_integration-2772745-92.patch57.84 KBborisson_
#92 interdiff.txt2.34 KBborisson_
#90 search_api_integration-90.patch55.49 KBborisson_
#90 interdiff.txt5.54 KBborisson_
#87 search_api_integration-2772745-87.patch58.9 KBborisson_
#87 interdiff.txt2.21 KBborisson_
#85 search_api_integration-2772745-85.patch50.37 KBborisson_
#85 interdiff.txt2.5 KBborisson_
#83 search_api_integration-2772745-83.patch48.72 KBborisson_
#79 search_api_integration-2772745-79.patch57.09 KBborisson_
#79 interdiff.txt1.44 KBborisson_
#77 search_api_integration-2772745-76.patch55.65 KBborisson_
#76 search_api_integration-2772745-76.patch55.65 KBborisson_
#76 interdiff.txt808 bytesborisson_
#75 search_api_integration-2772745-75.patch54.86 KBborisson_
#75 interdiff.txt1.25 KBborisson_
#74 search_api_integration-2772745-74.patch54.06 KBborisson_
#74 interdiff.txt2.03 KBborisson_
#73 search_api_integration-2772745-73.patch52.03 KBborisson_
#68 search_api_integration-2772745-68.patch51.85 KBborisson_
#68 interdiff.txt1016 bytesborisson_
#65 search_api_integration-2772745-65.patch50.86 KBborisson_
#65 interdiff.txt5.2 KBborisson_
#63 search_api_integration-2772745-63.patch50.63 KBborisson_
#63 interdiff.txt1.46 KBborisson_
#60 search_api_integration-2772745-60.patch50.3 KBborisson_
#60 interdiff.txt1.58 KBborisson_
#58 search_api_integration-2772745-58.patch49.35 KBborisson_
#58 interdiff.txt4.65 KBborisson_
#55 search_api_integration-2772745-54.patch39.68 KBborisson_
#53 search_api_integration-2772745-53.patch46.55 KBborisson_
#53 interdiff.txt2.71 KBborisson_
#50 search_api_integration-2772745-50.patch38.19 KBborisson_
#50 interdiff.txt958 bytesborisson_
#47 search_api_integration-2772745-47.patch37.25 KBborisson_
#47 interdiff.txt782 bytesborisson_
#44 search_api_integration-2772745-44.patch37.27 KBborisson_
#44 interdiff.txt4.72 KBborisson_
#41 search_api_integration-2772745-41.patch32.66 KBborisson_
#38 search_api_integration-2772745-38.patch32.77 KBborisson_
#35 search_api_integration-2772745-35.patch34.48 KBborisson_
#35 interdiff.txt1.82 KBborisson_
#35 interdiff-plugin-manager.txt1.2 KBborisson_
#32 search_api_integration-2772745-32.patch31.57 KBborisson_
#32 interdiff.txt4.17 KBborisson_
#28 search_api_integration-2772745-28.patch27.41 KBborisson_
#28 interdiff.txt1.08 KBborisson_
#25 search_api_integration-2772745-25.patch27.36 KBborisson_
#25 interdiff.txt7.42 KBborisson_
#19 2772745-18--search_api_integration.patch19.84 KBdrunken monkey
#19 2772745-18--search_api_integration--interdiff.txt1.2 KBdrunken monkey
#18 2772745-17--search_api_integration.patch19.91 KBdrunken monkey
#18 2772745-17--search_api_integration--interdiff.txt17.08 KBdrunken monkey
#15 search_api_integration-2772745-15.patch8.9 KBborisson_
#15 interdiff.txt604 bytesborisson_
#12 search_api_integration-2772745-12.patch8.89 KBborisson_
#12 interdiff.txt2.18 KBborisson_
#9 search_api_integration-2772745-9.patch7.27 KBborisson_
#9 interdiff.txt1.66 KBborisson_
#6 search_api_integration-2772745-6.patch7.29 KBborisson_
#6 interdiff.txt7.5 KBborisson_
#4 search_api_integration-2772745-4.patch2.33 KBborisson_

Comments

drunken monkey created an issue. See original summary.

borisson_’s picture

Priority: Normal » Critical
borisson_’s picture

You're absolutely right. We should do this.

borisson_’s picture

Status: Active » Needs review
StatusFileSize
new2.33 KB

I'm not sure, but I think we should make support for "or" facets mandatory.
I included some code that should do this.
It's not tested but I think this is the right place to do this?

drunken monkey’s picture

Yes, that looks quite good. Instead of loading the view, though, you could also just create the search display plugin instance and call getIndex() on that. But should be fine either way.

On a different note, though: I would actually suggest getting completely rid of the disctinction of Views searches, and just have a single Search API facet source plugin (with a deriver creating one definition for every search display). Do you really need the view, etc., information? Can't you just use the search display plugin for everything you need?

If not, then maybe we just have to amend the search display for that, but I thought that was the whole point of the exercise – standardizing on a way for other modules to interact with search displays, no matter what modules provide them.
(Would of course have been better to make these changes to search display plugins before going to Beta, but should still be possible. Will probably just affect Kristof at this point.)

But all of that should probably be a separate issue. And might already be a bit late at this point.

borisson_’s picture

StatusFileSize
new7.5 KB
new7.29 KB

I think this does what @drunken monkey suggested, let's see what our tests think.

Status: Needs review » Needs work

The last submitted patch, 6: search_api_integration-2772745-6.patch, failed testing.

The last submitted patch, 6: search_api_integration-2772745-6.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB
new7.27 KB

Status: Needs review » Needs work

The last submitted patch, 9: search_api_integration-2772745-9.patch, failed testing.

The last submitted patch, 9: search_api_integration-2772745-9.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new2.18 KB
new8.89 KB

Status: Needs review » Needs work

The last submitted patch, 12: search_api_integration-2772745-12.patch, failed testing.

The last submitted patch, 12: search_api_integration-2772745-12.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new604 bytes
new8.9 KB
borisson_’s picture

I think we can do the renames of the plugins in a later followup and see if we can implement the search api pages displays as well. I think otherwise these changes look good. Needs confirmation though.

drunken monkey’s picture

Why still make this view-specific? Seems like it could just be one class plus one deriver for all Search API displays. (Would also, e.g., make the Search Pages' facet source implementation unnecessary.)
Patch with my suggestion attached, will probably break some tests, though.
And, of course, it's your call in the end. I just thought that's what we introduced the Search API display plugins for – abstracting from the different kinds of search displays, so that other modules don't have to care about them.

I would also suggest not sorting the plugins right in the deriver – see #2758321: Clean up deriver code. A lot of code doesn't need them sorted, so you should only sort them when needed. (And, in that case, you probably want to sort all plugins, not just those derived from a specific base.)

drunken monkey’s picture

drunken monkey’s picture

StatusFileSize
new1.2 KB
new19.84 KB

Oops, messed up in calculateDependencies() – should use the display's base and derivative plugin ID, not the facet source's.
Anyways, I have a better suggestion: just let the display take care of that. (Would of course need a Search API patch to add that method and interface to the Views displays – but that should be easy. Although I guess there's no way to depend on a specific view display, which is a bit of a problem here.)

The last submitted patch, 18: 2772745-17--search_api_integration.patch, failed testing.

The last submitted patch, 18: 2772745-17--search_api_integration.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 19: 2772745-18--search_api_integration.patch, failed testing.

The last submitted patch, 19: 2772745-18--search_api_integration.patch, failed testing.

borisson_’s picture

The test fails here are because the base plugin changed from views_page to search_api. I'll do the find/replace later to fix the tests. Thanks for the patch - that looks great. I also think that we can now remove the facetsource plugin from search_api_page when this goes in. That sounds great!

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new7.42 KB
new27.36 KB

Changed tests.

Status: Needs review » Needs work

The last submitted patch, 25: search_api_integration-2772745-25.patch, failed testing.

The last submitted patch, 25: search_api_integration-2772745-25.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
new27.41 KB

Status: Needs review » Needs work

The last submitted patch, 28: search_api_integration-2772745-28.patch, failed testing.

The last submitted patch, 28: search_api_integration-2772745-28.patch, failed testing.

borisson_’s picture

Looks like fixing the tests wasn't as easy as I expected it to be. I don't have any more time to look at it before sunday - so if anyone else has time to pick this up in the meanwhile - be my guest.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new4.17 KB
new31.57 KB

So, it looks like the tests are failing because we usually equate the search_id to facetsource-id. Because this is no longer the case, this is currently not working. I currently don't know yet how to map the search_id to the facet source id.

Status: Needs review » Needs work

The last submitted patch, 32: search_api_integration-2772745-32.patch, failed testing.

The last submitted patch, 32: search_api_integration-2772745-32.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 KB
new1.82 KB
new34.48 KB

Maybe this works? I also added a processDefinition to the plugin manager so we are sure they have the display_id line in them.

Status: Needs review » Needs work

The last submitted patch, 35: search_api_integration-2772745-35.patch, failed testing.

The last submitted patch, 35: search_api_integration-2772745-35.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new32.77 KB

Reverted #35 since that doesn't seem to help at all.

Status: Needs review » Needs work

The last submitted patch, 38: search_api_integration-2772745-38.patch, failed testing.

The last submitted patch, 38: search_api_integration-2772745-38.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new32.66 KB

Patch no longer applied, reroll attached

Status: Needs review » Needs work

The last submitted patch, 41: search_api_integration-2772745-41.patch, failed testing.

The last submitted patch, 41: search_api_integration-2772745-41.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new4.72 KB
new37.27 KB

Status: Needs review » Needs work

The last submitted patch, 44: search_api_integration-2772745-44.patch, failed testing.

The last submitted patch, 44: search_api_integration-2772745-44.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new782 bytes
new37.25 KB

Status: Needs review » Needs work

The last submitted patch, 47: search_api_integration-2772745-47.patch, failed testing.

The last submitted patch, 47: search_api_integration-2772745-47.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new958 bytes
new38.19 KB

Status: Needs review » Needs work

The last submitted patch, 50: search_api_integration-2772745-50.patch, failed testing.

The last submitted patch, 50: search_api_integration-2772745-50.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new2.71 KB
new46.55 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 53: search_api_integration-2772745-53.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new39.68 KB

Status: Needs review » Needs work

The last submitted patch, 55: search_api_integration-2772745-54.patch, failed testing.

borisson_’s picture

The reason why the core search tests are failing is because it looks like an invalid plugin is being created for the search api plugins. I don't understand why though.

Maybe we should remove the ::processDefinition in the plugin manager? That's not a solution though, that's just removing the hard fail.

Anyway, that's enough for the day.

borisson_’s picture

Status: Needs work » Needs review
Issue tags: +Release blocker, +beta blocker
StatusFileSize
new4.65 KB
new49.35 KB

Since I was ill over the last week I haven't had a lot of time to work on this. At least not as much as I wanted.

Anyway, attached is what I did today, this should fix the unit tests and on my local machine it looks like the core search tests are fixed now as well.

Status: Needs review » Needs work

The last submitted patch, 58: search_api_integration-2772745-58.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.58 KB
new50.3 KB

Fixes rest test in the wrong way.

Status: Needs review » Needs work

The last submitted patch, 60: search_api_integration-2772745-60.patch, failed testing.

The last submitted patch, 60: search_api_integration-2772745-60.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.46 KB
new50.63 KB

fail: [Other] Line 129 of modules/facets/modules/rest_facets/src/Tests/RestIntegrationTest.php:
Value 'http://localhost/checkout/checkout/facets-rest?f[0]=type%3Aarticle' is equal to value 'http://localhost/checkout/facets-rest?f[0]=type%3Aarticle'.

The double checkout here is not working, so it looks like the changes I did in the QueryString Url processor broke things in fun ways. The tests don't seem to break when ran not in a subfolder.

Status: Needs review » Needs work

The last submitted patch, 63: search_api_integration-2772745-63.patch, failed testing.

borisson_’s picture

Issue tags: +#drupalironcamp
StatusFileSize
new5.2 KB
new50.86 KB

I had some time to work on this on the plane over to iron camp. The rest test is green now, as well as all the unit tests. Hopefully there will be no other fails.

This also reduced complexity in a couple of places by a little bit.

borisson_’s picture

Status: Needs work » Needs review

Setting to needs review for the testbot.

Status: Needs review » Needs work

The last submitted patch, 65: search_api_integration-2772745-65.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1016 bytes
new51.85 KB

UrlIntegrationTest is now green locally. The entire patch green by now?

borisson_’s picture

So the patch is green - all this needs is a review.

drunken monkey’s picture

I'm not an expert on Facets, but the changes look good to me in general.

However, unless I'm mistaken, you're missing one half of the issue title – I don't see a definition of the search_api_facets feature anywhere. Would be great if you could add that to README.txt, maybe along with an example service class documenting the exact structure – just see the Drupal 7 version [1][2].

Also, regarding calculateDependencies(), I'd recommend at least adding the index as a dependency if the display plugin doesn't define its own dependencies. (I know, that code is my own, but still.) But will also depend on the solution to #2831436: Add dependency information to display plugins, which I've now created – if that adds DependentPluginInterface directly to the DisplayPluginInterface, then this should always work, and you can even get rid of the if.

borisson_’s picture

Assigned: Unassigned » strykaizer
Issue tags: +Needs upgrade path

This needs an upgrade path (just to help people already building on this).

borisson_’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies and I screwed up my local branch. Needs a reroll.

borisson_’s picture

Issue tags: -Needs reroll
StatusFileSize
new52.03 KB

Reroll attached, looking into fixing #70.

borisson_’s picture

StatusFileSize
new2.03 KB
new54.06 KB

Looks like the patch I made in #73 doesn't work. Updating readme as requested in #70.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.25 KB
new54.86 KB
borisson_’s picture

StatusFileSize
new808 bytes
new55.65 KB
borisson_’s picture

StatusFileSize
new55.65 KB

Reuploading for testbot.

Status: Needs review » Needs work

The last submitted patch, 77: search_api_integration-2772745-76.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.44 KB
new57.09 KB

Status: Needs review » Needs work

The last submitted patch, 79: search_api_integration-2772745-79.patch, failed testing.

christianadamski’s picture

Hey,

just asking: Do you keep in mind that CoreViewsFacets and at least potentially other modules, like your CoreSearchFacets module, do not use Search API and therefor do not depend on it?

I understand that after all Solr is your main focus, but in a perfect world, facets would provide its functionality independently of the underlying data source and handle those in separate handlers, right?

If you want any support in that direction, I am very willing to help.

borisson_’s picture

@ChristianAdamski:

just asking: Do you keep in mind that CoreViewsFacets and at least potentially other modules, like your CoreSearchFacets module, do not use Search API and therefor do not depend on it?

I understand that after all Solr is your main focus, but in a perfect world, facets would provide its functionality independently of the underlying data source and handle those in separate handlers, right?

Yeah, Search API is the main focus. Not Solr specifically but also other search api backands (db, elasticsearch, ...). We try to keep in mind other facet sources can also be provided.
We don't (from memory) have any search api specific code other than in the FacetSource. Nothing in this issues creates a closer coupling with Search API.

If we do have a place where we the coupling is too tight, could you open up a new issue? this issue is already a nightmare and I want to keep the suffering for this specifically as short as possible (even though it looks like I probably won't get to fix this before my vacation between christmas and new years).

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new48.72 KB

Reroll.

Status: Needs review » Needs work

The last submitted patch, 83: search_api_integration-2772745-83.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new2.5 KB
new50.37 KB

Status: Needs review » Needs work

The last submitted patch, 85: search_api_integration-2772745-85.patch, failed testing.

borisson_’s picture

StatusFileSize
new2.21 KB
new58.9 KB

Reroll + small changes for new tests.

borisson_’s picture

Status: Needs work » Needs review

go testbot, go!

Status: Needs review » Needs work

The last submitted patch, 87: search_api_integration-2772745-87.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new5.54 KB
new55.49 KB

I fixed the kernel tests.

Status: Needs review » Needs work

The last submitted patch, 90: search_api_integration-90.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new2.34 KB
new57.84 KB

I think all tests are green now.

borisson_’s picture

StatusFileSize
new10.61 KB
new65.78 KB

Cleanup + comments + small changes. I'm not going to touch this (or commit anything else) until we get reviews in.

drunken monkey’s picture

StatusFileSize
new3.18 KB
new65.95 KB
diff --git a/src/FacetManager/DefaultFacetManager.php b/src/FacetManager/DefaultFacetManager.php
index 273f3cb..c7331e6 100644
--- a/src/FacetManager/DefaultFacetManager.php
+++ b/src/FacetManager/DefaultFacetManager.php
@@ -148,6 +148,10 @@ class DefaultFacetManager {
    *   The facet source ID to process.
    */
   public function alterQuery(&$query, $facetsource_id) {
+    if ($this->getFacetsByFacetSourceId($facetsource_id) === []) {
+      return;
+    }
+
     /** @var \Drupal\facets\FacetInterface[] $facets */
     foreach ($this->getFacetsByFacetSourceId($facetsource_id) as $facet) {

That's not only unrelated, but also doesn't really get us anything. If it's an empty array, the foreach will be a no-op anyways. I'd remove it again – this is just adding lines without use. (Would be another thing if the return value could be FALSE/NULL – but apparently that's not the point of the change.)
I'd also call the variable $facet_source_id (additional underscore), but that's of course even more unrelated. (Also, it's used the other way in lots of other places.)

diff --git a/src/Plugin/facets/facet_source/SearchApiDisplay.php b/src/Plugin/facets/facet_source/SearchApiDisplay.php
new file mode 100644
index 0000000..268daaf
--- /dev/null
+++ b/src/Plugin/facets/facet_source/SearchApiDisplay.php
+      foreach ($allResults as $plugn_id => $resultSet) {

Missing "i" – but also, the whole file wildly mixes snake_case and camelCase for variables, which I'd try to avoid. Your choice, though, I guess.

diff --git a/src/Plugin/facets/facet_source/SearchApiDisplayDeriver.php b/src/Plugin/facets/facet_source/SearchApiDisplayDeriver.php
new file mode 100644
index 0000000..1b75666
--- /dev/null
+++ b/src/Plugin/facets/facet_source/SearchApiDisplayDeriver.php
@@ -0,0 +1,59 @@ public function getDerivativeDefinitions($base_plugin_definition) {
+    $display_plugin_manager = $this->getSearchApiDisplayPluginManager();
+    foreach ($display_plugin_manager->getDefinitions() as $display_id => $display_definition) {
…
+      $machine_name = $display->getDerivativeId();
+      $plugin_derivatives[$machine_name] = [
+        'id' => $base_plugin_id . PluginBase::DERIVATIVE_SEPARATOR . $machine_name,
+        'display_id' => $display_id,
+        'label' => $display->label(),
+        'description' => $display->getDescription(),
+      ] + $base_plugin_definition;
+    }
+
+    uasort($plugin_derivatives, [$this, 'compareDerivatives']);

Just using the derivative ID is of course an idea to avoid the "double colon" problem, but it will necessarily lead to collisions when, e.g., a view and a search page have the same ID. I think you'll have to make sure to deal with duplicates in any case, so you might as well use the whole display ID and just "sanitize" it.

Also, we got rid of the sorting in our derivers in the Search API, since they served no real purpose. I'd suggest doing the same here.

--

Apart from this, I just added more information about the search_api_facets feature to README.txt. This should now really suffice as base information for someone who wants to add that to their backend plugin.

Also, is the "Needs upgrade path" still valid? Seems there is now an upgrade function.

borisson_’s picture

Issue tags: -Needs upgrade path
StatusFileSize
new3.45 KB
new67.16 KB

I'd also call the variable $facet_source_id (additional underscore), but that's of course even more unrelated. (Also, it's used the other way in lots of other places.)

Yeah, we've been using facetsource_id in a bunch of places. Keeping that as-is for now.

Missing "i" – but also, the whole file wildly mixes snake_case and camelCase for variables, which I'd try to avoid. Your choice, though, I guess.

Yeah, we should go trough everything and fix all those things. Not trying to worry about that in this issue. But I agree that I should try harder to keep style consistent.

Just using the derivative ID is of course an idea to avoid the "double colon" problem, but it will necessarily lead to collisions when, e.g., a view and a search page have the same ID. I think you'll have to make sure to deal with duplicates in any case, so you might as well use the whole display ID and just "sanitize" it.

Also, we got rid of the sorting in our derivers in the Search API, since they served no real purpose. I'd suggest doing the same here.

I removed the sorting in the derivers, but I'm not sure what you mean with just using the display ID?

Apart from this, I just added more information about the search_api_facets feature to README.txt. This should now really suffice as base information for someone who wants to add that to their backend plugin.

That looks great, thanks!

Also, is the "Needs upgrade path" still valid? Seems there is now an upgrade function.

You're right, that "Needs upgrade path" is no longer valid. Thanks!

strykaizer’s picture

EDIT: quick paste went wrong. The check for instanceof Url, that part of the code in the patch...
Can this be removed? Need to check if getPath can return something else

borisson_’s picture

StatusFileSize
new1.93 KB
new67.26 KB

This fixes #96 and adds/improves docs a little.

borisson_’s picture

StatusFileSize
new5.76 KB
new68.34 KB

Docs cleanup. Removed the strpos checking in the form and used instanceof checks instead.

nick_vh’s picture

  1. +++ b/facets.install
    @@ -0,0 +1,28 @@
    + * Rename old search api facet sources to the new naming scheme.
    

    Perhaps a description what this update actually is trying to and trying to change (and why) instead of what is literally does would be a good change here.

  2. +++ b/src/Plugin/facets/facet_source/SearchApiDisplay.php
    @@ -0,0 +1,343 @@
    +    // Check if there are results in the static cache.
    

    Not sure if this comment makes a lot of sense. How do you know the searchApiQueryHelper takes it from static cache? If that function ever changes this comment is no longer valid. Maybe better to say if the results have been populated already and if not, we should populate those in here.

  3. +++ b/src/Plugin/facets/facet_source/SearchApiDisplay.php
    @@ -0,0 +1,343 @@
    +      // The getPluginId is "views_rest:search_content__rest_export_1" and the
    +      // derivative id is "views_page:search_content__rest_export_1".
    +      // It looks like another plugin is creating the display that we need to
    +      // load so we have to fix that by finding the results from the correct id.
    

    I don't get this comment at all. What does this mean and what display do "we" want to load? Why is views_rest and views_page even included here? All I understand is that we get allResults from the searchApiDisplay and get the derivativeId from whatever we have in our hands (object) at that moment. Confused :)

  4. +++ b/src/Plugin/facets/facet_source/SearchApiDisplay.php
    @@ -0,0 +1,343 @@
    +          $results = $result_set;
    

    Can we not have multiple items that go into $results? If so, why don't we add a break here so that the foreach loops stops after one assignment to $results.

  5. +++ b/src/Plugin/facets/facet_source/SearchApiDisplay.php
    @@ -0,0 +1,343 @@
    +      // END.
    

    Why is this even relevant to add?

  6. +++ b/src/Plugin/facets/facet_source/SearchApiDisplayDeriver.php
    @@ -0,0 +1,57 @@
    +      // If 'index' is not set on the plugin, we can't load the index to check
    

    Missing dot to mark the end of a phrase.

  7. +++ b/src/Plugin/facets/facet_source/SearchApiDisplayDeriver.php
    @@ -0,0 +1,57 @@
    +      // if the 'search_api_facets' feature is available on the backend.
    

    This comment should be repositioned to where the logic actually is residing.

The last submitted patch, 97: search_api_integration-2772745-97.patch, failed testing.

borisson_’s picture

StatusFileSize
new3.25 KB
new68.8 KB

Thanks for that, I hope the improved comments make it somewhat clearer what's going on here.

Per your request I also took a stab at splitting up the patch into multiple smaller pieces, but I figure the only way to do that is to actually create multiple issues and that split this patch out over those issues. If we don't get consensus over this issue I'll do that on monday to make reviews afterwards easier. For now I'm going to try to figure out .3 here.

  1. Yep, it was already improved in #98 but I think it's even better now.
  2. You're right, I know this, but the code can't possible know that. Thanks! I hope the current comment improves this.
  3. Yeah, this is very confusing.

    The problem happens when there's a facet built on the non-standard display of a view.
    So for example there's a view (aaaaa) that has a page-display and rest-display.
    I have 1 facet / display.

        if ($results === NULL) {
          $all_results = $this->searchApiQueryHelper->getAllResults();
          $derivative_id = $this->getDisplay()->getDerivativeId();
    
          foreach ($all_results as $plugin_id => $result_set) {
            if (strpos($plugin_id, $derivative_id) !== FALSE) {
              $results = $result_set;
            }
          }
        }
    

    When I request the page display everything works as it should even without this codeblock. When looking at the rest display though, without that codeblock the facet is empty.
    This is because $this->getDisplay()->getPluginId() is views_rest:aaaaa__rest_export_1. That's correct.
    However, there are no results in the searchApiQueryHelper for that id. There are results in the searchApiQueryHelper for views_page:aaaaa__rest_export_1.

    So the code there actually just gets aaaaa__rest_export_1 ($this->getDisplay()->getDerivativeId();) and checks if any of the results in the result cache have that as part of their plugin id (the strpos check). This is a horrible way to do this and very error-prone.

    I think what's actually going on is that the results get saved with the wrong ID in search api. I'll try figuring out how exactly that is going on.

  4. Yeah, I could add that, but we might be able to remove the entire block (see .3)
  5. No, that's only for me to see what part of the code I needed to flag to reviewers :)
  6. Added a dot.
  7. Removed this line, there was already a comment to the same effect 10 lines down in the file.
borisson_’s picture

About .3: If I change
$this->query->setSearchId('views_page:' . $view->id() . '__' . $view->current_display); to $this->query->setSearchId('views_rest:' . $view->id() . '__' . $view->current_display); in \Drupal\search_api\Plugin\views\query\SearchApiQuery::init to entire if ($results === NULL) {} is no longer needed. This means we either have to override the search ID from the facets or fix this in search api.

I think this should be fixed from in search api?

borisson_’s picture

borisson_’s picture

StatusFileSize
new1.17 KB
new61.3 KB

If #2839981: Improve search id correctness in views integration lands, we can simplify a little bit here by removing the part that confused Nick in #99. (See attached patch - this won't pass tests but it IS correct.)

Status: Needs review » Needs work

The last submitted patch, 104: search_api_integration-2772745-104.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new61.3 KB
borisson_’s picture

StatusFileSize
new1.37 KB
new59.93 KB

The fails in Drupal\Tests\facets\Functional\UrlIntegrationTest are weird, but fixed by restoring the version of that test from 8.x-1.x. The failures in Drupal\Tests\facets\Functional\FacetSourceTest I can't reproduce locally.

Expecting 1 failure.

borisson_’s picture

I have no idea why these tests are failing. They aren't failing on my machine. I'll set up a local drupalci to see why these tests are failing.

borisson_’s picture

I have no idea why these tests are failing. They aren't failing on my machine. I'll set up a local drupalci to see why these tests are failing.

Hah, that was easy to say. I'm giving up on trying to set up drupalci locally for the day. Still no idea how to reproduce those testfailures.

drunken monkey’s picture

Just using the derivative ID is of course an idea to avoid the "double colon" problem, but it will necessarily lead to collisions when, e.g., a view and a search page have the same ID. I think you'll have to make sure to deal with duplicates in any case, so you might as well use the whole display ID and just "sanitize" it.

[…] I'm not sure what you mean with just using the display ID?

When a search display plugin has the plugin ID views_page:test__test, you only use the test__test part for your facet source plugin ID. That seems dangerous, since you end up with potential conflicts where IDs were previously unique. E.g., if someone creates a search page with ID test__test – the search display plugin ID would be search_api_page:test__test, and thus unique, but for your facet sources either the Views page or the search page would get overwritten (since both would get the facet source plugin ID search_api:test__test).
(Admittedly, this example sounds far-fetched, but with other modules defining search display plugins, this might get more likely – e.g., when two displays (defined by different module) just have search as the derivative plugin ID.)
I'd therefore recommend using the whole plugin ID (views_page:test__test and search_api_page:test__test), including the base ID, for your facet source derivative IDs, and just sanitizing them to avoid the additional colon (e.g., replace the : with __).

I hope this makes it clearer?

No idea about the test fail, sorry. I just thought it might be the Search API version, but seems it correctly downloads Beta 4. (And no other contrib modules seem to get downloaded.)
And, for what it's worth, I also failed at setting up Drupal CI locally (see #2784849-5: Tests fail w/ out of memory error.). Unfortunately, it's not as easy as it should be.

borisson_’s picture

StatusFileSize
new3.77 KB
new67.32 KB
dermario’s picture

I can reproduce the two test fails in #107 on my local vagrant box (CentOS Linux release 7.1.1503). I could have a look at it the upcoming weekend, if that would help.

borisson_’s picture

@dermario: oh good to know that it's reproducable on centos, I'll try setting up a vagrant box on thursday. Thanks!

vegardjo’s picture

Morning! Trying both patches #107 and #111 on both facets alpha 7 and dev, with search_api beta 4 gives me the following unexpected error / WSOD:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "views_page:search_api_publications__overview" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('views_page:search_api_publications__overview') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('views_page:search_api_publications__overview', Array) (Line: 84)
Drupal\Component\Plugin\PluginManagerBase->createInstance('views_page:search_api_publications__overview') (Line: 388)
Drupal\facets\FacetManager\DefaultFacetManager->updateResults('views_page:search_api_publications__overview') (Line: 210)
Drupal\facets\FacetManager\DefaultFacetManager->processFacets('views_page:search_api_publications__overview') (Line: 295)
Drupal\facets\FacetManager\DefaultFacetManager->build(Object) (Line: 82)
Drupal\facets\Plugin\Block\FacetBlock->build() (Line: 123)
Drupal\panels\Plugin\DisplayBuilder\StandardDisplayBuilder->buildRegions(Array, Array) (Line: 162)
Drupal\panels\Plugin\DisplayBuilder\StandardDisplayBuilder->build(Object) (Line: 328)
Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant->build() (Line: 34)
Drupal\page_manager\Entity\PageVariantViewBuilder->view(Object, 'full') (Line: 96)
Drupal\Core\Entity\Controller\EntityViewController->view(Object, 'full')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

"search_api_publications" is the machine name of my view here, while "overview" is the machine name of my display. The view only contains this display, which is a block display.

borisson_’s picture

Issue summary: View changes

@vegardjo: oh - that looks like the update hook didn't work as planned? I'll try to fix that as well. Updated IS with todo's

vegardjo’s picture

Oh, sorry, didn't notice there was an update hook there. However, after patching aplha7 with #111 again, and doing the db update, I still get the same error.

borisson_’s picture

I set up a new drupalvm vagrant box and tried the UrlIntegraionTest and FacetSourceTest again (w/ #107 applied) and I can't get them to fail. This is an ubuntu box though so that might not be it. not sure how easy it is to set up a similar env w/ CentOS. It's too late to do that today so that'll have to be for another day.

sukanya.ramakrishnan’s picture

StatusFileSize
new54.12 KB

There is a check for whether the source is an instance of SearchApiFacetSourceInterface in ListItemProcessor and this patch is causing a bug that doesnt render fields with allowed_values settings. Submitting a patch for the same!

Thanks,
Sukanya

sukanya.ramakrishnan’s picture

StatusFileSize
new1.17 KB
new54.62 KB

Sorry, missed to remove the unused use statement for SearchApiFacetSourceInterface. Adding a corrected patch and an interdiff for the same.

Status: Needs review » Needs work

The last submitted patch, 119: search_api_integration-2772745-119.patch, failed testing.

borisson_’s picture

Assigned: strykaizer » Unassigned

Ok, so I tried this again w/ centos yesterday and it took me a while to set up a new box. I didn't see any errors though in the time I had to test this. I'd suggest to go back to #107 for now and let's try to get that one green. Once we manage that we can have a look at #110/ #111.

Since #118 introduces new failures and nothing failed on the tests for that part yet - let's delegate that to a followup? This is issue is big enough as-is.

Unassigning @StryKaizer for now, as a review is not yet needed before we get this green :)

dermario’s picture

@borisson_ Sorry to hear that the test did not fail. I will investigate in that problem this weekend (when i manage it to pass the xdebug cookie to the test itself).

drunken monkey’s picture

when i manage it to pass the xdebug cookie to the test itself

Pro tip: I just hard-coded that on my local machine:

diff --git a/core/tests/Drupal/Tests/XdebugRequestTrait.php b/core/tests/Drupal/Tests/XdebugRequestTrait.php
index 5da86a51bd..25f2decf01 100644
--- a/core/tests/Drupal/Tests/XdebugRequestTrait.php
+++ b/core/tests/Drupal/Tests/XdebugRequestTrait.php
@@ -29,6 +29,9 @@ protected function extractCookiesFromRequest(Request $request) {
     if ($cookie_params->has('XDEBUG_SESSION')) {
       $cookies['XDEBUG_SESSION'][] = $cookie_params->get('XDEBUG_SESSION');
     }
+    else {
+      $cookies['XDEBUG_SESSION'][] = 'PHPSTORM';
+    }
     // For CLI requests, the information is stored in $_SERVER.
     $server = $request->server;
     if ($server->has('XDEBUG_CONFIG')) {

Had no idea why it didn't work and didn't find it worth my time to debug properly.

borisson_’s picture

StatusFileSize
new67.49 KB

Since I can't reproduce the failure (and I made my laptop crash 3 times with trying to run all the tests on a centos vagrant box and I can't get the testbot to run locally) I'm just guessing right now. This is 107 + a guess

borisson_’s picture

Status: Needs work » Needs review
borisson_’s picture

StatusFileSize
new59.93 KB

Reupload of #107. I still have no idea how to fix these fails.

Status: Needs review » Needs work

The last submitted patch, 126: search_api_integration-2772745-126.patch, failed testing.

dermario’s picture

Status: Needs work » Needs review
StatusFileSize
new66.78 KB
new1.1 KB

Sorry for not replying at the weekend, @borisson_ i didn't know that you try to go the CentOS way :-/ BIIG SORRY!!
I also investigated into that issue and somehow i couldn't reproduce it on CentOS any more. So i tried to reactivate some of my older linux machines at home to install a testbot on it. That did not work out as they are 32 Bit and Docker requires 64 Bit. So i set up a local Virtualhost machine and hacked as much as i could to make it running somehow. My Mac even went out of hdd-space. Somehow it works today - running the tests with sudo and hacky frwrites to STDERR inside the tests gave me a hint for the fail in FacetSourceTest. Please see the attached interdiff.

I don't think that this patch is the final solution for one of the fails in #107 but it maybe points us to the right directory. Lets see what the testbot says.

dermario’s picture

StatusFileSize
new66.78 KB
new1.1 KB

Sorry for the naming - mess. This one should be correct.

borisson_’s picture

Sorry for not replying at the weekend, @borisson_ i didn't know that you try to go the CentOS way :-/ BIIG SORRY!!

Sorry for the naming - mess. This one should be correct.

No need to say you're sorry. I'm very grateful for all of the help you've provided here so far. Very curious about what the tests will say about those patches.

dermario’s picture

StatusFileSize
new67.66 KB
new1.98 KB

I am pretty sure that the tests in #107 fail due a different sort order of the facet sources on our testbots. On our local machines the sort order is like:

      <tbody>
                      <tr class="facet-source odd">
                      <td class="facets-type">Facet source</td>
                      <td>search_api:search_api_test_view__block_1</td>
                      <td><a href="/admin/config/search/facets/facet-sources/search_api%3Asearch_api_test_view__block_1/edit">Configure</a></td>
                  </tr>
                      <tr class="facet-source even">
                      <td class="facets-type">Facet source</td>
                      <td>search_api:search_api_test_view__page_1</td>
                      <td><a href="/admin/config/search/facets/facet-sources/search_api%3Asearch_api_test_view__page_1/edit">Configure</a></td>
                  </tr>
          </tbody>

On our testbots it is:

Type         Title                                   Operations
Facet source search_api:search_api_test_view__page_1 Configure
Facet source search_api:search_api_test_view__block_1 Configure

I attached another simple fix to proof my assumption. By applying these patches on our local machine the tests will fail there. So we need to find a failsafe solution for:

 $this->clickLink('Configure');
 $this->clickLink('Configure', 1);
borisson_’s picture

If that's the problem - restoring the uasort might help as well. Let's try that?

The last submitted patch, 129: search_api_integration-2772745-129.patch, failed testing.

dermario’s picture

StatusFileSize
new23.36 KB

Seems like the fails are fixed now :-) My local testbot agrees with the changes in #132.

dermario’s picture

borisson_’s picture

Issue summary: View changes

Woo! Tests are green again. That's awesome. Thanks so much for all your help here @dermario!

So, now we have to decide about #110:

When a search display plugin has the plugin ID views_page:test__test, you only use the test__test part for your facet source plugin ID. That seems dangerous, since you end up with potential conflicts where IDs were previously unique. E.g., if someone creates a search page with ID test__test – the search display plugin ID would be search_api_page:test__test, and thus unique, but for your facet sources either the Views page or the search page would get overwritten (since both would get the facet source plugin ID search_api:test__test).
(Admittedly, this example sounds far-fetched, but with other modules defining search display plugins, this might get more likely – e.g., when two displays (defined by different module) just have search as the derivative plugin ID.)
I'd therefore recommend using the whole plugin ID (views_page:test__test and search_api_page:test__test), including the base ID, for your facet source derivative IDs, and just sanitizing them to avoid the additional colon (e.g., replace the : with __).

I don't think we have to care about that right now. We can always do the same we did right now (change the ids, provide upgrade path).

I'm going to manually test the upgrade path again tonight so that question should get answered before we can commit this patch (and all the open patches in the queue).

webcultist’s picture

It would be great if this patch could be applied soon. Can be very confusing that 2777217 can't be applied without this one.

borisson_’s picture

Issue summary: View changes

I just tested the upgrade path and that works as expected. I'm happy with the current state of this patch. All we need is an "ok, go" from @Nick_vh and/or @StryKaizer

borisson_’s picture

StatusFileSize
new14.08 KB
new62.84 KB

So @StryKaizer convinced me that we should do #110 + #136.

I fixed the upgrade path and most of the tests that failed in #111. Let's see how many things I missed.

borisson_’s picture

I don't think that test fail is our fault, as the test indicates that the patch didn't apply:

23:21:50 Checkout complete.
23:21:50 Fetch of https://www.drupal.org/files/issues/search_api_integration-2772745-139.patch to /var/lib/drupalci/workspace/jenkins-default-296910/ancillary/search_api_integration-2772745-139.patch complete.
23:21:50 Patch Error
23:21:50 The target patch directory /var/lib/drupalci/workspace/jenkins-default-296910/source/modules/contrib/facets is invalid.
23:21:50 PHP Warning:  implode(): Invalid arguments passed in /opt/drupalci_testbot/src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseAssemble/Patch.php on line 93

https://dispatcher.drupalci.org/job/default/296910/console

1 Error_ Patch failed to apply
1 Apply Patch

search_api_integration-2772745-139.patch
Patch Failed to apply

Confirmed: #2842529: ECK patch test because eck module not checked out?

borisson_’s picture

Ok, so #139 now fails with 2 failures and no longer is broken because of the testbot. I'll resolve those 2 fails after work.

borisson_’s picture

StatusFileSize
new3.65 KB
new70.02 KB

I noticed a failure in the facet summary test locally that I didn't see online. Maybe we should investigate? I'll try to remember that.

Also testOnViewDisplayRemoval found a legit bug. Hurray!

borisson_’s picture

Green tests again, that's great! Do we need a test for the upgrade path as well?

jespermb’s picture

I tested this on a project we are working right now and found a bug. Everything works fine, except for the facet blocks we have inserted via panels. Here the getPath() function returns the views path instead of the path from the current page. Any Idea as to how we fix this?

I just found that the patch changes SearchApiDisplay->getPath() from:

  public function getPath() {
    $display = View::load($this->pluginDefinition['view_id'])->getDisplay($this->pluginDefinition['view_display']);
    switch ($display['display_plugin']) {
      case 'page':
        $view = Views::getView($this->pluginDefinition['view_id']);
        $view->setDisplay($this->pluginDefinition['view_display']);
        return '/' . $view->getDisplay()->getPath();

      case 'block':
      default:
        $current_path = \Drupal::service('path.current')->getPath();
        if (\Drupal::moduleHandler()->moduleExists('path')) {
          return \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
        }
        else {
          return $current_path;
        }
    }
  }

to:

  public function getPath() {
    // The implementation in search api tells us that this is a url object only
    // if a path is defined, and null if that isn't done. This means that we
    // have to check for this + create our own Url object if that's needed.
    if ($this->getDisplay()->getUrl() instanceof Url) {
      return $this->getDisplay()->getUrl();
    }

    return Url::createFromRequest($this->request);
  }

Which is the cause of this issue. Is there a reason for this change or can it be changed back to account for the cases where the block is not on the url of the view page?

Br Jesper

jespermb’s picture

StatusFileSize
new63.35 KB
new1 KB

i created this fix for our own project to solve the issue for now. Hope you can use it.

Br Jesper

borisson_’s picture

Looks like that is a bug in Search API, not facets. That's where the path is generated.

One of the pro's of this patch is that we don't have to duplicate changes to displays for facets and search_api_sorts (and others). The patch in #144 reintroduces a (small) place where we'll have to keep things in line again.

@jespermb is it possible to fix this in search api instead?

jespermb’s picture

Sure i will look into that. Thanks for the reply.

Br Jesper

borisson_’s picture

#2842971: Handle path for blocks makes #145 obsolete.

@jespermb: can you confirm that the upgrade path worked?

jespermb’s picture

Yes it worked as expected.

dermario’s picture

StatusFileSize
new196.2 KB

I tried to update a customer project from alpha7 to the latest dev + #142 locally and run into an issue.

Facets source id before updb: views_page:search_results__search_results
Facets source id after updb: search_api:views_page__:search_results__search_results

When visiting admin/config/search/facets/section_facet/settings i get:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "search_api:views_page__:search_results__search_results" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I just took a screenshot of a debug session i did:

I could investigate tomorrow. Today i am to blind to the see the problem ;-)

borisson_’s picture

"search_api:views_page__:search_results__search_results" should be
"search_api:views_page__search_results__search_results"

The problem is the extra :.

dermario’s picture

StatusFileSize
new70.04 KB
new902 bytes

Thank you @borisson_ for your confirmation. This patch fixes the upgrade path for me. I also modified the comment a bit.

borisson_’s picture

StatusFileSize
new898 bytes
new70.61 KB

I tested the upgrade path again locally and noticed that facet summaries were not upgraded. They are now.

strykaizer’s picture

Status: Needs review » Needs work

Great work all, impressive patch ;-)

  • Lets move the summary upgrade path to the summary submodule
  • Lets change the upgrade documentation to a short sentence, e.g. "Convert Search API facet sources to use Search API display plugin system."
borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new2.74 KB
new71.09 KB

So, something like this?

strykaizer’s picture

Status: Needs review » Needs work

Current patch breaks facets which are rendered without being on the actual search api view page.

Lets fix this, and write a test for this which fails without the that fix.

Other than that, upgrade functionally working on my projects.

borisson_’s picture

Issue summary: View changes

It looks like this means we don't have sufficient coverage for only_visible_when_facet_source_is_visible.
So we should write a new test that covers that.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.49 KB
new72.37 KB

I think this proves that @StryKaizer 's right. Attached test-only.patch should pass on HEAD and fail w/ the rest applied. If we get that to pass we should be able to resolve #156

borisson_’s picture

StatusFileSize
new1.69 KB
new73.06 KB

This reintroduces code to fix the bug @StryKaizer reported.

borisson_’s picture

So, we have the new test green now, but there's a fail in the rest tests that I don't understand. I can get a rest view to work locally when I configure it myself.

I'll try to figure out how to fix it.

borisson_’s picture

StatusFileSize
new1.38 KB
new73.55 KB

I think I've figured it out. The configuration of the facet used in the rest view was incorrect. So good thing this errored.

borisson_’s picture

This is now ready for final reviews. Hoping to get at least StryKaizer and one other person to use this on a real project to see if we introduce any regressions.

jacobv1992’s picture

Hi , I updated the Search API to Search API 8.x-1.0-beta4 after which I updated the Facets API to Facets 8.x-1.0-alpha7.

I started to get https://www.drupal.org/node/2840613 and https://www.drupal.org/node/2839981#comment-11848090 issue

So I applied the https://www.drupal.org/files/issues/search_api_integration-2772745-161.patch patch but got the below issue on all pages with facets in them (from logs)

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "views_page:spaces_search__block_1" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /var/www/pennlib/code/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

This is happening on the facets setting as well

borisson_’s picture

Did you run the provided upgrade path? Does that make it better?

jacobv1992’s picture

I ran drush updb if after applying the https://www.drupal.org/files/issues/search_api_integration-2772745-161.p... . I'm not sure what I'm supposed to do to "run the provided upgrade path" . Could you let me know if there is more I'm supposed to do with this fix.

borisson_’s picture

Status: Needs review » Needs work

No that was all you needed to do. Looks like this isn't fixed yet. I'll try to figure it out during the sprint weekend sprints.

borisson_’s picture

Issue tags: +SprintWeekend2017

So, it looks like we don't have an upgrade path for facet source entities yet. So that's what we need to do here.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.7 KB
new74.27 KB

With upgrade path now.

borisson_ credited swentel.

borisson_’s picture

StatusFileSize
new1.97 KB
new74.69 KB

Discussed and tested with swentel at the sprint weekend.

  • borisson_ committed 7c73227 on 8.x-1.x
    Issue #2772745 by borisson_, dermario, drunken monkey, jespermb,...
borisson_’s picture

Status: Needs review » Fixed

Committed! Woo!

ndrake86’s picture

_borrison, was testing out the patch and used the update path provided, for common search api page the new source Id for each facet was changed correctly. But what I found was for export pages and panels block facets the source was not able to be updated. Not a super huge deal, I was able to manually reconfigure those facets just wanted to make a note here in case others had ran across a similar issue with their data export or panels block.

For my export page the facet source before updb:
views_page:advanced_page__data_export_1
going to admin/config/search/facets the source shows as
search_api:views_data__advanced_page__data_export_1
but was converted as:
search_api:views_page__advanced_page__data_export_1

This might be the way the export pages source Ids are made but I haven't gone that far into it yet. Also these export views are making use of the views data export module which also could have played a part. Which probably relates to this problem I was running into with my exports on Beta 4 of the search api ->https://www.drupal.org/node/2846357

All in all everything else is working great.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.