Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294323

\Drupal\Core\Extension\ModuleInstaller::uninstall() breaks if module was installed with inconsistent state

$
0
0

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():

<?php
  $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.


Viewing all articles
Browse latest Browse all 294323

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>