Problem/Motivation
Taxonomy term referenced in "Select taxonomy term(s)" on the block configuration form should also be added as a dependency to the configuration object of that block.
See how happens with content blocks for example: when you create custom content block and place it in the region, configuration object for that block placement have a dependency entry like this:
langcode: en
status: true
dependencies:
content:
- 'block_content:basic:79af5eed-a1cb-4da7-aeec-56d650fb196d'
module:
- block_class
- block_content
- system
theme:
- sector_radix_starter
id: backtotop_2
Example above is from Sector configuration block.block.backtotop_2.yml.
Steps to reproduce
- Create a term and a block
- Assign the block to display based on the presence of the term
- Delete the term
- View the block configuration form
Expected behaviour: dependency should prevent deletion of the required term.
Actual behaviour: term can be deleted, and this results in an error 500 when editing the block configuration; block config can no longer be edited via UI.
Proposed resolution
Add term from the configuration to the dependencies.
Remaining tasks
- Patch
- Review
- Commit
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | term_condition-3222715-5.patch | 611 bytes | rosk0 |
Issue fork term_condition-3222715
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xurizaemonSteps to reproduce:
- Create a term
- Assign some block to display based on the presence of the term
- Delete the term
- View the block configuration form
Result:
InvalidArgumentException: The #default_value property has to be an entity object or an array of entity objects. in Drupal\Core\Entity\Element\EntityAutocomplete::valueCallback() (line 114 of core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php). call_user_func_array(Array, Array) (Line: 1278) Drupal\Core\Form\FormBuilder->handleInputElement('block_form', Array, Object) (Line: 1001) Drupal\Core\Form\FormBuilder->doBuildForm('block_form', Array, Object) (Line: 1071) Drupal\Core\Form\FormBuilder->doBuildForm('block_form', Array, Object) (Line: 1071) Drupal\Core\Form\FormBuilder->doBuildForm('block_form', Array, Object) (Line: 1071) Drupal\Core\Form\FormBuilder->doBuildForm('block_form', Array, Object) (Line: 575) Drupal\Core\Form\FormBuilder->processForm('block_form', Array, Object) (Line: 321) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 54) Drupal\trusted_reverse_proxy\StackMiddleware\TrustedReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)Config dependency should prevent deleting the term until the dependent configuration is cleared.
Comment #3
xurizaemonSince the dependency would reference the term by UUID, I believe this depends on #2695141: Store UUID for exportability
Comment #4
xurizaemonLooks like the above was previously raised in #3059379: Notice: Undefined index: tid in Drupal\term_condition\Plugin\Condition\Term->buildConfigurationForm() (line 60 of modules/contrib/term_condition/src/Plugin/Condition/Term.php). and #3068565: Issues if a taxonomy term is deleted.
Time willing, I hope to address #3251165: Test coverage so we can get onto this one.
Comment #5
rosk0As noted in #3 this is dependent on #2695141: Store UUID for exportability so postponing based on this.
Supplied patch relies on #2695141: Store UUID for exportability committed.
Comment #6
rosk0Ready for review now when #2695141: Store UUID for exportability is committed.
Comment #7
rosk0Forgot to update title.
Comment #11
astonvictor commented