diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt index b69f75593e317dd68700fa0ab17a133934013036..852d5aa339003101e13d901e97752104e3e65f91 100644 --- a/.cspell-project-words.txt +++ b/.cspell-project-words.txt @@ -7,3 +7,4 @@ colinodell testlogger kanopi tabwise +sophron diff --git a/css/pb.css b/css/pb.css index 20adee504d98e8b2fe2c56eaa8f9d6948086d436..cbad4fd6646a0381d62e2dbcf2b33167f64ee656 100644 --- a/css/pb.css +++ b/css/pb.css @@ -630,7 +630,7 @@ .search__search_term::-webkit-search-decoration, .search__search_term::-webkit-search-results-button, .search__search_term::-webkit-search-results-decoration { - display: none; + display: none; } .search__search-bar { diff --git a/src/Controller/InstallerController.php b/src/Controller/InstallerController.php index 9d5c384354890662e1f562c65e51f5c3923b1ed9..7020569eded734164addc0fabc885f61108d4dc6 100644 --- a/src/Controller/InstallerController.php +++ b/src/Controller/InstallerController.php @@ -395,7 +395,7 @@ class InstallerController extends ControllerBase { try { $stage_id = $this->installer->create(); - $this->setRequiringState($project->uuid, 'creating install stage', $stage_id); + $this->setRequiringState($project->id, 'creating install stage', $stage_id); } catch (\Exception $e) { $this->cancelRequire(); diff --git a/src/EnabledSourceHandler.php b/src/EnabledSourceHandler.php index 7f4e22d20a98bee49a1ecaef12c1097daf0bfed2..79779f855449e11ff9bf4d0c24e9380779fbb445 100644 --- a/src/EnabledSourceHandler.php +++ b/src/EnabledSourceHandler.php @@ -3,7 +3,6 @@ namespace Drupal\project_browser; use Drupal\Component\Serialization\Json; -use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigFactoryInterface; @@ -35,7 +34,6 @@ class EnabledSourceHandler implements LoggerAwareInterface, EventSubscriberInter private readonly ConfigFactoryInterface $configFactory, private readonly ProjectBrowserSourceManager $pluginManager, private readonly ActivatorInterface $activator, - private readonly UuidInterface $uuid, KeyValueExpirableFactoryInterface $keyValueFactory, ) { $this->keyValue = $keyValueFactory->get('project_browser'); @@ -117,10 +115,11 @@ class EnabledSourceHandler implements LoggerAwareInterface, EventSubscriberInter $stored = []; foreach ($projects as $source_id => $results) { foreach ($results->list as $project) { - // Each project is identified by a UUID which persists until the data - // store is wiped. - $project->uuid = $this->uuid->generate(); - $this->keyValue->set($project->uuid, $project); + // Generate an ID for the project from the package name and machine + // name, which are unlikely to change. This isn't security-sensitive, + // so SHA1 is okay for this purpose. + $project->id = sha1($source_id . $project->packageName . $project->machineName); + $this->keyValue->setIfNotExists($project->id, $project); // Add activation data to the project. $this->getActivationData($project); } @@ -128,7 +127,7 @@ class EnabledSourceHandler implements LoggerAwareInterface, EventSubscriberInter // ProjectsResultsPage. $stored[$source_id] = [ $results->totalResults, - array_column($results->list, 'uuid'), + array_column($results->list, 'id'), $results->pluginLabel, ]; } diff --git a/src/ProjectBrowser/Project.php b/src/ProjectBrowser/Project.php index d0c95a3c253b01952f4b6f720c3517e8598e294b..fc8370593af593a262d1f99eb710312f4d4634d0 100644 --- a/src/ProjectBrowser/Project.php +++ b/src/ProjectBrowser/Project.php @@ -15,13 +15,13 @@ use Drupal\project_browser\ProjectType; class Project implements \JsonSerializable { /** - * A persistent UUID for this project in non-volatile storage. + * A persistent ID for this project in non-volatile storage. * * @var string * * @see \Drupal\project_browser\EnabledSourceHandler::getProjects() */ - public string $uuid; + public string $id; /** * The status of this project in the current site. @@ -186,7 +186,7 @@ class Project implements \JsonSerializable { 'created' => $this->created, 'selector_id' => $this->getSelectorId(), 'commands' => $commands, - 'id' => $this->uuid, + 'id' => $this->id, ]; } diff --git a/tests/src/Functional/InstallerControllerTest.php b/tests/src/Functional/InstallerControllerTest.php index a5f4ef5250ae22f1af788ca94f97790370937ae6..e3276054acb154c73f7b8db53d238e0a0569fa05 100644 --- a/tests/src/Functional/InstallerControllerTest.php +++ b/tests/src/Functional/InstallerControllerTest.php @@ -625,7 +625,7 @@ class InstallerControllerTest extends BrowserTestBase { foreach ($projects as $results_page) { foreach ($results_page->list as $project) { if ($project->machineName === $module_name) { - return $project->uuid; + return $project->id; } } } diff --git a/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php b/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php index e7aaf954aa48c1616888dba5e54aa92cb59562f4..e0bc77d70d6b83b2d894a6debf1ee2906ec043c1 100644 --- a/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php +++ b/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php @@ -274,7 +274,7 @@ class ProjectBrowserInstallerUiTest extends WebDriverTestBase { if (method_exists($source, 'isProjectSafe') && !$source->isProjectSafe($project)) { continue; } - return $project->uuid; + return $project->id; } } $this->fail("Could not find a project to install from amongst the enabled sources."); diff --git a/tests/src/Kernel/EnabledSourceHandlerTest.php b/tests/src/Kernel/EnabledSourceHandlerTest.php index 64ba6a163053f2c52dfcadb54b257f1ed70f55aa..fa0452aff60db9e70c3ee6e0b63641eb990f0562 100644 --- a/tests/src/Kernel/EnabledSourceHandlerTest.php +++ b/tests/src/Kernel/EnabledSourceHandlerTest.php @@ -61,7 +61,7 @@ class EnabledSourceHandlerTest extends KernelTestBase { $this->assertNotEmpty($list); $project = reset($list); - $project_again = $handler->getStoredProject($project->uuid); + $project_again = $handler->getStoredProject($project->id); $this->assertNotSame($project, $project_again); $this->assertSame($project->jsonSerialize(), $project_again->jsonSerialize()); @@ -86,7 +86,7 @@ class EnabledSourceHandlerTest extends KernelTestBase { // `commands` properties should be uninitialized. $project = $this->container->get('keyvalue.expirable') ->get('project_browser') - ->get($project->uuid); + ->get($project->id); $this->assertInstanceOf(Project::class, $project); $this->assertFalse(self::hasActivationData($project)); }