Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Saving Book configuration is not possible due to an error in form validation. See attached image.
Steps to reproduce
- Install the latest Drupal 8.9.x using the standard profile.
- enable the Book module
- Go to admin/structure/book/settings and save the configuration form. You will get an error.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Original report by [JD_1]
The created patch is breaking my configuration.
See attached image after which occurs after patching to D8.9.7(+)
Comment | File | Size | Author |
---|---|---|---|
#16 | 3181173-16.patch | 2.01 KB | longwave |
#16 | 3181173-16-test-only.patch | 751 bytes | longwave |
Bug.png | 73 KB | dbielke1986 |
Comments
Comment #2
dbielke1986 CreditAttribution: dbielke1986 commentedI need to revert the changes which were made here:
https://git.drupalcode.org/project/drupal/commit/cb2e043f53fcf05dd20d164...
Comment #3
dbielke1986 CreditAttribution: dbielke1986 commentedComment #4
dbielke1986 CreditAttribution: dbielke1986 commentedError which occurs:
"The content type for the Add child page link must be one of those selected as an allowed book outline type."
Comment #5
dbielke1986 CreditAttribution: dbielke1986 commentedI did some more research...
$child_types is empty after the following line:
array_filter() is not working, because "$form_state->getValue('book_child_type')" is just a string of the content type like "book"
Comment #6
dbielke1986 CreditAttribution: dbielke1986 commentedAnd I think it was mentioned here:
https://www.drupal.org/project/drupal/issues/315176#comment-12171773
So it only should be this patch be applied:
https://www.drupal.org/files/issues/315176-array_filter_remains-27.patch
Comment #7
dbielke1986 CreditAttribution: dbielke1986 commentedComment #8
larowlanHi, can you please elaborate on what the issue is, e.g do you get an error, if so what is the error
Thanks
Comment #9
dbielke1986 CreditAttribution: dbielke1986 commentedHi larowlan,
At the moment (with Drupal 8.9.7 and later) no one can activate a content type to create books or change the book settings.
The reason is the mentioned error in the form of the bool settings. Please see the attached screenshot.
It seems to me that the array_filter() function is killing the provided string, because it is just a string, not an array.
In the linked issue the comment (https://www.drupal.org/project/drupal/issues/315176#comment-12171773) reverts the patches which was committed to the core.
BR
Daniel
Comment #10
dbielke1986 CreditAttribution: dbielke1986 commentedComment #11
pefferen CreditAttribution: pefferen as a volunteer commentedComment #12
pefferen CreditAttribution: pefferen as a volunteer commentedRewrote the form validation and form submit methods, locally this works, I can save the form again, without getting a warning.
Comment #13
pefferen CreditAttribution: pefferen as a volunteer commentedComment #14
dbielke1986 CreditAttribution: dbielke1986 commented@pefferen
Perfect! Exactly what I did to fix this problem.
Is working for me, too.
Comment #15
longwaveWe need a test for this form to make sure we don't break it again.
Comment #16
longwaveComment #18
larowlanComment #21
catchCommitted/pushed to 9.2.x and cherry-picked back through to 8.9.x, thanks!