We have two blocks in the header of our main page of our dev version. The display order recently got reversed, despite what the blocks interface was telling me. I reordered the blocks in the interface again and the error corrected itself, but this started me looking at the blocks table. I see that a new bid is created for every instance in every theme. We have about 3 or 4 old themes that have been removed from that instance, but the rows in the blocks table referring to them remain. Is this info supposed to get cleared out when you properly deactivate and uninstall a theme? It's possible we just deactivated and then deleted the theme folder.
Thanks,
Elizabeth

Comments

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.

Collins405’s picture

Issue summary: View changes

I have just noticed this as well, what are the implications of deleting these from the block table?

Collins405’s picture

Version: 6.19 » 7.43
Collins405’s picture

Status: Closed (outdated) » Active
jalpesh’s picture

Hi,

I don't see this functionality as bug. It may possible that user can enable/disable more then one theme to check which one suit best to website. The block entry will remain as it is because it may possible that user install same theme which was enable in past. All the setting like block assigning in region done in past will not required to do it again.

Let me know in case if you have still confusion in it.

Collins405’s picture

@jalpesh So how would one clear these? Is it safe to just delete the database rows, or better to re-enable the theme and disable/delete blocks there?

jalpesh’s picture

It is batter if you re-enable and remove all block from theme and then disable it instead of deleting from DB. It may possible direct row delete from DB cause issue in future.

Version: 7.43 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

ressa’s picture

Version: 7.x-dev » 9.5.x-dev

I ran into this after upgrading a web site from Drupal 7 to Drupal 9, originally started in Drupal 5.

After exporting the config files, I noticed quite a few left over ghost blocks from previous themes that were installed over the years, golden oldies such as Bluemarine and BlueBreeze with files such as block.block.bluebreeze_user_login.yml. I tried removing the config files and importing the config, but got a lot of dependency errors and missing theme, which blocked it.

My solution was to create a minimal theme with the same name:

$ tree bluebreeze/
bluebreeze/
└── bluebreeze.info.yml

$ cat bluebreeze/bluebreeze.info.yml 
name: Bluebreeze
type: theme
base theme: false
core_version_requirement: ^8 || ^9
description: 'A theme to delete old blocks with.'

regions:
  header: 'Header'
  primary_menu: 'Primary menu'
  sidebar: 'Sidebar'
  content: 'Content'
  footer: 'Footer'

... and install and uninstall the theme with drush theme:enable bluebreeze and drush theme:uninstall bluebreeze.

After that I could verify that the theme and blocks had been fully removed from the system:

$ drush config:status
 ----------------------------------- ------------------ 
  Name                                State             
 ----------------------------------- ------------------ 
  block.block.bluebreeze_user_login   Only in sync dir  
 ----------------------------------- ------------------ 
$ drush config:export --diff
 [notice] Differences of the active config to the export directory:
diff --git a/tmp/drush_tmp_1662884366_631d9a0e1c5e4/block.block.bluebreeze_user_login.yml b/tmp/drush_tmp_1662884366_631d9a0e1c5e4/block.block.bluebreeze_user_login.yml
deleted file mode 100644
[...]

I renamed the folder and file to bluemarine and bluemarine.info.yml, and cleaned up those blocks, etc.

I hope it helps someone :-)

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

candelas’s picture

I am having the same problem. Thanks @ressa . I go to test your solution.

candelas’s picture

Buf, when I try to import one image style, I get like 25 problems with old themes (since Drupal 5) that don't let to me.
So I went to the database and search them and delete. I put here one example, just in case someone finds this. Also I don't understand why an image style has to give this errors. I translate because the errors are in Catalan (though as an admin I have English). I try to import with drush, so this is what my terminal gets.
The error
The configuration <em class="placeholder">block.block.adminimal_system_main</em> depend on the theme <em class="placeholder">adminimal</em> that will not be installed after import.
The sql to delete it
DELETE FROM `key_value` WHERE `key_value`.`collection` = 'config.entity.key_store.block' AND `key_value`.`name` = 'theme:adminimal';

ressa’s picture

Thanks for sharing @candelas. Would this be safe to use? Of course only if Adminimal theme will not be used any longer:

drush sql:query "DELETE FROM `key_value` WHERE `key_value`.`name` = 'theme:adminimal';"

In case you still have a back up of the database, it would be interesting to find a command which can clear all blocks from an ancient, removed theme.

candelas’s picture

The problem is that each of us will have different ones.
And if you make a database backup, you are not using anymore the adminimal theme, you can run that command without problem.
At the end, I have used this drush command

drush sql:query "DELETE FROM config WHERE name IN ('block.block.bluebreeze_new_fixed_user_login ', 'block.block.bluebreeze_new_node_syndicate', 'block.block.bluebreeze_new_search_form', 'block.block.bluebreeze_new_user_login', 'block.block.bluebreeze_node_syndicate', 'block.block.bluebreeze_search_form', 'block.block.bluebreeze_user_login', 'block.block.bluemarine_node_syndicate', 'block.block.bluemarine_user_login', 'block.block.bootstrap_block_8', 'block.block.bootstrap_system_main', 'block.block.bootstrap_user_login', 'block.block.box_grey_node_syndicate', 'block.block.box_grey_search_form', 'block.block.box_grey_user_login', 'block.block.garland_block_15', 'block.block.garland_block_8', 'block.block.garland_block_9', 'block.block.garland_menu_menu_collaboration', 'block.block.garland_node_syndicate', 'block.block.garland_system_main', 'block.block.garland_user_login', 'block.block.jul_fixed_node_syndicate', 'block.block.jul_fixed_search_form', 'block.block.jul_fixed_user_login', 'block.block.jul_node_syndicate', 'block.block.jul_search_form', 'block.block.jul_user_login', 'block.block.lela_block_15', 'block.block.lela_block_8', 'block.block.lela_block_9', 'block.block.lela_menu_menu_collaboration', 'block.block.lela_node_syndicate', 'block.block.lela_search_form', 'block.block.lela_system_main', 'block.block.lela_user_login', 'block.block.seven_block_17', 'block.block.seven_menu_menu_collaboration', 'block.block.seven_search_form', 'block.block.seven_system_main', 'block.block.stark_search_form', 'block.block.stark_system_main', 'bluebreeze-fixed.settings', 'bluebreeze.settings', 'bluemarine.settings', 'box.settings', 'jul.settings', 'language.content_settings.menu_link_content.menu_link_content', 'lela.settings')"

ressa’s picture

I agree, every Drupal installation's lingering left over theme cruft will be unique, for sure. My thinking is just that for example for me, I only had left over block references from two themes, so in my case it might have been enough to run these two commands, as opposed to my workaround to create a dummy-theme (#9):

drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:bluemarine';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:bluebreeze';"

Similarly, in your case, these commands might have take care of most old references for you (though box might not have been a theme?):

drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:bluebreeze';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:bluemarine';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:bootstrap';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:box';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:garland';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:jul';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:lela';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:seven';"
drush sql:query "DELETE FROM `key.value` WHERE `key.value`.`name` = 'theme:stark';"