Call to a member function setSyncing() on null when installing a module

Created on 29 April 2019, over 5 years ago
Updated 9 February 2023, almost 2 years ago

Not sure of the precise cause but installing a site with pre-existing config (in this case using "blt setup"in a DrupalVM) can result in invalid IDs which then generate fatal errors.

Error: Call to a member function setSyncing() on null in /var/www/DigitalPlatformCore/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php on line 389 #0 /var/www/DigitalPlatformCore/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(979): Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete('views.view.tmgm...', Object(Drupal\Core\Config\Config), Object(Drupal\Core\Config\Config))
#1 /var/www/DigitalPlatformCore/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(765): Drupal\Core\Config\ConfigImporter->importInvokeOwner('', 'delete', 'views.view.tmgm...')
#2 /var/www/DigitalPlatformCore/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(592): Drupal\Core\Config\ConfigImporter->processConfiguration('', 'delete', 'views.view.tmgm...')
#3 /var/www/DigitalPlatformCore/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(496): Drupal\Core\Config\ConfigImporter->processConfigurations(Array)
#4 /var/www/DigitalPlatformCore/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(239): Drupal\Core\Config\ConfigImporter->doSyncStep('processConfigur...', Array)
#5 /var/www/DigitalPlatformCore/vendor/drush/drush/includes/drush.inc(223): Drush\Drupal\Commands\config\ConfigImportCommands->doImport(Object(Drupal\Core\Config\StorageComparer))
#6 /var/www/DigitalPlatformCore/vendor/drush/drush/includes/drush.inc(214): drush_call_user_func_array(Array, Array)
#7 /var/www/DigitalPlatformCore/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(211): drush_op(Array, Object(Drupal\Core\Config\StorageComparer))
#8 [internal function]: Drush\Drupal\Commands\config\ConfigImportCommands->import('sync', Array)
#9 /var/www/DigitalPlatformCore/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#10 /var/www/DigitalPlatformCore/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#11 /var/www/DigitalPlatformCore/vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#12 /var/www/DigitalPlatformCore/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#13 /var/www/DigitalPlatformCore/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/DigitalPlatformCore/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/DigitalPlatformCore/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/DigitalPlatformCore/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/DigitalPlatformCore/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/DigitalPlatformCore/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/DigitalPlatformCore/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#20 /var/www/DigitalPlatformCore/vendor/drush/drush/drush(4): require('/var/www/Digita...')
#21 {main}
Error: Call to a member function setSyncing() on null in Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete() (line 389 of /var/www/DigitalPlatformCore/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php).

There have been other similar reports but the main associated one is given. This is the relevant method:

  public function importDelete($name, Config $new_config, Config $old_config) {
    $id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
    $entity = $this->load($id);
    $entity->setSyncing(TRUE);
    $entity->delete();
    return TRUE;
  }

