Skip to content

Commit

Permalink
Fix #5730. php:cli should avoid duplicate class name. (#5733)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman authored Aug 19, 2023
1 parent 5aee7ef commit 0292cd2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Commands/core/CliCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,12 @@ public function makeEntitiesAvailableWithShortClassNames(): void
foreach ($this->entityTypeManager->getDefinitions() as $definition) {
$class = $definition->getClass();
$reflectionClass = new \ReflectionClass($class);
if ($reflectionClass->isFinal()) {
$parts = explode('\\', $class);
$end = end($parts);
// https://github.com/drush-ops/drush/pull/5729 and https://github.com/drush-ops/drush/issues/5730.
if ($reflectionClass->isFinal() || class_exists($end)) {
continue;
}
$parts = explode('\\', $class);
// Make it possible to easily load revisions.
eval(sprintf('class %s extends \%s {
public static function loadRevision($id) {
Expand All @@ -321,7 +323,7 @@ public static function loadRevision($id) {
$storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(static::class));
return $storage->loadRevision($id);
}
}', end($parts), $class));
}', $end, $class));
}
}
}

0 comments on commit 0292cd2

Please sign in to comment.