Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
2fe57efe
Commit
2fe57efe
authored
Jun 20, 2013
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2022769
by fubhy, xjm: Fixed conversion of field_delete_field() in hook_uninstall().
parent
5d0f9d91
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
4 deletions
+150
-4
core/modules/comment/comment.install
core/modules/comment/comment.install
+0
-3
core/modules/comment/lib/Drupal/comment/Tests/CommentUninstallTest.php
...comment/lib/Drupal/comment/Tests/CommentUninstallTest.php
+77
-0
core/modules/forum/forum.install
core/modules/forum/forum.install
+4
-1
core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php
...dules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php
+69
-0
No files found.
core/modules/comment/comment.install
View file @
2fe57efe
...
...
@@ -9,9 +9,6 @@
* Implements hook_uninstall().
*/
function
comment_uninstall
()
{
// Delete comment_body field.
field_info_field
(
'comment_body'
)
->
delete
();
// Remove variables.
variable_del
(
'comment_block_count'
);
$node_types
=
array_keys
(
node_type_get_types
());
...
...
core/modules/comment/lib/Drupal/comment/Tests/CommentUninstallTest.php
0 → 100644
View file @
2fe57efe
<?php
/**
* @file
* Definition of Drupal\comment\Tests\CommentUninstallTest.
*/
namespace
Drupal\comment\Tests
;
use
Drupal\simpletest\WebTestBase
;
/**
* Tests comment module uninstallation.
*/
class
CommentUninstallTest
extends
WebTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'comment'
,
'node'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Comment uninstallation'
,
'description'
=>
'Tests comment module uninstallation.'
,
'group'
=>
'Comment'
,
);
}
protected
function
setUp
()
{
parent
::
setup
();
// Create a content type so that the comment module creates the
// 'comment_body' field upon installation.
$this
->
drupalCreateContentType
();
}
/**
* Tests if comment module uninstallation properly deletes the field.
*/
function
testCommentUninstallWithField
()
{
// Ensure that the field exists before uninstallation.
$field
=
field_info_field
(
'comment_body'
);
$this
->
assertNotNull
(
$field
,
'The comment_body field exists.'
);
// Uninstall the comment module which should trigger field deletion.
$this
->
container
->
get
(
'module_handler'
)
->
disable
(
array
(
'comment'
));
$this
->
container
->
get
(
'module_handler'
)
->
uninstall
(
array
(
'comment'
));
// Check that the field is now deleted.
$field
=
field_info_field
(
'comment_body'
);
$this
->
assertNull
(
$field
,
'The comment_body field has been deleted.'
);
}
/**
* Tests if uninstallation succeeds if the field has been deleted beforehand.
*/
function
testCommentUninstallWithoutField
()
{
// Manually delete the comment_body field before module uninstallation.
$field
=
field_info_field
(
'comment_body'
);
$this
->
assertNotNull
(
$field
,
'The comment_body field exists.'
);
$field
->
delete
();
// Check that the field is now deleted.
$field
=
field_info_field
(
'comment_body'
);
$this
->
assertNull
(
$field
,
'The comment_body field has been deleted.'
);
// Ensure that uninstallation succeeds even if the field has already been
// deleted manually beforehand.
$this
->
container
->
get
(
'module_handler'
)
->
disable
(
array
(
'comment'
));
$this
->
container
->
get
(
'module_handler'
)
->
uninstall
(
array
(
'comment'
));
}
}
core/modules/forum/forum.install
View file @
2fe57efe
...
...
@@ -122,7 +122,10 @@ function forum_uninstall() {
variable_del
(
'node_options_forum'
);
field_info_field
(
'taxonomy_forums'
)
->
delete
();
if
(
$field
=
field_info_field
(
'taxonomy_forums'
))
{
$field
->
delete
();
}
// Purge field data now to allow taxonomy module to be uninstalled
// if this is the only field remaining.
field_purge_batch
(
10
);
...
...
core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php
0 → 100644
View file @
2fe57efe
<?php
/**
* @file
* Definition of Drupal\forum\Tests\ForumUninstallTest.
*/
namespace
Drupal\forum\Tests
;
use
Drupal\simpletest\WebTestBase
;
/**
* Tests forum module uninstallation.
*/
class
ForumUninstallTest
extends
WebTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'forum'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Forum uninstallation'
,
'description'
=>
'Tests forum module uninstallation.'
,
'group'
=>
'Forum'
,
);
}
/**
* Tests if forum module uninstallation properly deletes the field.
*/
function
testForumUninstallWithField
()
{
// Ensure that the field exists before uninstallation.
$field
=
field_info_field
(
'taxonomy_forums'
);
$this
->
assertNotNull
(
$field
,
'The taxonomy_forums field exists.'
);
// Uninstall the forum module which should trigger field deletion.
$this
->
container
->
get
(
'module_handler'
)
->
disable
(
array
(
'forum'
));
$this
->
container
->
get
(
'module_handler'
)
->
uninstall
(
array
(
'forum'
));
// Check that the field is now deleted.
$field
=
field_info_field
(
'taxonomy_forums'
);
$this
->
assertNull
(
$field
,
'The taxonomy_forums field has been deleted.'
);
}
/**
* Tests if uninstallation succeeds if the field has been deleted beforehand.
*/
function
testForumUninstallWithoutField
()
{
// Manually delete the taxonomy_forums field before module uninstallation.
$field
=
field_info_field
(
'taxonomy_forums'
);
$this
->
assertNotNull
(
$field
,
'The taxonomy_forums field exists.'
);
$field
->
delete
();
// Check that the field is now deleted.
$field
=
field_info_field
(
'taxonomy_forums'
);
$this
->
assertNull
(
$field
,
'The taxonomy_forums field has been deleted.'
);
// Ensure that uninstallation succeeds even if the field has already been
// deleted manually beforehand.
$this
->
container
->
get
(
'module_handler'
)
->
disable
(
array
(
'forum'
));
$this
->
container
->
get
(
'module_handler'
)
->
uninstall
(
array
(
'forum'
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment