Add support for book module

Created on 25 February 2022, over 2 years ago
Updated 2 March 2023, over 1 year ago

Problem/Motivation

When nodes are part of a book outline from Drupal core's book module, then that outline information is lost after sync.

Remaining tasks

  • Find out, how to include the book settings into the json api serialization
  • Add the node uuids of all referenced parent nodes and books and manage them for sharing just like entity references
  • On the client side, handle the parent nodes and book references and store the book outline information
Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    It's probably a bit late, but I have now incorporated your in-code comments from the MR and did also some code cleanup.

    Wanted to start on the test but struggle with that and probably need your help. The challenge is that we need to have the module json_api_book on the server side of entity_share to inject the book related extra data which then needs to be tested on the client side.

    How would youy go about that for testing then?

  • 🇫🇷France Grimreaper France 🇫🇷

    Hi @jurgenhaas,

    Glad to see your are still active on this issue.

    You can add json_api_book in the require-dev of the composer.json.

    In a dedicated test which could inherit of EntityShareClientFunctionalTestBase, enable json_api_book in addition in this test and take inspiration from BasicFieldsTest and/or TaxonomyEntityReferenceTest or other tests about entity reference fields to see how the setup and the tests are done.

    See tests like EmbeddedEntityTest when configuring additional import processors and/or json api extras enhancers are required.

    Are those guidelines ok for you?

  • Assigned to jurgenhaas
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • Issue was unassigned.
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thanks @Grimreaper this is great advise. But I still don't get it completely. I have an idea how you've built all those abstract classes to build your test data, but I don't easily find out how I should define my test data.

    I'm sure you could do that fairly quickly with your knowledge of all that background. I've started building \Drupal\Tests\entity_share_client\Functional\BookStructureImporterTest in the MR and you can find the information of what is needed in \Drupal\Tests\entity_share_client\Functional\BookStructureImporterTest::getEntitiesDataArray where I have included the data structure of the node, its parent node and its book node. If you could turn that into the correct data array, I may well get the rest of the test completed.

  • Assigned to Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷

    Thanks for your hard work and to have prepared the test class.

    I will try to give it a look.

  • Issue was unassigned.
  • 🇫🇷France Grimreaper France 🇫🇷

    Please check the structure of the nodes in getEntitiesDataArray if it is ok, especially the p* and depth.

    The checker_callback methods have to be implemented like in ContentEntityReferenceTest or TaxonomyEntityReferenceTest.

    If too time consuming, at least ensure the book data is ok and I will try to finish the test.

    Thanks :)

  • 🇩🇪Germany jurgenhaas Gottmadingen

    I have checked and updated the data structure and also implemented the checker callback, hopefully in the right way? But the structure looks ok to me now.

    The test is failing with this error:

    The node with UUID book_root has been recreated.
    Failed asserting that false is true.
    

    Would be great if you could get this fixed.

  • Assigned to Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷

    Thanks!

    Ok, I will try to test that and finish the test.

    I am currently on 🐛 Infinite Loop in link field, block field and embedded entity importer plugins Fixed and will give a try here after.

  • @grimreaper opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷

    Got it!

    The problem was that during the entity creation, the book structure requires the entity ID while it does not exist yet.
    So need to create the entities in prepareContent().

    I gave a look at the tests in the core Book module to see how to create a book structure programmatically.

    I also made simplification of the plugin to only import the parent and by recursion it will be ok.

    @jurgenhaas can you please give a look at the new MR (rebased) to see if it is ok for you?

    Without response I will merge next week.

  • Status changed to RTBC over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This is looking great. Your simplication of the code is amazing, thanks a lot for that.

    • Grimreaper committed f34d178b on 8.x-3.x
      Issue #3266530 by jurgenhaas, Grimreaper: Add support for book module
      
  • Status changed to Fixed over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷

    Thanks for the quick feedback.

    Merged!

    Only 📌 D10: update dev dependency Simple Oauth to ~5.2 Fixed before next release.

    And 💬 Call to a member function getAlias on null Fixed before stable release.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    That's amazing, great work!

    We have a very complex environment with books where we run real tests asap again. They will run a couple of days just because of the volume, but we will quickly see if all books still come across properly. If there was any issue, I'd open a new one here to address it directly. But there shouldn't be any.

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

Production build 0.69.0 2024