If you enable search_api_database_defaults it depends on Core Search because the view modes search_index and search_display are part of Search Core.

We should "copy" those view modes and somehow make sure they can run in combination with drupal core search if someone wants to do so. I suggest searchapi_index and searchapi_display or something?

Estimated Value and Story Points

This issue was identified as a Beta Blocker for Drupal 8. We sat down and figured out the value proposition and amount of work (story points) for this issue.

Value and Story points are in the scale of fibonacci. Our minimum is 1, our maximum is 21. The higher, the more value or work a certain issue has.

Value : 13
Story Points: 2

CommentFileSizeAuthor
#44 2624468-44--db_defaults_installation_ux--interdiff.txt10.98 KBdrunken monkey
#44 2624468-44--db_defaults_installation_ux.patch15.02 KBdrunken monkey
#37 2624468-37.patch13.37 KBNick_vh
#28 2624468-28.patch12.62 KBNick_vh
#27 2624468-27.patch12.7 KBNick_vh
#23 2624468-23.patch9.86 KBNick_vh
#19 2624468-17.patch9.82 KBNick_vh
#18 2624468-17.patch5.1 KBNick_vh
#17 2624468-16.patch3.86 KBNick_vh
#15 2624468-15.patch10.01 KBNick_vh
#14 2624468-14.patch837 bytesNick_vh
#14 2624468-13.patch837 bytesNick_vh
#9 2624468-9--core_search_dependency--interdiff.txt3.37 KBdrunken monkey
#9 2624468-9--core_search_dependency.patch3.27 KBdrunken monkey
#7 2624468-6.patch2.44 KBNick_vh
#5 2624468-5.patch2.47 KBNick_vh
#4 2624468-4.patch1.74 KBNick_vh
#3 2624468-3.patch3.94 KBNick_vh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nick_vh created an issue. See original summary.

Nick_vh’s picture

Taking this now - found the problem and testing the solution now.

Nick_vh’s picture

Status: Active » Needs review
FileSize
3.94 KB

The solution is to add the configs to optional and only if you do not have the article and story type it will "silently" not install those configs. Core has support for this behavior and it is not a new pattern.

Nick_vh’s picture

Adding a hook_requirements so that it would fail to install if the article and bundle are not available. Next up, adding the requirements for the specific fields that we need.

Nick_vh’s picture

This should be good for review.

