Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 299230

Block name collision on theme creation

$
0
0

Problem/Motivation

During theme initialization, block_theme_initialize() copies over existing blocks and gives them a machine name prefixed with the theme name. It does not check to see if a block exists with this name already.

Steps to reproduce

See #2858897-17: Block name collision on theme creation:

Initial setup

Prepare two themes:

  1. Theme 1: themeone, Active, default
  2. Theme 2: themetwo, Disabled

Setup steps:

  1. Using Theme 1 theme, place a block with id: a_block_with_a_cool_id
  2. In the same theme, place a block with this id: themetwo_a_block_with_a_cool_id
  3. Enable Theme 2. In the process, this will copy the blocks from the default theme themeone to themetwo
  4. and prepend the theme machine name to the final block ID.

The copy process fails because, when trying to copy a_block_with_a_cool_id to themetwo, this will create themetwo_a_block_with_a_cool_id, resulting in a failure for ID duplicate (because already exists in themeone).

This is from memory, so I hope I don't give any wrong indication.

Proposed resolution

Move the logic in \Drupal\block\BlockForm::getUniqueMachineName to a location where it can be shared with block_theme_initialize.

Remaining tasks

Review latest patch in #2858897-29: Block name collision on theme creation, and get core maintainer review to push this forward.

User interface changes

None?

API changes

@tbd

Data model changes

Drupal will add an integer-increasing counter (e.g. _1, _2) to conflicting blocks when processing a cloned block for an enabled theme (in block_theme_initialize()).


Viewing all articles
Browse latest Browse all 299230

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>