Created
April 27, 2010 11:37
-
-
Save jacobSingh/380645 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 29420009e02a0aa053678e31c14475206cf4d125 Mon Sep 17 00:00:00 2001 | |
From: dries <dries> | |
Date: Tue, 9 Mar 2010 12:09:52 +0000 | |
Subject: [PATCH] - Patch #735900 by andypost: deleting custom block does not clean block_role() table. | |
--- | |
modules/block/block.admin.inc | 6 +++++- | |
modules/block/block.module | 16 +++++++++++++++- | |
modules/block/block.test | 9 ++++++++- | |
3 files changed, 28 insertions(+), 3 deletions(-) | |
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc | |
index 952d675..807ea2c 100644 | |
--- a/modules/block/block.admin.inc | |
+++ b/modules/block/block.admin.inc | |
@@ -1,5 +1,5 @@ | |
<?php | |
-// $Id: block.admin.inc,v 1.74 2010/03/09 03:48:59 dries Exp $ | |
+// $Id: block.admin.inc,v 1.75 2010/03/09 12:09:52 dries Exp $ | |
/** | |
* @file | |
@@ -516,6 +516,10 @@ function block_custom_block_delete_submit($form, &$form_state) { | |
->condition('module', 'block') | |
->condition('delta', $form_state['values']['bid']) | |
->execute(); | |
+ db_delete('block_role') | |
+ ->condition('module', 'block') | |
+ ->condition('delta', $form_state['values']['bid']) | |
+ ->execute(); | |
drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info']))); | |
cache_clear_all(); | |
$form_state['redirect'] = 'admin/structure/block'; | |
diff --git a/modules/block/block.module b/modules/block/block.module | |
index c337d24..2ba13d6 100644 | |
--- a/modules/block/block.module | |
+++ b/modules/block/block.module | |
@@ -1,5 +1,5 @@ | |
<?php | |
-// $Id: block.module,v 1.412 2010/03/09 03:48:59 dries Exp $ | |
+// $Id: block.module,v 1.413 2010/03/09 12:09:52 dries Exp $ | |
/** | |
* @file | |
@@ -925,3 +925,17 @@ function block_form_system_performance_settings_alter(&$form, &$form_state) { | |
'#weight' => -1, | |
); | |
} | |
+ | |
+/** | |
+ * Implements hook_modules_uninstalled(). | |
+ * | |
+ * Cleanup {block} and {block_role} tables from modules' blocks. | |
+ */ | |
+function block_modules_uninstalled($modules) { | |
+ db_delete('block') | |
+ ->condition('module', $modules, 'IN') | |
+ ->execute(); | |
+ db_delete('block_role') | |
+ ->condition('module', $modules, 'IN') | |
+ ->execute(); | |
+} | |
diff --git a/modules/block/block.test b/modules/block/block.test | |
index 87e771f..d5b46e2 100644 | |
--- a/modules/block/block.test | |
+++ b/modules/block/block.test | |
@@ -1,5 +1,5 @@ | |
<?php | |
-// $Id: block.test,v 1.45 2010/03/09 03:48:59 dries Exp $ | |
+// $Id: block.test,v 1.46 2010/03/09 12:09:52 dries Exp $ | |
/** | |
* @file | |
@@ -84,11 +84,18 @@ class BlockTestCase extends DrupalWebTestCase { | |
$this->assertRaw(l(t('configure'), 'admin/structure/block/manage/block/' . $bid . '/configure'), t('Custom block configure link found.')); | |
$this->assertRaw(l(t('delete'), 'admin/structure/block/manage/block/' . $bid . '/delete'), t('Custom block delete link found.')); | |
+ // Set visibility only for authenticated users, to verify delete functionality. | |
+ $edit = array(); | |
+ $edit['roles[2]'] = TRUE; | |
+ $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', $edit, t('Save block')); | |
+ | |
// Delete the created custom block & verify that it's been deleted and no longer appearing on the page. | |
$this->clickLink(t('delete')); | |
$this->drupalPost('admin/structure/block/manage/block/' . $bid . '/delete', array(), t('Delete')); | |
$this->assertRaw(t('The block %title has been removed.', array('%title' => $custom_block['info'])), t('Custom block successfully deleted.')); | |
$this->assertNoText(t($custom_block['title']), t('Custom block no longer appears on page.')); | |
+ $count = db_query("SELECT 1 FROM {block_role} WHERE module = :module AND delta = :delta", array(':module' => $custom_block['module'], ':delta' => $custom_block['delta']))->fetchField(); | |
+ $this->assertFalse($count, t('Table block_role being cleaned.')); | |
} | |
/** | |
-- | |
1.6.4+GitX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not sure if this is a big deal, just cruft.