Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I see the next error when Drupal is installed from configs:
[PDOException (42S02)]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.path_alias' doesn't exist
From the exception trace I see that it was called from smtp_install():
Exception trace:
at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Database/Connection.php:701
Drupal\Core\Database\Connection->handleQueryException() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Database/Connection.php:665
Drupal\Core\Database\Connection->query() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:357
Drupal\Core\Database\Driver\mysql\Connection->query() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Database/Query/Select.php:510
Drupal\Core\Database\Query\Select->execute() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Path/AliasRepository.php:98
Drupal\Core\Path\AliasRepository->lookupByAlias() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Path/AliasManager.php:212
Drupal\Core\Path\AliasManager->getPathByAlias() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php:77
Drupal\Core\PathProcessor\PathProcessorFront->processOutbound() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php:108
Drupal\Core\PathProcessor\PathProcessorManager->processOutbound() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php:389
Drupal\Core\Routing\UrlGenerator->processPath() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php:298
Drupal\Core\Routing\UrlGenerator->generateFromRoute() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php:105
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Url.php:762
Drupal\Core\Url->toString() at /home/travis/build/test/test/docroot/modules/contrib/smtp/smtp.install:66
smtp_install() at n/a:n/a
call_user_func_array() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:392
Drupal\Core\Extension\ModuleHandler->invoke() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php:325
Drupal\Core\Extension\ModuleInstaller->install() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php:813
Drupal\Core\Config\ConfigImporter->processExtension() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php:577
Drupal\Core\Config\ConfigImporter->processExtensions() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php:514
Drupal\Core\Config\ConfigImporter->doSyncStep() at /home/travis/build/test/test/docroot/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php:31
Drupal\Core\Config\Importer\ConfigImporterBatch::process() at /home/travis/build/test/test/docroot/core/includes/batch.inc:295
_batch_process() at /home/travis/build/test/test/docroot/core/includes/form.inc:947
batch_process() at /home/travis/build/test/test/docroot/core/includes/install.core.inc:658
install_run_task() at /home/travis/build/test/test/docroot/core/includes/install.core.inc:576
install_run_tasks() at /home/travis/build/test/test/docroot/core/includes/install.core.inc:118
install_drupal() at /home/travis/build/test/test/vendor/drush/drush/includes/drush.inc:229
drush_call_user_func_array() at /home/travis/build/test/test/vendor/drush/drush/includes/drush.inc:214
drush_op() at /home/travis/build/test/test/vendor/drush/drush/src/Commands/core/SiteInstallCommands.php:145
Drush\Commands\core\SiteInstallCommands->install() at n/a:n/a
call_user_func_array() at /home/travis/build/test/test/vendor/consolidation/annotated-command/src/CommandProcessor.php:257
Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() at /home/travis/build/test/test/vendor/consolidation/annotated-command/src/CommandProcessor.php:212
Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() at /home/travis/build/test/test/vendor/consolidation/annotated-command/src/CommandProcessor.php:176
Consolidation\AnnotatedCommand\CommandProcessor->process() at /home/travis/build/test/test/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:302
Consolidation\AnnotatedCommand\AnnotatedCommand->execute() at /home/travis/build/test/test/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /home/travis/build/test/test/vendor/symfony/console/Application.php:1005
Symfony\Component\Console\Application->doRunCommand() at /home/travis/build/test/test/vendor/symfony/console/Application.php:255
Symfony\Component\Console\Application->doRun() at /home/travis/build/test/test/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /home/travis/build/test/test/vendor/drush/drush/src/Runtime/Runtime.php:118
Drush\Runtime\Runtime->doRun() at /home/travis/build/test/test/vendor/drush/drush/src/Runtime/Runtime.php:49
Drush\Runtime\Runtime->run() at /home/travis/build/test/test/vendor/drush/drush/drush.php:72
require() at /home/travis/build/test/test/vendor/drush/drush/drush:4
Steps to reproduce
smtp and path_alias module should be added into core.extension config.
Then try to install drupal from configs and observe the error.
Proposed resolution
Do not run smtp_install code during a config sync.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#6 | 3216362-6-hook-modules-installed.patch | 2.26 KB | TR |
|
Issue fork smtp-3216362
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
id.aleks CreditAttribution: id.aleks at Smile commentedI have opened MR. Please review.
Also here is a link to the patch if anyone needs it https://git.drupalcode.org/project/smtp/-/merge_requests/7.patch
Comment #4
TR CreditAttribution: TR commentedI personally do not like putting in random conditionals as a solution. That just leads to spaghetti code. If the code causes problems it's probably wrong, and not just wrong for this narrow use case.
It seems to me that the root of the problem comes from #3092942: Route "smtp.config" not available in hook_install(), which put the router rebuild call into hook_install(). The documentation for hook_install() says that the preferable way to solve the problem should have been to put the addMessage() calls into hook_modules_installed() instead - a router rebuild during install shouldn't be necessary and doesn't have to be done if the addMessage() calls are in hook_modules_installed(). SMTP even already has a hook_modules_installed() implementation, so it's no big deal to move a few lines of code into that. I think if it is done that way there shouldn't be an issue here, and after that is done hook_install() can be removed since it won't be doing anything anymore.
This raises an additional problem - the documentation for hook_modules_installed() says it should be located in a .module file. But presently it is in the .install file. I don't think it's actually being run ...
Comment #5
TR CreditAttribution: TR commented@id.aleks: Can you test this patch and see if it resolves your issue?
Comment #6
TR CreditAttribution: TR commentedSame patch, but with coding standards fixed. This is the one to use.
Comment #7
id.aleks CreditAttribution: id.aleks at Smile commentedHello @TR. Thanks for your detailed explanation. It sounds reasonable to me. But I'm facing the same error when trying to install Drupal form configs with your patch.
FYI: I'm able to test only on Drupal 8.9 by running
blt drupal:install
command.Comment #8
TR CreditAttribution: TR commentedHmm, that did move the error into hook_modules_installed(), but from what I read that should have worked.
It's not clear to me how the path_alias module gets involved here. SMTP does not use path aliases and does not depend on path_alias. That module didn't exist in Drupal 8.7, and is "special" in Drupal 8.8 and 8.9 - enabled by default but hidden for backwards compatibility. In D9 it is optional. I'm wondering if what you're seeing is just an artifact of that change.
Comment #10
japerryhmm so that error is being caused because we call URL->tostring in our install (to get the path for config). However, the stack seems to indicate that the path alias module is installed, even though the base table for it is missing.
Committing the change TR suggested, since it does clean up the installer regardless of this specific issue.