Problem/Motivation

During installation of facets with drush on a fresh 8.2.dev Drupal installation, I get the following error:

Drush command terminated abnormally due to an unrecoverable error.
Class 'Drupal\rest\Plugin\views\style\Serializer' not found in .../facets/src/Plugin/views/style/FacetsSerializer.php on line 22

That happens because this plugin inherited from \Drupal\rest\Plugin\views\style\Serializer

Proposed resolution

Prevent initialize style plugin when rest module not enabled

Remaining tasks

User interface changes

API changes

Data model changes

Comments

ohmdesbois created an issue. See original summary.

borisson_’s picture

am I correct in assuming that you don't have the rest module enabled? That might help in finding out why this fails.

mpotter’s picture

This is a new error with 8.2.x. Didn't happen a couple weeks ago. I don't see any dependency listed in facets.info.yml for the Rest module, but enabling Rest did fix the error.

Either the facets.info.yml file needs to be updated, along with an update hook to enable it for existing sites. Or whatever caused Rest to suddenly be needed should be changed.

mikran’s picture

Status: Active » Needs review
StatusFileSize
new740 bytes

This prevents new installations from configuration so here is a patch that adds rest module dependency to the module.

borisson_’s picture

Status: Needs review » Active

This is not the correct way, I don't want facets to depend on this. Perhaps we should put the rest stuff in a submodule and have that one depend on rest?

Status: Active » Needs work

The last submitted patch, 4: add_rest_module_dependency-2775963-4.patch, failed testing.

The last submitted patch, 4: add_rest_module_dependency-2775963-4.patch, failed testing.

marthinal’s picture

I agree. We should put the rest stuff in a submodule. AFAIK the only way to avoid the error is enabling the REST module... so yes makes sense.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new614 bytes

No reason in new module, just properly expose dependency.
This is how language module from core works

andypost’s picture

Title: Class 'Drupal\rest\Plugin\views\style\Serializer' not found » FacetsSerializer views style plugin depends on optional rest module

Proper title

andypost’s picture

Issue summary: View changes

updated IS

PS Tests are broken now so expect failures

Status: Needs review » Needs work

The last submitted patch, 9: 2775963-9.patch, failed testing.

The last submitted patch, 9: 2775963-9.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
Related issues: +#2777483: Unmet dependencies

Tests are failed because of search api #2777483: Unmet dependencies

mpp’s picture

I had a similar error with an event subscriber (https://www.drupal.org/node/2776235). This problem didn't occur before 8.1.6 after that I had to put extra dependencies to my install profile.

nick_vh’s picture

Priority: Normal » Critical

Bumping to critical as it's why the integration tests are failing:
https://travis-ci.org/mkalkbrenner/search_api_solr/jobs/149402468

andypost’s picture

I think #9 is a proper patch so called to retest, maybe test should be fixed as well to declare dependency on rest module

Status: Needs review » Needs work

The last submitted patch, 9: 2775963-9.patch, failed testing.

The last submitted patch, 9: 2775963-9.patch, failed testing.

borisson_’s picture

I just committed #2776711: non-existent service "search_api.results_static_cache", so sent this for another retest.

The last submitted patch, 9: 2775963-9.patch, failed testing.

borisson_’s picture

I sent this for a rest earlier and while the tests are green, it look like this is not sufficient:

drush en facets
The following extensions will be enabled: facets
Do you really want to continue? (y/n): y
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Class 'Drupal\rest\Plugin\views\style\Serializer' not found in
/.../modules/facets/src/Plugin/views/style/FacetsSerializer.php, line
22

joachim’s picture

The plugin is used in tests/facets_search_api_dependency/config/install/views.view.search_api_test_views_fulltext.ym.

Does rest module maybe need to be declared in test_dependencies?

borisson_’s picture

@joachim: it's not just a problem in the tests, it's also a problem for real sites, and we really don't want to have rest as a hard dependency for all facets.

joachim’s picture

AFAIK, declaring a module in test_dependencies only tells the d.org test runner that the module is needed. It's not an actual dependency.

There's already this in facets.info:

test_dependencies:
  - search_api:search_api
  - drupal:views
borisson_’s picture

AFAIK, declaring a module in test_dependencies only tells the d.org test runner that the module is needed. It's not an actual dependency.

There's already this in facets.info: ...

While that is true, that's not enough. It's not just for the tests that we need to resolve this, but also for the normal installation.

borisson_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.03 KB

I did the changing into a submodule.

borisson_’s picture

StatusFileSize
new544 bytes
new1.56 KB

The installation on @StryKaizer's machine didn't work without this patch applied. With the patch it did. I forgot to move the test though, so I did that.

I'm confident we can commit this patch so that at least installs work again.

borisson_’s picture

StatusFileSize
new14.42 KB
new15.74 KB

This should probably maybe resolve the issue.

borisson_’s picture

The fails that are currently happening on the last patch are because facets are broken. We're trying to resolve that issue. However, there's nothing related to rest anymore.

So I feel that this patch resolves the issue at hand.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

I think this is ready, but I'd like confirmation.

andypost’s picture

Separation looks ok, just wondered why not put submodules in to "modules" folder - separate issue

Suppose this needs change record pointing that you need to enable new module

joachim’s picture

> Separation looks ok, just wondered why not put submodules in to "modules" folder - separate issue

Yes please, do make that a separate issue, so the files move is its own commit. It makes a much cleaner git history.
Search API added code and moved files to a modules folder in a single commit, and I was trying to find a change in the git log and it was a painful commit to deal with!

mpp’s picture

OK to move the module to modules/
rtbc on the error

borisson_’s picture

I agree with the modules directory, created #2798483: Move submodules into a modules folder.

borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Committed this, as it resolves at least some of our problems we currently have with facets.

I made sure to credit everyone I discussed this with at drupalcamp Ghent.

Thanks everyone for their help in figuring this one out.

  • borisson_ committed 5b20157 on 8.x-1.x
    Issue #2775963 by borisson_, andypost, mikran, mpp, Nick_vh, StryKaizer...
ohmdesbois’s picture

It seems that the patch solve the problem.
Thanks to everyone.

The last submitted patch, 27: facetsserializer_views-2775963-27.patch, failed testing.

The last submitted patch, 28: facetsserializer_views-2775963-28.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 30: facetsserializer_views-2775963-29.patch, failed testing.

The last submitted patch, 27: facetsserializer_views-2775963-27.patch, failed testing.

The last submitted patch, 28: facetsserializer_views-2775963-28.patch, failed testing.

The last submitted patch, 30: facetsserializer_views-2775963-29.patch, failed testing.

borisson_’s picture

Status: Needs work » Closed (works as designed)

Was already fixed.