BookOutline" plugin does not exist

Created on 25 June 2024, 2 months ago
Updated 4 September 2024, 4 days ago

Problem/Motivation

On Drupal 10.2, when trying to add book content, you get a WSOD with the following error...

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "BookOutline" plugin does not exist. 

... this error also shows up in browser response due to the AJAX call that happens when you try to select a book outline on the /node/add page.

Steps to reproduce

  1. Download any version of Drupal core in the 10.0.x, 10.1.x, or 10.2.x branches (I used 10.2.7, the latest version of 10.2 at time-of-writing): composer create-project drupal/recommended-project:10.2.7 "install-dir"
  2. Optional: install Drush: composer require drush/drush
  3. Install with any install profile (I used minimal): drush site:install minimal or go to the installer
  4. Download the Book module version 1.0.0: composer require drupal/book:^1
  5. Install the book module: drush pm:install book
  6. Go to /node/add/book. Enter a Title and Body. Click "Save"
    • Expected behavior: the book page is created
    • Actual behavior: WSOD. If PHP is set up to display errors, then you see Drupal\Component\Plugin\Exception\PluginNotFoundException: The "BookOutline" plugin does not exist.

Proposed resolution

Either:

  1. switch back to the comment-based annotation in src/Plugin/Validation/Constraint/BookOutlineConstraint.php, or
  2. drop support for 10.2 before its official end-of-life ( on the Week of December 9, 2024 β†’ ) by changing the core_version_requirement in book.info.yml)

Remaining tasks

  1. Decide a path forward (i.e.: switch back to comment-based annotations, or drop 10.2 support before its EOL), move back to Active
  2. Write patch/merge request
  3. Review and feedback
  4. RTBC and feedback from maintainers
  5. Commit
  6. Release

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

(To be determined)

Original report by @Liliplanet

Hi, I used to have book installed, now moving over to this module.

On installation, add content, error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "BookOutline" plugin does not exist.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France Liliplanet Cannes

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

Merge Requests

