Community

Blocks are not deleted from block database table when theme is deactivated?!

Hi,

I just found out that blocks are not deleted from blocks database table - I have a large project with many blocks from different views and modules as some themes. This alone leads to many rows in database table. Additionally the block settings for every theme I ever had activated are still found in this table. This leads to thousands of rows in this table which are totally useless. Maybe in D7 there was a change but if not I think one should be think of how this could be avoided maybe in D8?! I am not really a programmer - just wanted to spread this :-)

Best,
Tobias

Comments

=-=

The issue you are having is due to themes not having an uninstall routine. disabling a theme or a module for that matter doesn't do anything to the database except set the status to 0 which means off. Themes by their nature aren't installed. They are enabled. Thus they aren't uninstalled. They are disabled. If disabling a theme removed the block settings from the DB, then every time someone tried a new theme, and decided to go back o the old one then they would have to reset the blocks. That said, an argument can be made that themes should have uninstall routines. The problem with that may be that there can't be any install routine since themes don't install blocks.

As an aside, the issue can be avoided by using the context module to place blocks. contexts are also the way Drupal 8 is moving.