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.
Hello!
The webform block (WebformBlock
) does not report any dependency, but in fact it does depend on the webform config entity.
Failure to report its dependency may lead to a situation when the dependent webform is removed and the block then has difficult time figuring out what to do. If the dependency is reported, then core configuration API will not allow a webform to be deleted before all of its blocks are removed too.
Supplying a patch shortly.
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-10-12.txt | 1.91 KB | bucefal91 |
#12 | 2944515-block-dependencies-12.patch | 9.29 KB | bucefal91 |
| |||
#10 | 2944515-block-dependencies-9_.patch | 7.38 KB | bucefal91 |
| |||
#10 | interdiff-6-9.txt | 813 bytes | bucefal91 |
#6 | interdiff-4-6.txt | 719 bytes | bucefal91 |
Comments
Comment #2
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedThis patch fixes the bug + covers it with a unit test.
I shall additionally:
Comment #4
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedWe should see 100% pass now.
I also addressed both items from my previous comment - update hook (tested manually and confirm it works), and cleaning up WebformBlock from checking whether $webform exists.
Comment #6
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedAlright, now yes, let the show start :) I've fixed the failing test.
My changes in
WebformBlock
made it a little stricter about block initialization (you can't save a block until you have defined its webform) - this patch fixes up the failing test so it specifies the webform at the moment of block creation and not afterwords as it was doing before.Comment #7
jrockowitz CreditAttribution: jrockowitz at The Big Blue House commentedThis is causing a merge conflict.
Otherwise, the patch looks good.
Comment #8
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedI also have 1 extra thing. It popped up in my head after I switched off the computer yesterday. The current update hook will fail with fatal error if there is already inconsistency in the DB, i.e. if there is already a block whose webform has been deleted. I will wrap the re-saving of the $block with checking whether it's webform exists. If it exists I will proceed to re-saving, but if it doesn't, I will instead delete the block since there is no use of it when it's not backed by any existing webform.
Comment #9
jrockowitz CreditAttribution: jrockowitz at The Big Blue House commentedCan you please also update exported blocks that included in the below test modules?
Comment #10
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedMy #8 is addressed in this patch. I've just tested the new update hook manually having 2 blocks: one block was fine (backed by an existing webform) and another was corrupted (the webform was removed while keeping the block around).
After running the update hook the corrupted block is removed from DB without any error. The OK block is successfully re-saved to acknowledge drupal core of its correct dependencies.
As far as the minor conflict - I rebased my local branch and the patch now does not contain the conflict.
Comment #11
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedJust saw your comment. Yup. I'll look into those.
Comment #12
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedI scanned all the blocks stored in /config folders of all the (sub-)modules and only 2 blocks were built on "webform_block" plugin. This patch updates those 2 blocks with proper dependencies.
Comment #13
jrockowitz CreditAttribution: jrockowitz at The Big Blue House commentedComment #15
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedCommitted :)