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

  1. Patch
  2. Review
  3. Commit

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#5 term_condition-3222715-5.patch611 bytesrosk0
Command icon 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

RoSk0 created an issue. See original summary.

xurizaemon’s picture

Issue summary: View changes

Steps 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.

xurizaemon’s picture

Since the dependency would reference the term by UUID, I believe this depends on #2695141: Store UUID for exportability

rosk0’s picture

Title: Properly expose config dependencies in block configuration » [PP-1] Properly expose config dependencies in block configuration
Issue summary: View changes
Status: Active » Postponed
Related issues: +#2695141: Store UUID for exportability
StatusFileSize
new611 bytes

As 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.

rosk0’s picture

Status: Postponed » Needs review

Ready for review now when #2695141: Store UUID for exportability is committed.

rosk0’s picture

Title: [PP-1] Properly expose config dependencies in block configuration » Properly expose config dependencies in block configuration

Forgot to update title.

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.