In this particular instance, we're trying to delete on non-existent entity but fail if it doesn't already exist. The other methods (importCreate() and importUpdate()) check for a valid entity, this one doesn't. It should.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated about 9 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom adaddinsane

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Can you please provide steps to reproduce this.

    This will need a test case to show the issue

    Thanks!

  • πŸ‡ΊπŸ‡ΈUnited States loopy1492

    I just had to do this on another site.

    I'm not totally sure, but it's possible we're getting this during blt ci due to adding shortcut.set.default to config ignore.

    [error]  Error: Call to a member function setSyncing() on null in Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete() (line 379 of /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php) #0 /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(1030): Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete()
    #1 /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(816): Drupal\Core\Config\ConfigImporter->importInvokeOwner()
    #2 /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(637): Drupal\Core\Config\ConfigImporter->processConfiguration()
    #3 /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(541): Drupal\Core\Config\ConfigImporter->processConfigurations()
    #4 /mnt/tmp/local.prod/source/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(300): Drupal\Core\Config\ConfigImporter->doSyncStep()
    #5 [internal function]: Drush\Drupal\Commands\config\ConfigImportCommands->doImport()
    #6 /mnt/tmp/local.prod/source/vendor/drush/drush/includes/drush.inc(122): call_user_func_array()
    #7 /mnt/tmp/local.prod/source/vendor/drush/drush/includes/drush.inc(113): drush_call_user_func_array()
    #8 /mnt/tmp/local.prod/source/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(271): drush_op()
    #9 [internal function]: Drush\Drupal\Commands\config\ConfigImportCommands->import()
    #10 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
    #11 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
    #12 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
    #13 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process()
    #14 /mnt/tmp/local.prod/source/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
    #15 /mnt/tmp/local.prod/source/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
    #16 /mnt/tmp/local.prod/source/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
    #17 /mnt/tmp/local.prod/source/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
    #18 /mnt/tmp/local.prod/source/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run()
    #19 /mnt/tmp/local.prod/source/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun()
    #20 /mnt/tmp/local.prod/source/vendor/drush/drush/drush.php(77): Drush\Runtime\Runtime->run()
    #21 /mnt/tmp/local.prod/source/vendor/drush/drush/drush(4): require('...')
    #22 /mnt/tmp/local.prod/source/vendor/bin/drush(120): include('...')
    #23 {main}. 
    
    Error: Call to a member function setSyncing() on null in Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete() (line 379 of /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php).
  • πŸ‡§πŸ‡ͺBelgium aimevp Belgium

    The patch from #10 would no longer apply for my D10.1.7 installation where I was using it. This is the updated version which applies again on the latest 10.1.x.

  • πŸ‡ͺπŸ‡ΈSpain rteijeiro

    Tested the #20 patch on:

    - Drupal 10.2.4
    - OpenID Connect / OAuth client 3.0.0-alpha3
    - OpenID Connect Microsoft Azure Active Directory client 2.0.0-beta7

    And I get the following error when I go to admin/config/people/openid-connect

    TypeError: Drupal\openid_connect\Plugin\OpenIDConnectClientCollection::__construct(): Argument #2 ($instance_id) must be of type string, null given, called in /var/www/web/modules/contrib/openid_connect/src/Entity/OpenIDConnectClientEntity.php on line 142 in Drupal\openid_connect\Plugin\OpenIDConnectClientCollection->__construct() (line 33 of /var/www/web/modules/contrib/openid_connect/src/Plugin/OpenIDConnectClientCollection.php).

  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    OK, so here is a minimal reproducible recipe (also updating the IS):

    - Install drupal using minimal profile
    - Enable views module
    - Create a new module called mymodule.
    - Create an install file in this module containing this

    /**
     * Implements hook_install().
     */
    function mymodule_install() {
      \Drupal::configFactory()->getEditable('views.view.content')
        // Make extra double sure this is actually going to update the title, with
        // adding a time factor here.
        ->set('display.default.display_options.title', 'overridden title here' . time())
        ->save();
    }
    

    - Enable the mymodule module
    - Export the config
    - Reinstall the site using existing config (for example with drush si minimal --existing-config -y)

  • Merge request !8354Avoid recreating config with no uuid β†’ (Open) created by eiriksm
  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Opened a MR with another approach, also working for me.

    I have a feeling that we are sort of working against an anti pattern for example in contrib here, so not totally sure this is needed. However, it's probably going to continue happening, so it's nice to guard against it at least.

  • Pipeline finished with Success
    5 months ago
    Total: 548s
    #195416
  • First commit to issue fork.
  • πŸ‡§πŸ‡ͺBelgium kriboogh

    Since both patches (#20 and #24) deal with fixing this issue at different stages in the import sync by adding better code checks, I combined both into the MR. Also added the patch for the MR as it stands now to use in composer.

  • Status changed to Needs review 3 months ago
  • Status changed to Needs work 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Can the proposed solution be verified please

    Moving to NW for that and the tests

    Steps appear to be added so removing that tag

    Thanks.

  • πŸ‡¨πŸ‡¦Canada ydahi Waterloo, Canada

    Patch in #20 applied to 10.2.6 and helped me get out of this mess.

Production build 0.71.5 2024