Comments & Activities

  • Issue created by @Liliplanet
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    We're running into the same issue on Drupal core 10.2.7. Here is what happens:

    • in D10.2.7, the book module is still in core and uses annotations for validation plugins
    • there is now also a public release of the book module, which works with all Drupal versions >= 10
    • the json_api_book module requires the book module which came from core in the past and should be coming from the contrib module in the future
    • because of json_api_book, composer now also installs the book module from contrib
    • as a result, we have the book module with the same namespace twice: one time in core and another time in contrib
    • the contrib version uses attributes instead of annotations, and that's why Drupal doesn't find the plugins

    Workaround, until we can upgrade to Drupal 10.3:

    • delete web/core/modules/book after composer update or composer install
    • apply a patch to bring back annotations into the validation plugin in contrib
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    For anyone who wants to use the same workaround, attached is a copy of the working constraint plugin, remove the .txt extension after downloading it. Then copy that into the config directory of the project root. In composer.json add 2 scripts:

    {
      "scripts": {
        "post-update-cmd": "rm -rf web/core/modules/book && cp config/BookOutlineConstraint.php web/modules/contrib/book/src/Plugin/Validation/Constraint/BookOutlineConstraint.php",
        "post-install-cmd": "rm -rf web/core/modules/book && cp config/BookOutlineConstraint.php web/modules/contrib/book/src/Plugin/Validation/Constraint/BookOutlineConstraint.php"
      }
    }
    

    That way it works for now, but it's not a solution to the general problem.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    WRT the real solution, the version constraint for this module should have been that it only works with Drupal core >= 10.3 because the used constraint plugin uses an attribute which isn't available in earlier Drupal core versions. Problem is that this can't be corrected now. Even if there were a new release with that constraint, the 1.0.0 release would still be found by composer and then used for the older Drupal core versions.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Turns out, my workaround only works on PHP 8.1, it fails on PHP 8.2 with reflection class exceptions.

    However, that leads towards a proper solution, that I didn't see before: for Drupal core <10.3 we need to remove the attribute usage from the validation plugin and bring back the annotations. That needs to be done both in Drupal core and in the contrib book module.

    Then we need the following releases:

    • Drupal core: we need 9.2.8 with that being fixed
    • Book contrib module: 1.0.1 with that being fixed and a version constraint on Drupal core for >= 10 and <= 10.3
    • Book contrib module: 1.1.0 and 2.0.0 with the attributes left in but a version constraint on Drupal core for >= 10.3

    As a work around for site owners: use the BookOutlineConstraint.php file from #3 and add the 2 scripts to the root composer.json:

    {
      "scripts": {
        "post-update-cmd": "cp config/BookOutlineConstraint.php web/core/modules/book/src/Plugin/Validation/Constraint/BookOutlineConstraint.php && cp config/BookOutlineConstraint.php web/modules/contrib/book/src/Plugin/Validation/Constraint/BookOutlineConstraint.php",
        "post-install-cmd": "cp config/BookOutlineConstraint.php web/core/modules/book/src/Plugin/Validation/Constraint/BookOutlineConstraint.php && cp config/BookOutlineConstraint.php web/modules/contrib/book/src/Plugin/Validation/Constraint/BookOutlineConstraint.php"
      }
    }
    

    This works for Drupal core < 10.3

  • πŸ‡¨πŸ‡¦Canada mparker17 UTC-4

    I can also confirm this error on Drupal 10.2.7.

    Note that Drupal 10.2 will be supported for security fixes until the Week of December 9, 2024 β†’ .

    For now, I think we could solve this problem by either:

    1. switching back to the comment-based annotation in src/Plugin/Validation/Constraint/BookOutlineConstraint.php, or
    2. drop support for 10.2 before its official end-of-life (i.e.: by changing the core_version_requirement in book.info.yml)

    ... do the maintainers have a preference? I can write a patch.

  • Status changed to Needs review 29 days ago
  • πŸ‡¨πŸ‡¦Canada mparker17 UTC-4

    Updated the issue summary.

    Setting to "Needs review" for ideas on whether we should switch back to comment-based annotations, or drop 10.2 support before its EOL.

    For what it's worth, I'm in favour of switching back to comment-based annotations to give people on 10.2 more time to upgrade.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Is this issue strictly related to book 2 or does it also affect book 1?

    I'm seeing something a bit different in this issue I'm marking as "related"

  • πŸ‡¨πŸ‡¦Canada mparker17 UTC-4

    This affects both book-1.0.x and book-2.0.x, because both have core_version_requirement: '>=10 || ^11' (1.0.x, 2.0.x) and both use attribute-based annotations (1.0.x, 2.0.x).

    I happened to run into this while I was testing the sitemap module (which I maintain) on drupal-10.2.7 with book-1.0.0 - so that is how I wrote the test case - but @Liliplanet filed it against book-2.0.x, and I noticed the code was the same in both branches, so I left the Version field alone.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Think since 2.0.x has no release putting a requirement of 10.3 would be best. For the attribute replacements

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Okay this is probably ready to merge and can do an alpha1 release for 2.0.x

    Will have to fix the tests for next minor and next major

  • Status changed to Fixed 4 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Believe we have fix for the failing tests but need the changes here.

  • πŸ‡³πŸ‡±Netherlands MegaChriz

    @smustgrave
    Thanks for the update, but the issue remains that requirements for drupal/book:^1.0 are incorrect.

    I ran into this when trying to test my contrib project with Drupal 10.2, 10.3 and 11.0. Tests were failing on 11.0 when not requiring "drupal/book" and failing on 10.2 when requiring "drupal/book".

    I fixed this by creating a bridge package called "megachriz/drupalbook", a tip that I found on https://stackoverflow.com/questions/51333587/php-composer-require-depend.... By requiring that instead of drupal/book, I'll get drupal/book on Drupal 11 tests only.

    But it would have been easier if drupal/book was compatible with Drupal 10.2.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    1.0.x is a copy of core and goal is to leave that relatively untouched.

    Also in 10.2 book is still in core to be used.

  • πŸ‡³πŸ‡±Netherlands MegaChriz

    Okay, just saying that it created extra work for making modules that depend or integrate with the book module to be compatible with both Drupal 11 and Drupal 10.2. As a module maintainer, you need to require a bridge package in this case.

    On the other hand, grabbing the core book module from Drupal 10.2.x and put that into book 1.x may require some extra work too: I'm not sure if that could just be copied 1 on 1 or if that requires additional changes (like cleaning up references). And I don't know if core book module from Drupal 10.2 would be compatible with Drupal 10.3 or Drupal 11.

Production build 0.71.5 2024