Clear blocks table of old theme references

Created on 15 September 2010, over 14 years ago
Updated 12 February 2024, 11 months ago

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

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
BlockΒ  β†’

Last updated 6 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States ealtman Northridge, CA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ͺπŸ‡ΈSpain candelas

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

  • πŸ‡ͺπŸ‡ΈSpain candelas

    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';

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    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.

  • πŸ‡ͺπŸ‡ΈSpain candelas

    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')"

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    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 ✨ Clear blocks table of old theme references Active ):

    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';"
    
Production build 0.71.5 2024