Commit b6fa40b4 authored by drumm's avatar drumm
Browse files

Issue #3117465: Fix exception when a project does not have a release with usage

parent 810bace1
......@@ -238,25 +238,27 @@ function project_usage_restws_response_alter(&$response, $function, $formatName,
$usage[$row->project_nid][$row->nid] = $row->count;
$release_nids[] = $row->nid;
}
$result = (new EntityFieldQuery())->entityCondition('entity_type', 'node')
->propertyCondition('status', NODE_PUBLISHED)
->propertyCondition('nid', $release_nids)
->execute();
if (!empty($result['node'])) {
field_attach_load('node', $result['node'], FIELD_LOAD_CURRENT, [
'field_id' => field_info_field('field_release_version')['id'],
]);
$release_branches = [];
foreach ($result['node'] as $release) {
$release_branches[$release->nid] = project_release_get_branch($release->field_release_version[LANGUAGE_NONE][0]['value']) . 'x';
}
foreach ($usage as $project_nid => $releases) {
foreach ($releases as $nid => $count) {
if (isset($response['list'][$nid_map[$project_nid]]['project_usage'][$release_branches[$nid]])) {
$response['list'][$nid_map[$project_nid]]['project_usage'][$release_branches[$nid]] += $count;
}
else {
$response['list'][$nid_map[$project_nid]]['project_usage'][$release_branches[$nid]] = $count;
if (!empty($release_nids)) {
$result = (new EntityFieldQuery())->entityCondition('entity_type', 'node')
->propertyCondition('status', NODE_PUBLISHED)
->propertyCondition('nid', $release_nids)
->execute();
if (!empty($result['node'])) {
field_attach_load('node', $result['node'], FIELD_LOAD_CURRENT, [
'field_id' => field_info_field('field_release_version')['id'],
]);
$release_branches = [];
foreach ($result['node'] as $release) {
$release_branches[$release->nid] = project_release_get_branch($release->field_release_version[LANGUAGE_NONE][0]['value']) . 'x';
}
foreach ($usage as $project_nid => $releases) {
foreach ($releases as $nid => $count) {
if (isset($response['list'][$nid_map[$project_nid]]['project_usage'][$release_branches[$nid]])) {
$response['list'][$nid_map[$project_nid]]['project_usage'][$release_branches[$nid]] += $count;
}
else {
$response['list'][$nid_map[$project_nid]]['project_usage'][$release_branches[$nid]] = $count;
}
}
}
}
......
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