X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FDrupal%2FCommands%2Fcore%2FEntityCommands.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FDrupal%2FCommands%2Fcore%2FEntityCommands.php;h=c425ad7a7f71480e20c5cefe5faba515a6726943;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=dd85863b3efb6b868af11a65f7a0f46ae5962494;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/vendor/drush/drush/src/Drupal/Commands/core/EntityCommands.php b/vendor/drush/drush/src/Drupal/Commands/core/EntityCommands.php index dd85863b3..c425ad7a7 100644 --- a/vendor/drush/drush/src/Drupal/Commands/core/EntityCommands.php +++ b/vendor/drush/drush/src/Drupal/Commands/core/EntityCommands.php @@ -35,6 +35,8 @@ class EntityCommands extends DrushCommands * Delete all shortcut entities. * @usage drush entity:delete node 22,24 * Delete nodes 22 and 24. + * @usage drush entity:delete user + * Delete all users except uid=1. * * @command entity:delete * @aliases edel,entity-delete @@ -51,10 +53,18 @@ class EntityCommands extends DrushCommands } else { $entities = $storage->loadMultiple(); } + + // Don't delete uid=1, uid=0. + if ($entity_type == 'user') { + unset($entities[1]); + unset($entities[0]); + } + if (empty($entities)) { - throw new \Exception(dt('No matching entities found.')); + $this->logger()->success(dt('No matching entities found.')); + } else { + $storage->delete($entities); + $this->logger()->success(dt('Deleted !type entity Ids: !ids', ['!type' => $entity_type, '!ids' => implode(', ', array_keys($entities))])); } - $storage->delete($entities); - $this->logger()->success(dt('Deleted !type entity Ids: !ids', ['!type' => $entity_type, '!ids' => implode(', ', array_keys($entities))])); } }