From 67850c97ebaa261d3911cc1e5d2fb15061723583 Mon Sep 17 00:00:00 2001 From: Neil Drumm <drumm@delocalizedham.com> Date: Mon, 7 Oct 2024 21:01:30 +0000 Subject: [PATCH] Issue #3460888: Remove last use of project_composer_providers table --- project_composer.install | 45 ++++++++++++++++++++++++---------------- project_composer.sa.inc | 2 +- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/project_composer.install b/project_composer.install index 52970ef..309dca0 100644 --- a/project_composer.install +++ b/project_composer.install @@ -145,42 +145,42 @@ function project_composer_schema() { 'primary key' => array('provider_count_id'), ); - $schema['project_composer_namespace_map'] = array( + $schema['project_composer_namespace_map'] = [ 'description' => 'Drupal package json metadata file information', - 'fields' => array( - 'map_id' => array( + 'fields' => [ + 'map_id' => [ 'description' => 'Unique ID for a mapping.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - ), - 'project_nid' => array( + ], + 'project_nid' => [ 'description' => 'The {node}.nid of the project node that includes this provider.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, - ), - 'project_name' => array( + ], + 'project_name' => [ 'description' => 'The machine readable name of a project', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'component_name' => array( + ], + 'component_name' => [ 'description' => 'The component name (module or theme)', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'package_namespace' => array( + ], + 'package_namespace' => [ 'description' => 'The namespace used in the json metadata', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), + ], 'category' => [ 'description' => 'The field_release_category, either “current” or “legacy”', 'type' => 'varchar', @@ -188,13 +188,15 @@ function project_composer_schema() { 'not null' => TRUE, 'default' => '', ], - ), - 'primary key' => array('map_id'), - 'indexes' => array( - 'project_nid' => array('project_nid'), + ], + 'primary key' => ['map_id'], + 'indexes' => [ + 'project_nid' => ['project_nid'], 'project_component_category' => ['project_name', 'component_name', 'category'], - ), - ); + 'category_namespace' => ['category', 'package_namespace'], + ], + ]; + $schema['project_composer_component'] = array( 'description' => 'The component(s) contained by a project release.', 'fields' => array( @@ -1022,3 +1024,10 @@ function project_composer_update_7022() { 'default' => 0, ]); } + +/** + * Add project_composer_namespace_map.category_namespace index. + */ +function project_composer_update_7023() { + db_add_index('project_composer_namespace_map', 'category_namespace', ['category', 'package_namespace']); +} diff --git a/project_composer.sa.inc b/project_composer.sa.inc index 124e98c..a26aa73 100644 --- a/project_composer.sa.inc +++ b/project_composer.sa.inc @@ -25,7 +25,7 @@ function project_composer_security_advisories($release_category) { } // Get project node IDs. - $project_nids = db_query("SELECT project_nid FROM {project_composer_providers} WHERE release_category = 'current' AND provider_type = 'package' AND provider_name IN (:names)", [ + $project_nids = db_query("SELECT map.project_nid, map.map_id, min(dupe.map_id) FROM {project_composer_namespace_map} map INNER JOIN {project_composer_namespace_map} dupe ON dupe.category = map.category AND dupe.project_name = map.project_name WHERE map.category = 'current' AND map.package_namespace IN (:names) GROUP BY map.project_nid HAVING map.map_id = min(dupe.map_id) ORDER BY NULL", [ ':names' => $names, ])->fetchCol(); if (in_array('core', $names)) { -- GitLab