I'm using config_installer to install. Almost at the end of the installation, I get the following fatal error. I previously applied patch 1356276-302, but I don't think this is related. It started happening after upgrading core to 8.3.0. The install does not finish correctly (the site has no admin user set). Any help or workaround is appreciated.
~/p/n/n/d/bin (master ⚡☡=) ./drush site-install config_installer config_installer_sync_configure_form.sync_directory=/var/www/drupal/config/sync --verbose --db-url=mysql://root:xxx@db/drupal --account-name=admin --account-pass=xxx -y
Executing: mysql --defaults-extra-file=/tmp/drush_IucryR --database=drupal --host=db --silent < /tmp/drush_4Sag50 > /dev/null
You are about to DROP all tables in your 'drupal' database. Do you want to continue? (y/n): y
Sites directory /var/www/drupal/web/sites/default already exists - [notice]
proceeding.
Executing: mysql --defaults-extra-file=/tmp/drush_mYQQIy --database=drupal --host=db --silent < /tmp/drush_nu5C8H > /dev/null
Executing: mysql --defaults-extra-file=/tmp/drush_hGpyVf --database=drupal --host=db --silent < /tmp/drush_vyJbkp
Executing: mysql --defaults-extra-file=/tmp/drush_YotAaX --database=drupal --host=db --silent < /tmp/drush_S0z3x6
Starting Drupal installation. This takes a while. Consider using the [ok]
--notify global option.
Error: Call to a member function getThirdPartySetting() on null in /var/www/drupal/web/core/modules/content_translation/src/ContentTranslationManager.php on line 98 #0 /var/www/drupal/web/core/modules/content_translation/content_translation.module(166): Drupal\content_translation\ContentTranslationManager->isEnabled('media', '')
#1 /var/www/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(501): content_translation_entity_bundle_info_alter(Array, NULL, NULL)
#2 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php(110): Drupal\Core\Extension\ModuleHandler->alter('entity_bundle_i...', Array)
#3 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php(80): Drupal\Core\Entity\EntityTypeBundleInfo->getAllBundleInfo()
#4 /var/www/drupal/web/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php(95): Drupal\Core\Entity\EntityTypeBundleInfo->getBundleInfo('block')
#5 /var/www/drupal/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver->getDerivativeDefinitions(Array)
#6 /var/www/drupal/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array)
#7 /var/www/drupal/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(283): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#8 /var/www/drupal/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(174): Drupal\Core\Plugin\DefaultPluginManager->findDefinitions()
#9 /var/www/drupal/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(22): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
#10 /var/www/drupal/web/core/lib/Drupal/Core/TypedData/DataDefinition.php(193): Drupal\Core\Plugin\DefaultPluginManager->getDefinition('field_item:stri...')
#11 /var/www/drupal/web/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(566): Drupal\Core\TypedData\DataDefinition->getClass()
#12 /var/www/drupal/web/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(555): Drupal\Core\Field\BaseFieldDefinition->getFieldItemClass()
#13 /var/www/drupal/web/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(485): Drupal\Core\Field\BaseFieldDefinition->getMainPropertyName()
#14 /var/www/drupal/web/modules/contrib/media_entity/src/Entity/Media.php(309): Drupal\Core\Field\BaseFieldDefinition->setDefaultValue('')
#15 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(204): Drupal\media_entity\Entity\Media::baseFieldDefinitions(Object(Drupal\Core\Entity\ContentEntityType))
#16 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(171): Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions('media')
#17 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(394): Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions('media')
#18 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityManager.php(154): Drupal\Core\Entity\EntityFieldManager->getFieldStorageDefinitions('media')
#19 /var/www/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(282): Drupal\Core\Entity\EntityManager->getFieldStorageDefinitions('media')
#20 /var/www/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1411): Drupal\Core\Entity\Sql\SqlContentEntityStorage->getTableMapping()
#21 /var/www/drupal/web/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php(74): Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldStorageDefinitionCreate(Object(Drupal\Core\Field\BaseFieldDefinition))
#22 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityManager.php(411): Drupal\Core\Field\FieldStorageDefinitionListener->onFieldStorageDefinitionCreate(Object(Drupal\Core\Field\BaseFieldDefinition))
#23 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php(169): Drupal\Core\Entity\EntityManager->onFieldStorageDefinitionCreate(Object(Drupal\Core\Field\BaseFieldDefinition))
#24 /var/www/drupal/web/core/modules/content_translation/src/ContentTranslationUpdatesManager.php(63): Drupal\Core\Entity\EntityDefinitionUpdateManager->installFieldStorageDefinition('content_transla...', 'media', 'content_transla...', Object(Drupal\Core\Field\BaseFieldDefinition))
#25 /var/www/drupal/web/core/modules/content_translation/src/ContentTranslationUpdatesManager.php(77): Drupal\content_translation\ContentTranslationUpdatesManager->updateDefinitions(Array)
#26 /var/www/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): Drupal\content_translation\ContentTranslationUpdatesManager->onConfigImporterImport(Object(Drupal\Core\Config\ConfigImporterEvent), 'config.importer...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#27 /var/www/drupal/web/core/lib/Drupal/Core/Config/ConfigImporter.php(644): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('config.importer...', Object(Drupal\Core\Config\ConfigImporterEvent))
#28 /var/www/drupal/web/core/lib/Drupal/Core/Config/ConfigImporter.php(488): Drupal\Core\Config\ConfigImporter->finish(Array)
#29 /var/www/drupal/web/profiles/contrib/config_installer/config_installer.profile(139): Drupal\Core\Config\ConfigImporter->doSyncStep('finish', Array)
#30 /var/www/drupal/web/core/includes/batch.inc(252): config_install_batch_process(Object(Drupal\Core\Config\ConfigImporter), 'finish', Array)
#31 /var/www/drupal/web/core/includes/form.inc(874): _batch_process()
#32 /var/www/drupal/web/core/includes/install.core.inc(625): batch_process(Object(Drupal\Core\Url), Object(Drupal\Core\Url))
#33 /var/www/drupal/web/core/includes/install.core.inc(546): install_run_task(Array, Array)
#34 /var/www/drupal/web/core/includes/install.core.inc(117): install_run_tasks(Array)
#35 /var/www/drupal/vendor/drush/drush/includes/drush.inc(726): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#36 /var/www/drupal/vendor/drush/drush/includes/drush.inc(711): drush_call_user_func_array('install_drupal', Array)
#37 /var/www/drupal/vendor/drush/drush/commands/core/drupal/site_install.inc(84): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
#38 /var/www/drupal/vendor/drush/drush/commands/core/site_install.drush.inc(254): drush_core_site_install_version('config_installe...', Array)
#39 /var/www/drupal/vendor/drush/drush/includes/command.inc(422): drush_core_site_install('config_installe...', 'config_installe...')
#40 /var/www/drupal/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#41 /var/www/drupal/vendor/drush/drush/includes/command.inc(199): drush_command('config_installe...', 'config_installe...')
#42 /var/www/drupal/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#43 /var/www/drupal/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#44 /var/www/drupal/vendor/drush/drush/drush.php(12): drush_main()
#45 {main}
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Call to a member function getThirdPartySetting() on null in Drupal\content_translation\ContentTranslationManager->isEnabled() (line 98 of /var/www/drupal/web/core/modules/content_translation/src/ContentTranslationManager.php).
Comments
Comment #2
kjauslin commentedNote, some debugging has shown the following cases where $config will be null in the function isEnabled. I don't know whether this is a configuration problem, but adding a !is_null($config) in the following statement will let me finish the installation.
I added a patch which should work in any case ($config must not be null anyway) and circumvents the problem.
Comment #3
dawehnerLet's also document on
\Drupal\content_translation\ContentTranslationManager::loadContentLanguageSettingsthat the method can actuallyreturn NULL;Comment #4
Jeroen_005 commentedI experienced the same issue and applied this patch. But it's introduced a new error:
exception 'RuntimeException' with message 'Unable to determine class for field type '' found in the 'field.storage.' configuration' in /web/core/modules/field/src/FieldStorageConfigStorage.php:157So I think the provided patch isn't the right approach.
Comment #5
kienan commentedThe patch in #2 worked for me.
Comment #6
idebr commentedComment #8
mpp commented@dawehner, good idea to document this.
The patch in #2 worked for me.
Comment #9
goz commented#2 works for me to in 8.3.x
Comment #10
maxplus commentedThanks,
using Drupal 8.4.2 and drush config-import stopped at the end with this content_translation error.
Patch from #2 solved this error for me, thanks!
Comment #11
pedrop commentedI had the same error message during cim with PHP 7.1 and it turned out that with PHP 7.0 it works without any errors, so in our case this workaround was the solution.
Comment #12
eiriksmPatch works for me!
Updated patch based on #3. Would be nice with a test as well?
Comment #14
martijn de witUsing patch 2868294-12.patch with the latest 8.5.RC1
Error: Call to a member function getThirdPartySetting() on null in Drupal\content_translation\ContentTranslationManager->getBundleTranslationSettings() (line 122 of [PROJECT]/web/core/modules/content_translation/src/ContentTranslationManager.php).Applying the same trick
!is_null($config)to the getBundleTranslationSettings did the trick.Comment #15
martijn de witComment #16
iainp999 commentedHi everyone.
Patch 2 works for us too. Is there any update on this please? Thanks in advance.
Comment #17
martijn de wit@iainp999 Why are you using patch nr2 ? It's an incomplete patch. See comment #3.
Please test te latest patch and/or mention which version of Drupal + Module you are using. Please explain more than I used #X and it works... we need to know the circumstances of your environment. Thank you.
Comment #18
iainp999 commentedWe're on 8.4.6 - there's no alternative on this thread yet?
Comment #19
vijaycs85Looks good and fixes the fatal error.
Probably it could be back ported to 8.5.x, not sure about 8.4.x though.
Comment #20
tstoecklerThe
!is_null()is not necessary. It's fine to just checkif ($config)Comment #21
yogeshmpawarComment #22
yogeshmpawarChanges done as per comment #20 & also added an interdiff.
Comment #23
iainp999 commented@yogesh-pawar thank you. I think you still have a call to is_null() in your patch in 22 though.
thanks.
Comment #24
iainp999 commentedHow about the attached? Thank you.
Comment #25
vijaycs85Thanks @iainp99. Just realised it'd be possible to get NULL all instances of
loadContentLanguageSettingscall. How about this?Comment #26
tstoecklerThanks for the quick turnaround. Didn't test the issue, but re-marking RTBC per #19.
Comment #27
tstoecklerAhem.
Comment #28
manuel garcia commentedHere's a backport to 8.4.x for #25 in case someone needs it :)
Comment #29
iainp999 commentedthanks @manuel-garcia!
Comment #30
alexpottIn order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:
Also we need some understand of how we get to the point where this is null and why and whether the fix is correct.
Comment #31
vijaycs85Setting it to needs review to test.
We might need a functional test for this.
Comment #34
iainp999 commented@vijaycs85 I think you've got a typo in a method name:
public function tstSetBundleTranslationSettings() {Comment #35
vijaycs85Thanks @iainp999. Here is an update.
Comment #36
vijaycs85Sorry, another silly mistake on #35
Comment #41
vijaycs85Fixing another unintended failure.
Comment #43
KittenDestroyer commented2868294-41.patch Updated to 8.5.x core.
Comment #44
KittenDestroyer commentedAttaching for 8.5.3 specific patch.
Comment #45
manuel garcia commentedThanks @KittenDestroyer. I believe this needs to be addressed first on 8.6.x so switching the issue's version back to that :)
For clarity, the patch to continue work on/review is still #41.
Comment #46
douggreen commentedIs a missing config a real issue that this solution just hides?
Comment #48
eiriksmPatch works and looks good. Since I have a patch in this issue, leaving to others to RTBC.
Comment #49
eiriksmReviewing the patch in #41, I noticed that the comments and naming of functions and dataproviders seems to be taken from somewhere else (probably copy-pasted). Small nit though.
Comment #50
borisson_Removing the needs tests tag.
Why are we disabling strict config schema checking here? We probably shouldn't do that if we can help it.
Can be {@inheritdoc}
Comment #51
borisson_This fixes my own remarks.
Comment #52
tikaszvince commentedI think #2599228: Programmatically created translatable content type returns SQL error on content creation is related here. The lates patch there (https://www.drupal.org/files/issues/2018-10-06/2599228-74.patch) is also solving this error.
Comment #53
borisson_Since the other patch has also already been RTBC before, we should probably close this. Not sure though.
Comment #54
manuel garcia commentedComment #55
danepowell commentedI encountered this error on Drupal 8.6. I tried #74 in #2599228: Programmatically created translatable content type returns SQL error on content creation and it didn't help. But #51 in this issue worked great, so it seems like there's a gap between the two approaches. Not sure if that's specific to 8.6 or what.
Comment #56
jgalletta commentedI'm afraid the patch introduces another bug.
I have an install script that
- install a brand new Drupal site
- import the configuration
- run migrations to populate the database
I started to get the "Call to a member function getThirdPartySetting() on null in ContentTranslationManager" at the end of the import configuration step, so I tried the #51 patch. It removed the error message, but now I run into this problem: https://www.drupal.org/project/drupal/issues/2599228.
With the #51 patch, the column content_translation_source in table node_field_data is not created during the install / import config process. If I remove the patch, the column is created like it should be.
Comment #57
taran2lI can confirm that patch from #51 creates an issue with missing
content_translation_sourcecolumn. Patch from #2599228-105: Programmatically created translatable content type returns SQL error on content creation does not fix this issue on it's own.Comment #58
taran2lSeems like the in order to fix the issue both patches are required. One from here and one from #2599228-105: Programmatically created translatable content type returns SQL error on content creation. The problem is that they cannot be applied together. I think those two issues should be combined into a single one.
Comment #59
taran2lHe's a patch that can be applied after #2599228-105: Programmatically created translatable content type returns SQL error on content creation.
So, should those 2 issues be combined? Or just wait until the other one is committed.
Regarding questions in #30 and #46 that we are fixing not the real issue here, as config should not be null. The easiest way to reproduce this is to create a block content block and export it to configuration. As you might know custom blocks are not exported "correctly", see #2756331: Custom blocks cannot be properly exported and imported. Then try to install site using config_installer. Boom.
Comment #60
martijn de witAdded test manually because off issue status :)
Comment #61
osmanCombined #2599228-105: Programmatically created translatable content type returns SQL error on content creation with #2868294-59: Call to a member function getThirdPartySetting() on null in ContentTranslationManager against 8.6.x
Comment #63
alexpott[##2599228] has been committed so we can now concentrate on this issue without having to combine patches.
Comment #64
mpp commentedI couldn't get the patch in #59 tested so here's a reroll of #59 against 8.8.
Comment #65
berdirWould be great to have an updated issue summary update, when this happens exactly and what we are doing to fix it.
Comment #67
neelaj82 commentedAll upgraded to the 8.7.0 core just now and this patch failed
https://www.drupal.org/files/issues/2018-09-26/2868294-51.patchWhat are you all using for 8.7.0?Comment #68
zyla commentedHello @neelaj82,
I have this same issue. Did you find how to fix it ? Thank you !
Comment #69
martijn de witpatch 2868294_64.patch from nr 64 should work ?
Comment #70
zyla commentedThanks ! For the current version of 8.7.x, I tested the patch #64 and it works. The fail triggered during test seems to be related to the new file ContentTranslationManagerTest.php and it doesn't impact the issue itself.
Comment #75
tessa bakkerHad kind of the same issue after reusing a database where the
system.menu.develconfig wasn't correctly imported, but I missed that part so I went on with the idea that everything was fine. But when I uninstalled the modulewebprofiler, the message was the same as in the description of this issue.After some debugging, I could trace the issue back to
system.menu.develin the config table. The stored configuration was missing an ID and some other data, only the dependencies array was available.The problem in my case was, when https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/lib/Drupal/C... (\Drupal\Core\Config\Entity\ConfigEntityStorage::doLoadMultiple) is searching for the 'id' (
$id = $config->get($this->idKey);) in the config record, it is missing. Because of the missing ID in the stored config, the key for processing configuration entity bundles array will be empty, and result in a empty key with a config entity object that isn't usable.The patch just hides the invalid config in the database, I think it would be better to be aware of the problem and/or exclude the invalid config earlier on in the code at
ConfigEntityStorage::doLoadMultiple().After I removed the config entry and run config import with Drush, the issue was gone. I tried to recreate the situation, but wasn't able to.
Site setup: Drupal 8.9.19 with Configuration Split (1.7) for Devel & Webprofiler
Comment #78
Harsh panchal commentedRerolled patch against drupal-9.5.x-dev
Comment #79
pooja saraah commentedFixed failed commands on #78
Attached interdiff
Comment #81
rassoni commentedComment #82
rassoni commentedComment #84
ravi.shankar commentedFixed failed tests of patch #81.
Comment #87
shubham chandra commentedAdded patch against #84 in Drupal 10.1.x
Comment #88
jamesyao commentedThanks @shubham-chandra for the patch #87.
It works well on Drupal Core 9.4.8 with PHP8.0 & Mysql 5.7.
Comment #89
bnjmnmPatch #87 doesn't fix anything, it instead removes the tests that are failing, but those tests are there for a reason. The correct approach would be to get those tests passing, not removing them. Work should continue from an earlier patch that includes
ContentManagerTranslationTestComment #94
kriboogh commentedPatch of !MR8986 (works on 11.0 and 10.3, 10.2)
Comment #95
kriboogh commentedTests are working now, but someone should have a look at what those test values should do...
Comment #96
kriboogh commentedpatch for MR
Comment #97
kriboogh commentedI was looking a bit more into the test that is failing (data index 3). The test data uses a non existing bundle id. What happens then is loadContentLanguageSettings initially cannot find the config and then creates a new one for the non existing bundle.
So either a couple of things should happen:
- the test data is incorrect and tries to test a situation that can never happen, being a non existing bundle id and the hasexception flag set to false or
- loadContentLanguageSettings should not create a config for a non existing bundle, and should return null. So loadContentLanguageSettings should check if the entity_id and bundle actually exist?