Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-2563515
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-2563515
Commits
896105cf
Commit
896105cf
authored
1 year ago
by
nicxvan
Browse files
Options
Downloads
Patches
Plain Diff
Convert 57 to MR
parent
16964d02
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#134024
failed
1 year ago
Stage: 🏗️ Build
Stage: 🪄 Lint
Stage: 🗜️ Test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lib/Drupal/Core/Entity/ContentUninstallValidator.php
+14
-6
14 additions, 6 deletions
core/lib/Drupal/Core/Entity/ContentUninstallValidator.php
core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php
+11
-0
11 additions, 0 deletions
...tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php
with
25 additions
and
6 deletions
core/lib/Drupal/Core/Entity/ContentUninstallValidator.php
+
14
−
6
View file @
896105cf
...
...
@@ -40,12 +40,20 @@ public function validate($module) {
$entity_types
=
$this
->
entityTypeManager
->
getDefinitions
();
$reasons
=
[];
foreach
(
$entity_types
as
$entity_type
)
{
if
(
$module
==
$entity_type
->
getProvider
()
&&
$entity_type
instanceof
ContentEntityTypeInterface
&&
$this
->
entityTypeManager
->
getStorage
(
$entity_type
->
id
())
->
hasData
())
{
$reasons
[]
=
$this
->
t
(
'There is content for the entity type: @entity_type. <a href=":url">Remove @entity_type_plural</a>.'
,
[
'@entity_type'
=>
$entity_type
->
getLabel
(),
'@entity_type_plural'
=>
$entity_type
->
getPluralLabel
(),
':url'
=>
Url
::
fromRoute
(
'system.prepare_modules_entity_uninstall'
,
[
'entity_type_id'
=>
$entity_type
->
id
()])
->
toString
(),
]);
try
{
if
(
$module
==
$entity_type
->
getProvider
()
&&
$entity_type
instanceof
ContentEntityTypeInterface
&&
$this
->
entityTypeManager
->
getStorage
(
$entity_type
->
id
())
->
hasData
())
{
$reasons
[]
=
$this
->
t
(
'There is content for the entity type: @entity_type. <a href=":url">Remove @entity_type_plural</a>.'
,
[
'@entity_type'
=>
$entity_type
->
getLabel
(),
'@entity_type_plural'
=>
$entity_type
->
getPluralLabel
(),
':url'
=>
Url
::
fromRoute
(
'system.prepare_modules_entity_uninstall'
,
[
'entity_type_id'
=>
$entity_type
->
id
()])
->
toString
(),
]);
}
}
catch
(
\Throwable
$th
)
{
// An exception here means that the table does not exist. That means
// there is no data. This exception is caught to allow to uninstall
// modules with incorrectly installed entity types.
return
$reasons
=
[];
}
}
return
$reasons
;
...
...
This diff is collapsed.
Click to expand it.
core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php
+
11
−
0
View file @
896105cf
...
...
@@ -430,4 +430,15 @@ public function testIdentifierSchema() {
$this
->
assertEquals
(
$expected_revision_id_schema
,
$revision_id_schema
);
}
/**
* Manually drop one of the test entity type tables to simulate a scenario
* where a table was not created or an entity type is new.
*/
public
function
testUninstall
()
{
$this
->
installModule
(
'entity_test'
);
\Drupal
::
database
()
->
schema
()
->
dropTable
(
'entity_test'
);
// Uninstall the entity_test module.
$this
->
container
->
get
(
'module_installer'
)
->
uninstall
([
'entity_test'
]);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment