Steps to reproduce:
1. Ensure the module is uninstalled.
2. Install the module such that it gets into an inconsistent state. HOW exactly you accomplish this part isn't super-important: basically you just have to get a module to be registered as installed but fail to install the actual entity's tables. Assumes they are stored in MySQL*.
This is what I did:
In a content entity's baseFieldDefinitions()
, create a BaseFieldDefinition
that passes an invalid substitution to t()
. In my case, I didn't call $overview_url->toString()
:
$overview_url = Url::fromRoute('fillpdf.forms_admin'); // notice lack of ->toString()
$fields['admin_title'] = BaseFieldDefinition::create('string')
->setLabel(t('Administrative description'))
->setDescription(t('Enter the name of the form here as it should be shown on the <a href="@overview_url">form overview page</a>.', array('@overview_url' => $overview_url));
You will get an error about method Drupal\Core\Url::__toString() needing to not throwing an exception.
3. Fix the bug in step 2 (add ->toString()) and then try to uninstall the module.
Expected: Module uninstalls.
Actual: Error about base table(s) corresponding to content entities defined in the module not existing.
Workaround: Manually create stub tables named the same as the entity tables with at least their ID fields. Then the module can be uninstalled.
Comments
Comment #1
dawehnerIn other words, its better to not do anything fancy inside
baseFieldDefinitions()
Comment #2
wizonesolutions@dawehner: That's well and fair, but it needs to be documented. Perhaps this is a documentation issue. When using entity forms, this is a realistic use case. Of course, it's possible to modify the form element description in the
MyEntityForm::form()
, but it's not always obvious what to do where.Comment #3
dawehnerOne thing which has to be mentioned now is, that since #2416971: Remove Url::__toString(), its no longer possible to throw such an error in the middle of nowhere.
Btw. In general it would be great to update the issue summary with the exact error message, as otherwise you have a hard time to find the place, which is the problem.
Comment #4
TR CreditAttribution: TR commentedCan you test the patch in #2474363: Stuck in failed module install process? I think that fixes this issue.
Comment #15
DanielVezaThis is now 7 years old and looks to have been fixed by the referenced issue. Let's close.