Commit 15d2730b authored by drumm's avatar drumm
Browse files

Issue #3104698: Remove {project_release_supported_versions}.tid column

parent ed365662
......@@ -21,18 +21,27 @@ function project_release_project_edit_releases($node) {
*/
function project_release_project_edit_form($form, $form_state, $node) {
// Get all the data about versions for this project.
$recommended_api_terms = (new EntityFieldQuery())->entityCondition('entity_type', 'taxonomy_term')
->fieldCondition('field_release_recommended', 'value', 1)
->execute();
if ($api_vid = variable_get('project_release_api_vocabulary')) {
$api_field = 'taxonomy_' . taxonomy_vocabulary_load($api_vid)->machine_name;
$recommended_api_terms = (new EntityFieldQuery())->entityCondition('entity_type', 'taxonomy_term')
->fieldCondition('field_release_recommended', 'value', 1)
->execute();
}
$query = db_select('project_release_supported_versions', 'psrv')
->condition('psrv.nid', $node->nid)
->fields('psrv', ['branch', 'tid', 'supported', 'recommended']);
->fields('psrv', ['branch', 'supported', 'recommended']);
$data = [];
$current_versions = [];
foreach ($query->execute() as $object) {
// Releases with an API compatability that is not recommended can not be
// supported.
if (!empty($object->tid) && !isset($recommended_api_terms['taxonomy_term'][$object->tid])) {
continue;
if ($versions = project_release_get_releases_by_version($node->nid, $object->branch)) {
$current_versions[$object->branch] = entity_metadata_wrapper('node', array_shift($versions));
if (isset($api_field)) {
if (!empty($current_versions[$object->branch]->{$api_field}->value()->tid) && !isset($recommended_api_terms['taxonomy_term'][$current_versions[$object->branch]->{$api_field}->value()->tid])) {
continue;
}
}
}
$data[$object->branch] = [
......@@ -57,13 +66,12 @@ function project_release_project_edit_form($form, $form_state, $node) {
];
uksort($data, 'project_release_version_compare');
foreach (array_reverse($data, TRUE) as $branch => $branch_data) {
$versions = array_keys(project_release_get_releases_by_version($node->nid, $branch));
$form['branches'][$branch] = [
'name' => [
'#markup' => check_plain($branch_data['name']),
],
'current' => [
'#markup' => (!empty($versions)) ? check_plain($versions[0]) : '',
'#markup' => (!empty($current_versions[$branch])) ? $current_versions[$branch]->field_release_version->value(['sanitize' => TRUE]) : '',
],
'supported' => [
'#type' => 'checkbox',
......
......@@ -73,13 +73,6 @@ function project_release_schema() {
'not null' => TRUE,
'default' => '',
],
'tid' => array(
'description' => 'The {term_data}.tid of the API compatability version associated with the branch.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'supported' => array(
'description' => 'A flag to indicate whether or not a given branch of a project is supported.',
'type' => 'int',
......@@ -2282,3 +2275,10 @@ function project_release_update_7029() {
function project_release_update_7030() {
db_add_unique_key('project_release_supported_versions', 'latest_release', ['latest_release']);
}
/**
* Remove {project_release_supported_versions}.tid column.
*/
function project_release_update_7031() {
db_drop_field('project_release_supported_versions', 'tid');
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment