- Issue created by @anilu@
- πΊπΈUnited States anilu@ Houston, TX
The primary issue is with the BookOutlineConstraintValidator in the Book module. This validator is designed to prevent changes to book outlines in non-default (draft) revisions.
The key problematic code is in the validate() method of the BookOutlineConstraintValidator class:public function validate($entity, Constraint $constraint): void { // Validate the book structure when the user has access to manage book // outlines. When the user can manage book outlines, the book variable will // be populated even if the node is not part of the book. If the user cannot // manage book outlines, the book variable will be empty, and we can safely // ignore the constraints as the outline cannot be changed by this user. if (isset($entity) && !$entity->isNew() && !$entity->isDefaultRevision()) { /** @var \Drupal\Core\Entity\ContentEntityInterface $original */ $original = $this->bookManager->loadBookLink($entity->id(), FALSE) ?: [ 'bid' => 0, 'weight' => 0, ]; if (empty($original['pid'])) { $original['pid'] = -1; } if ($entity->book['bid'] != $original['bid']) { $this->context->buildViolation($constraint->message) ->atPath('book.bid') ->setInvalidValue($entity) ->addViolation(); } // Additional validation code... } }
This constraint validator triggers when:
- An entity exists (isset($entity))
- The entity is not new (!$entity->isNew())
- The entity is not the default revision (!$entity->isDefaultRevision())
- πΊπΈUnited States anilu@ Houston, TX
Last development version for this module has the required validation for $value->book on src/Plugin/Validation/Constraint/BookOutlineConstraintValidator.php
if (isset($value) && !empty($value->book) && !$value->isNew() && !$value->isDefaultRevision()) {
This should be working, but is not. This may be related to the update from core to contrib module.
- πΊπΈUnited States anilu@ Houston, TX
I write a script on composer that removes book core module. For now this should work for anyone that needs a quick fix.
{ "scripts": { "post-install-cmd": [ "rm -rf web/core/modules/book", "@composer drupal:scaffold" ], "post-update-cmd": [ "rm -rf web/core/modules/book", "@composer drupal:scaffold" ] } }
- Merge request !84Issue #3519344 by anilu: Skip validation if the node type is not allowed in book outlines β (Open) created by anilu@
- πΊπΈUnited States anilu@ Houston, TX
Automatic testing failed because of update to 3.0 branch. Manually applying the patch is working on my project but we need to update the patch and continued testing.
At this moment, I am not sure if this is a long term solution. Open to hear oppinions.