Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As a result of an upgrades and theme changes, not all of a site's blocks can be assumed to have database rows. Because the block module only runs UPDATE to save block settings, blocks without existing rows don't get saved.
The easiest solution is to add @db_query('INSERT INTO {blocks} (module, delta, theme) VALUES ("%s", "%s", "%s")', $block['module'], $block['delta'], $block['theme']);
directly before the UPDATE query in block_admin_display_form_submit
.
Comments
Comment #1
Coornail CreditAttribution: Coornail commentedI would prefer to useON DUPLICATE KEY UPDATE
(MySQL manual).That's a mysql specific thing =(
Comment #2
dpearcefl CreditAttribution: dpearcefl commentedIs this still an issue in modern Drupal?
Comment #3
dpearcefl CreditAttribution: dpearcefl commented