When I enable facets module the whole site is getting down with an error:
Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: "You have requested a non-existent service "search_api.query_helper"." at /var/www/user640/data/www/example.com/web/core/lib/Drupal/Component/DependencyInjection/Container.php line 157, referer: http://example.com/batch?id=20&op=start

I uninstall facets with drush pm-unistall, enable search_api module, then enable facets - everything works, no errors.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sumerian created an issue. See original summary.

borisson_’s picture

borisson_’s picture

I think this is also why the tests are currently all failing on HEAD. Let's try to get to this with priority!

borisson_’s picture

Issue tags: +beta blocker

I'm afraid that the easiest answer will be to create a new submodule that depends on search api.

Either that or something like this in the ::create method of \Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

    if (!$container->get('module_handler')->moduleExists('search_api')) {
      return new \stdClass();
    }

    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('plugin.manager.facets.query_type'),
      $container->get('search_api.query_helper'),
      $container->get('plugin.manager.search_api.display'),
      $container->get('request_stack')->getMasterRequest()
    );
  }

Let's get opinions in before we do this, tagging as beta blocker - because if we need to create the submodule, we really have to do that before beta.

StryKaizer’s picture

I prefer a moduleExists for this case
I think most users will use facets with search_api enabled, so I don't mind having this in the core facets module.

borisson_’s picture

Status: Active » Needs review
FileSize
901 bytes

Added this as a patch; with more docs.

borisson_’s picture

Title: Search API dependency? » Module depends on a search api service and it shouldn't

Updated the title.

Rishi Kulshreshtha’s picture

Patch got applied pretty well on the latest dev version of the module but somehow after enabling it I'm getting this message:

Fatal error: Call to undefined method stdClass::isRenderedInCurrentRequest() in /var/www/drupal/modules/contrib/facets/facets.module on line 249

This is the code in facets.module on line 249:

if (!$facet_source_plugin->isRenderedInCurrentRequest()) {

Rishi Kulshreshtha’s picture

Status: Needs review » Needs work
borisson_’s picture

Ah, great catch. I figured this should work, but looks like we'll have to do more work to actually get this to work. I'll try to get to this issue over the weekend.

borisson_’s picture

Status: Needs work » Needs review
FileSize
1.6 KB
1.78 KB

I think this resolves the problem. Would you mind testing this?

Status: Needs review » Needs work

The last submitted patch, 11: module_depends_on_a-2877989-11.patch, failed testing. View results

borisson_’s picture

Status: Needs work » Needs review
FileSize
1.35 KB
3.13 KB

Fixes the tests, not related to this issue.

Rishi Kulshreshtha’s picture

Status: Needs review » Reviewed & tested by the community

Patch provided in [#13] got easily applied to the latest dev version of the module.

Checking patch src/FacetSource/FacetSourcePluginManager.php...
Checking patch src/Plugin/facets/facet_source/SearchApiDisplay.php...
Applied patch src/FacetSource/FacetSourcePluginManager.php cleanly.
Applied patch src/Plugin/facets/facet_source/SearchApiDisplay.php cleanly.

I was able to enable this module without any dependency of search_api, hence marking this as RTBC.

  • borisson_ committed 9e01591 on 8.x-1.x
    Issue #2877989 by borisson_: Module depends on a search api service and...
borisson_’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -beta blocker

Committed, thanks!

Status: Fixed » Closed (fixed)

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