borisson_’s picture

  1. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.info.yml
    @@ -12,4 +12,3 @@ dependencies:
    -  - drupal:standard
    

    ++

  2. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.install
    @@ -0,0 +1,47 @@
    + * @file
    + * Install, update and uninstall functions for the search_api_db_defaults
    + * module.
    

    This is not compliant with the other @file blocks.

  3. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.install
    @@ -0,0 +1,47 @@
    +  if ($phase == "install") {
    

    any reason for the double quotes here?

Otherwise this looks great.

Nick_vh’s picture

Adding newline and changing double quotes to single quotes

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

RTBC!

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
3.27 KB
3.37 KB

Thanks for solving this, looks good!
However, still a bit of nit-picking …

borisson_’s picture

Status: Needs review » Needs work

The change in the integration test is unrelated and I don't think it should go in with this patch. Otherwise the changes looks great.

drunken monkey’s picture

Status: Needs work » Fixed

OK, thanks. Committed (split in two, so Order In The World is preserved).

Nick_vh’s picture

Status: Fixed » Needs work

Sorry, a little follow up patch is required. And it does confuse me, the "links" parameter is shown in the export as a dependency

links:
    weight: 2
    settings: {  }
    third_party_settings: {  }

However, it is not present when looping over the fields. I'm going to say it is not required as everything installs just fine without it. The other change was just a mistake that I don't know how that can pass the test suite. I also installed it with the standard profile but the page content type didn't have field_image, ever.

Please review and commit this follow-up

Nick_vh’s picture

FileSize
837 bytes
837 bytes
Nick_vh’s picture

Status: Needs work » Needs review
FileSize
10.01 KB

So, this was more difficult than I thought. This adds a test for installing and uninstalling through the UI and make sure that it also removed the server and index. The test also removes the article content type and checks if the module fails to install. Since the configs are just exports, they are not being removed on uninstall. The reason is that they don't have a single dependency on config entities that makes them obsolete, and hence they are not marked for deletion. This is kind of strange as I even tried to make them a hard dependency on the module.

I had to move the view mode displays to optional and the view itself as well. Since we do check for the content types as the only hook_requirement, there is no need to add them to the install. It also conflicts if those view modes were already set up and we do not remove them on uninstall so they are fully optional. Since the view depends on those view mode displays, I had to move it to optional because the way the dependency system works. Eg, if you move that to "install" it fails to install because the stuff it depends on are listed in optional. Regardless of whether it adds it to your site or not, it will fail to install. Only the server and index are added to the install folder and those are also removed when uninstalling the module.

This brings me to a conflict, should we "uninstall" the configured view modes when uninstalling this module? Should we figure out if there are any other systems that use those view mode displays and if so, do not remove them?

Thanks

borisson_’s picture

  1. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.install
    @@ -45,3 +53,51 @@ function search_api_db_defaults_requirements($phase) {
    +  if ($index) {
    ...
    +  if ($server) {
    ...
    +  if ($view) {
    ...
    +  if ($article_search_index_vd) {
    ...
    +  if ($article_search_result_vd) {
    ...
    +  if ($page_search_index_vd) {
    ...
    +  if ($page_search_result_vd) {
    

    Do we need to check if these exist? They can't be uninstalled seperatly, can they? Not that it hurts, just wanted to know.

  2. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.install
    @@ -45,3 +53,51 @@ function search_api_db_defaults_requirements($phase) {
    +  // Delete the Entity View Displays
    +  // Before doing so, calculate the dependencies of those to make sure we do
    +  // not delete them if they are already in use.
    

    Either add a full stop after "Displays" or reflow the text to be one sentence.

  3. +++ b/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php
    @@ -108,10 +77,33 @@ class IntegrationTest extends WebTestBase {
    +    // Check if server is found on search api admin page
    +    // check if index is found on search api admin page
    

    Should those comments be there? I think they need to be near the relevant parts of the test. And They need a starting capital and period at the end.

  4. +++ b/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php
    @@ -108,10 +77,33 @@ class IntegrationTest extends WebTestBase {
    +    // Install Defaults Module and make sure it failed because there was no content type "article".
    

    80 cols

This brings me to a conflict, should we "uninstall" the configured view modes when uninstalling this module? Should we figure out if there are any other systems that use those view mode displays and if so, do not remove them?

I think we should, but only if we can figure out that we're uninstalling them without breaking something else.

Nick_vh’s picture

FileSize
3.86 KB

Updated patch to be a bit more clear in what it does. I tried to calculate the dependent other configs but failed miserably.

Nick_vh’s picture

Do we need to check if these exist? They can't be uninstalled seperatly, can they? Not that it hurts, just wanted to know.

They can, they are all available in the UI.

Rerolled it to incorporate your comments

Nick_vh’s picture

Doh, wrong way of getting the patch

The last submitted patch, 17: 2624468-16.patch, failed testing.

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

borisson_’s picture

Status: Needs review » Needs work
    Overall this looks great and I think this is probably the best we can do while staying sane.

    I have a couple of really small nitpicks, because I like nitpicking.

  1. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.install
    @@ -45,3 +50,40 @@ function search_api_db_defaults_requirements($phase) {
    +  // Delete the default index
    ...
    +  // Delete the default server
    ...
    +  // Delete the default view
    
    +++ b/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php
    @@ -108,10 +77,37 @@ class IntegrationTest extends WebTestBase {
    +    // check if index is found on search api admin page.
    

    Capital/period.

  2. +++ b/search_api_db/search_api_db_defaults/search_api_db_defaults.install
    @@ -45,3 +50,40 @@ function search_api_db_defaults_requirements($phase) {
    +  $vd_list = [ 'node.article.search_index', 'node.article.search_result', 'node.page.search_index', 'node.page.search_result'];
    

    The search api standards say not use short array syntax.

  3. +++ b/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php
    @@ -47,60 +47,29 @@ class IntegrationTest extends WebTestBase {
    +    // Install Defaults Module.
    
    @@ -108,10 +77,37 @@ class IntegrationTest extends WebTestBase {
    +    // Uninstall Defaults Module.
    

    Too Many Capitals That Should Not Be Needed. ;)

Nick_vh’s picture

addressed those :)

Nick_vh’s picture

Status: Needs work » Needs review
borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, let's get this in.

Nick_vh’s picture

Status: Reviewed & tested by the community » Needs work

drunken_monkey: Nick_vh: Huh. I actually would have said the server and index not being uninstalled with the module is a good thing.
[4:16pm] Nick_vh: then it should also move to optional
[4:16pm] drunken_monkey: That way, you can just uninstall the module again after installing it and it won't decrease performance completely unnecessarily.
[4:16pm] drunken_monkey: Also, I think it
[4:16pm] oraculi joined the chat room.
[4:16pm] drunken_monkey: 's more in line with the config philosophy of D8.
[4:16pm] drunken_monkey: Nick_vh: Why?
[4:17pm] Nick_vh: So installing a module adds stuff, uninstalling doesn’t remove anything?
[4:17pm] Nick_vh: doesn’t make a lot of sense
[4:18pm] Nick_vh: and then when you install it again, the server is in “install” and the module will fail to get enabled
[4:18pm] Nick_vh: so it has to be optional
[4:18pm] Nick_vh: imho
[4:19pm] drunken_monkey: Nick_vh: As said, I think it's in line with D8's config philosophy: the site owns the configuration, not the module.
[4:19pm] drunken_monkey: Maybe ask someone about it?
[4:20pm] drunken_monkey: If they wanted installed config to be removed along with the module, I think they'd coded it that way.
[4:20pm] Nick_vh: Well, if it depends on config entities, that’s how it works
[4:20pm] Nick_vh: but should the module fail to install after a second try then?
[4:20pm] drunken_monkey: And, as said, leaving the module enabled completely unnecessarily reduces performance.
[4:20pm] Nick_vh: I think that’s why it’s called optional
[4:20pm] Nick_vh: I’m fine in not removing it
[4:20pm] drunken_monkey: Hm, might be we should move it to optional, yes.
[4:21pm] drunken_monkey: Or add a check to hook_requirements() to give a more meaningful error message.
[4:21pm] drunken_monkey: (Unless the one you'd get currently is good enough already.)
[4:24pm] Nick_vh: well, that one is pretty clear currently
[4:24pm] Nick_vh: it checks all the required components
[4:25pm] Nick_vh: but it shouldn’t fail when re-enabling then
[4:25pm] Nick_vh: and I agree in not removing it, maybe we do need to add it to the description
[4:26pm] drunken_monkey: Like, "Can be uninstalled again right afterwards."? Sounds sensible to me, yes.
[4:26pm] dasjo left the chat room. (Remote host closed the connection)
[4:27pm] drunken_monkey: Failing on re-installing makes sense, too, I'd say, since that wouldn't do anything anyways. We should just have a good error message. "It looks like the default setup provided by this module already exists on your site. Installation failed." or something.
[4:27pm] dasjo joined the chat room.
[4:31pm] Nick_vh: the thing is that Core provides the error message if we have it in “install"
[4:31pm] Nick_vh: so sure, we can check if the resources are there in hook_requirements and then fail
[4:31pm] Nick_vh: but with a clear message
[4:31pm] Nick_vh: that would make sense to me
[4:31pm] drunken_monkey: OK, great!
[4:31pm] Nick_vh: I’ll c/p this conversation to the patch
[4:31pm] drunken_monkey: Then let's do it like that.

Nick_vh’s picture

So I think this patch complies with the discussion we had. You are now able to install the module and get all the configs, even if you already enabled the view display modes. On uninstall it will not remove the configs but when you try to install them again it will fail if you still have the index, server or view.

All of the above is also tested in an integration test. I have one exception which seems very unrelated so trying to test that here also.

The last submitted patch, 27: 2624468-27.patch, failed testing.

The last submitted patch, 27: 2624468-27.patch, failed testing.

The last submitted patch, 27: 2624468-27.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 28: 2624468-28.patch, failed testing.

The last submitted patch, 28: 2624468-28.patch, failed testing.

The last submitted patch, 28: 2624468-28.patch, failed testing.

The last submitted patch, 27: 2624468-27.patch, failed testing.

The last submitted patch, 28: 2624468-28.patch, failed testing.

Nick_vh’s picture

The last submitted patch, 27: 2624468-27.patch, failed testing.

The last submitted patch, 27: 2624468-27.patch, failed testing.

The last submitted patch, 27: 2624468-27.patch, failed testing.

The last submitted patch, 28: 2624468-28.patch, failed testing.

The last submitted patch, 28: 2624468-28.patch, failed testing.

The last submitted patch, 28: 2624468-28.patch, failed testing.

drunken monkey’s picture

Thanks, great job!
Just a bit of nit-picking, once again …

Also, the partial_matches change is a bit unfortunate, since it's of course completely unrelated, but if it needs to be there to pass the tests I guess it can't be helped.

If no-one objects and the test bot is happy, too, I'll hopefully commit this in a few days.
In any case, thanks again for your work on this!

StryKaizer’s picture

This patch, which is in 8.x-1.x HEAD, added a dependency on 2 non-existant fields (field_image and field_links) on a CT page, for search_api_db_defaults
Installation is complaining about this and wont succeed.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

The latest patch (#44) doesn't have the remark made in #45 anymore, I'd suggest we get that patch in so installation actually works.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Yes, definitely, thanks.
Committed.
Thanks again for your work, Nick!

  • drunken monkey committed af42911 on 8.x-1.x authored by Nick_vh
    Follow-up to #2624468 by Nick_vh, drunken monkey: Fixed dependencies of...

Status: Fixed » Closed (fixed)

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