14

I have two Drupal environments with the same system.site:uuid

In the main Drupal I export the configuration with command:

drush config-export deploy -y

In the destination drupal I import the configuration with command:

drush config-import deploy -y

But I have this error

Entities exist of type Shortcut link and Default. These entities need to be deleted before importing.

And:

Unable to install the mytest theme since it does not exist.

My test was a test for create subtheme, but then I delete mytest form drupal. And I don't know what it exports now, and, placeholder I don't Know what is it

I followed this article And I have the same issue of this comment

6 Answers 6

6

Sounds like you deleted your test theme without uninstalling it. You either have to properly uninstall it, which might not be possible when it's not there or edit the core.extension.yml file in your exported config and remove it by hand.

About the other error, it looks like you are either really deleting shortcut/menu link types or, more likely, you manually "fixed" the system.site UUID. That check and UUID exists for a reason, just changing it to the same value on two different installations will do a lot of unexpected things. You would have to update lots of other UUID's too, otherwise Drupal will delete and re-create pretty much every single configuration entity in your system. Due to the changed UUID, it assumes you deleted and re-created it, so that's what it is trying to do.

And since it prevents you from deleting bundle config entity types when there is still content for that type/bundle, it gives you that error.

What is it that you are trying to do exactly? Maybe you're looking for Config Installer instead?

1
  • thanks for your reply. I have SiteA with fresh installation. Export my configuration with drush config-export deploy -y get my uuid with drush cget system.site uuid. In my SiteB I have the clone of siteA Change uuid with drush cedit shortcut.set.default and set the same of siteA. When I do drush config-export deploy -y I have an errore of placeholder. I follow this tutorial (dcycleproject.org/blog/68/…) and change uuid by module, but I have the same result
    – monkeyUser
    Dec 20, 2015 at 14:32
11

For:

Entities exist of type Shortcut link and Default. These entities need to be deleted before importing.

You need delete the entities of type short-cut, you can do with drush:

drush ev '\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();'
5
  • When I try this, I get this error: bash: -c: line 0: syntax error near unexpected token ('` I'm not sure if it's because I am running drush from within ddev - my full command is: ddev drush ev '\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete(); Jan 23, 2020 at 23:24
  • The above issue can be addressed by running drush on the host, instead: github.com/drud/ddev/issues/1648#issuecomment-502757303 Because now, for a composer-based Drupal 8+ project, drush can be installed for the project using composer require drush/drush and you can create a short cut by doing this: cd web (your docroot), then ` ln -s ../vendor/drush/drush/drush .` This assumes that your source tree is 2 levels, with the site docroot in web and composer.json, .git folder etc above that by one level. Jan 24, 2020 at 16:44
  • With drush setup locally as above, then the command can be issued thus: ./drush ev '\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();' Note the ./ preceding the command. Jan 24, 2020 at 16:47
  • The above solution would not actually work for me whereby I'm running drush on the host, because the database not accessible from the host as it's associated with a docker container with ddev. So you have to actually use ddev. The way to solve the ddev issue with the bash is to escape all of the characters that could cause the issue: ddev drush ev \'\\Drupal\:\:entityManager\(\)\-\>getStorage\(\"shortcut_set\"\)\-\>load\(\"default\"\)\-\>delete\(\)\;\'- I found this actually works! I'm prefixing any special character with a backslash to "escape" it. May 31, 2020 at 22:24
  • 1
    "entityManager" has been replaced by "entityTypeManager" in Drupal 9+ drush ev '\Drupal::entityTypeManager()->getStorage("shortcut_set")->load("default")->delete();' api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/…
    – knice
    Jan 31 at 21:49
8

About the first error (Entities exist of type Shortcut link and Default. These entities need to be deleted before importing.):

I went to Home > Administration > Configuration > User interface > Shortcuts (admin/config/user-interface/shortcut), than in "List links" of "Default" I deleted every shortcut.

The error is gone now.

6

Whenever you get this type of error, you need to delete the entities first.

Here's a generic Drush command that will delete any entity type, unlike another answer here. Just set the machine name in the first PHP command.

drush @site eval '$entity_type = "my_entity_type"; $storage_handler = \Drupal::entityTypeManager()->getStorage($entity_type); $storage_handler->delete($storage_handler->loadMultiple(\Drupal::entityQuery($entity_type)->execute()));'

1
  • This should be a drush command, it would come in handy
    – wranvaud
    Feb 15, 2022 at 13:48
1

An easy way using drush nowadays: drush edel [entity_type] --bundle=[bundle_name]

drush edel shortcut_set --bundle=default
1

Using the answers above as a base the following worked for me:

To delete entities of a specific bundle, replace the first 2 values accordingly on the script and save it on a file.

$entity_type = "paragraph";
$type = "contact";

$storage_handler = \Drupal::entityTypeManager()->getStorage($entity_type);
$entities_to_delete = \Drupal::entityQuery($entity_type)
  ->condition('type', $type)->execute();
$storage_handler->delete($storage_handler->loadMultiple($entities_to_delete));

Then run drush php:script to-delete-entities.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.