See also #2692247: Pre-existing 'forum' content type prevents forum module installation
Problem/Motivation
In a D8 site with the book module not installed:
- Manually create a node type with machine name "book". Or, perform a migration from a site with a "book" content type.
- Go to the Extend page and try to install the book module.
- "Unable to install Book, core.entity_form_display.node.book.default, core.entity_view_display.node.book.default, core.entity_view_display.node.book.teaser, field.field.node.book.body, node.type.book already exist in active configuration.">
Proposed resolution
Move all node and field configuration from config/install to config/optional.
Remaining tasks
Do it.
User interface changes
None.
API changes
None.
Data model changes
None.
Original report
I have a Drupal 7 installation, for which I'm exploring possibilities of migrating to Drupal8.
Of the many things, one that looks core to Drupal8 issue is the 'book' module. In drupal 7, I have a collection of pages organized as the book. After migration to Drupal8, only the 1st leaf of the book is displayed. The rest of the contents are not interlinked.
On looking at the modules page, I noticed that the 'book' module was not enabled. Trying to enabled it resulted in the following error:
Unable to install Book, core.entity_form_display.node.book.default, core.entity_view_display.node.book.default, core.entity_view_display.node.book.teaser, core.entity_view_mode.node.print, field.field.node.book.body, node.type.book already exist in active configuration.
Screenshot of error attached.
Steps to reproduce
- Install drupal 7 and populate it with content organizing it as a book
- Migrate to Drupal 8 as has been documented
- Check basic website status by clicking on the book
- Check modules page. you may notice that 'book' module is inactive
- try activating it and you may get an error like i've mentioned in the screenshot.
Comment | File | Size | Author |
---|---|---|---|
#24 | book_installed.png | 90.39 KB | Sophie.SK |
#23 | drupal-check-existing-book-2714497-23.patch | 12.74 KB | mangy.fox |
#20 | interdiff-2714497-18-20.txt | 1.15 KB | Peacog |
#20 | drupal-check-existing-book-2714497-20.patch | 12.27 KB | Peacog |
#20 | drupal-check-existing-book-2714497-20-tests-only.patch | 1.22 KB | Peacog |
Comments
Comment #2
mikeryanYou must enable the book module *before* running the upgrade process for the book hierarchy info to be migrated. See Preparing an upgrade, "Enable required modules" section.
As for the consequences of not enabling the module first, the forum module has the same issue: #2692247: Pre-existing 'forum' content type prevents forum module installation.
Comment #3
riteshsarraf CreditAttribution: riteshsarraf commentedThank you very much for the info @mikeryan. I surely must have missed that paragraph tagged "Enable required Modules". I'll try this again this weekend on a fresh setup, and update this bug report accordingly.
Comment #4
riteshsarraf CreditAttribution: riteshsarraf commentedI tried it again today.
As you advised, I enabled the 'Book' module prior to initiating the migration.
It did report seeing the 'Book' content. But the final presentation of the data in Drupal8 is not accordingly.
Even after I enabled the 'book' module in d8, at the migration page (screenshot) it reported it as missing. Is it to assume that the migrate module currently doesn't have an upgrade path for the 'Book' module's content ?
Comment #5
mediameriquat CreditAttribution: mediameriquat as a volunteer commentedI migrated a fairly simple D7 site to D8. The book module was properly activated on D8 before proceeding, but the migration of the book hierarchy failed.
I had to manually rebuild my books, after making sure all relevant content types can be included in admin/structure/book/settings. Of course, this would not have been a solution if I had dozens of books containing hundreds of pages.
Comment #6
riteshsarraf CreditAttribution: riteshsarraf commented@mediameriquat
THere is a bug with Drupal. It is referenced in this bug report.
But I wish they did a proper release than a half baked one. Bare features like migration of data generated from core modules break. :-(
Comment #7
mikeryanUpdating the title/issue summary to reflect the current understanding and the corresponding fix we've made to the forum module: #2692247: Pre-existing 'forum' content type prevents forum module installation
Comment #8
mikeryanMarking as a novice task - if you follow the forum example, this should be straight-forward.
Comment #9
Peacog CreditAttribution: Peacog as a volunteer commentedI've made a patch for this, following the forum example.
Comment #10
riteshsarraf CreditAttribution: riteshsarraf commentedHello @Peacog,
So what happens next now?
I'm not versed with Drupal's process but we have a bug and we have a patch.
We need a review of the patch (presumably by someone from the Drupal core team?).
And currently the bug is marked as 'Unassigned'.
Comment #11
Peacog CreditAttribution: Peacog as a volunteer commentedHi @riteshsarraf
Now we need a few people to use the patch and report back here whether it works or not, whether it passes coding standings, etc. If the patch seems OK eventually a core maintainer will review it and commit. It doesn't need to be assigned to anyone.
Comment #13
dawehnerThank you for your contribution!
One thing we could add here is some automated test to ensure the installation bug, as described in the issue is actually fixed.
So:
Comment #14
dawehnerdouble postComment #15
Peacog CreditAttribution: Peacog as a volunteer commentedI've added the test as suggested in #14. The tests-only patch will fail with a PreExistingConfigException exception, and the full patch should pass. I don't have much experience writing tests so I don't know if I need to output some kind of message when the test passes. If so, what's the best way to do that?
Comment #18
Peacog CreditAttribution: Peacog as a volunteer commentedHere's another go at the full patch. The tests-only patch from #15 is OK.
Comment #19
borisson_The test-only patch shows the failure as expected but it crashes with an exception.
It can be
I also checked the patch for coding standards / documentation and I did find a couple of things to be improved.
This needs a period at the end.
This should use {@inheritdoc} instead of the full description.
The first line of a docblock should be only 1 line of max 80 cols. So the comment should be rewritten.
This comment should also have a period at the end.
Comment #20
Peacog CreditAttribution: Peacog as a volunteer commentedThanks for the review @borisson_.
I've fixed it so that the tests-only patch now catches the expected exception. As for coding standards:
1. Fixed
2. {@inheritdoc} is not needed because the comment refers to a variable declaration, not a method.
3. The first line of the docblock is already less than 80 characters so I've left that unchanged too.
4. Fixed
Comment #21
Peacog CreditAttribution: Peacog as a volunteer commentedComment #23
mangy.fox CreditAttribution: mangy.fox at Investis Digital commentedPatch #20 no longer applies cleanly, so re-rolled against current 8.3.x.
I also added a new summary for the install test, to comply with coding standards.
Comment #24
Sophie.SKPatch applied locally and works perfectly.
Attached is a screenshot showing the module being successfully enabled (with existing Book content type and patch applied).
Comment #25
Sophie.SKWhoops, forgot status update!
Comment #26
Sophie.SKComment #28
catchCommitted/pushed to 8.3.x, thanks!