Commit ba396caa authored by drumm's avatar drumm
Browse files

Issue #3137087: Limit parts of project_release_node_view() to one execution

parent 41ad17c1
......@@ -1070,6 +1070,8 @@ function project_release_download_table($pid, $_clear = FALSE) {
* Implements hook_node_view().
*/
function project_release_node_view($node, $view_mode, $langcode) {
static $nids_processed = [];
if (project_node_is_project($node)) {
if (!empty($node->field_project_has_releases[LANGUAGE_NONE][0]['value']) && $view_mode === 'full') {
// Add releases table and links.
......@@ -1103,24 +1105,30 @@ function project_release_node_view($node, $view_mode, $langcode) {
}
elseif (project_release_node_is_release($node)) {
if ($view_mode === 'full') {
$project = node_load(project_release_get_release_project_nid($node));
project_project_set_breadcrumb($project, TRUE, [[
'title' => t('Releases'),
'href' => 'node/' . $project->nid . '/release',
'localized_options' => [],
]]);
// Display packaging errors to admins.
if (project_user_access($project, 'administer releases')) {
$rows = unserialize(db_select('project_release_package_errors', 'prpe')
->fields('prpe', ['messages'])
->condition('prpe.nid', $node->nid)
->execute()->fetchField());
if (!empty($rows)) {
drupal_set_message(theme('item_list', [
'title' => t('Packaging error messages'),
'items' => $rows,
]), 'error');
if (!isset($nids_processed[$node->nid])) {
// Can be called twice with the same arguments, such as Panelizer field
// panes. Only do the global work once.
$nids_processed[$node->nid] = TRUE;
$project = node_load(project_release_get_release_project_nid($node));
project_project_set_breadcrumb($project, TRUE, [[
'title' => t('Releases'),
'href' => 'node/' . $project->nid . '/release',
'localized_options' => [],
]]);
// Display packaging errors to admins.
if (project_user_access($project, 'administer releases')) {
$rows = unserialize(db_select('project_release_package_errors', 'prpe')
->fields('prpe', ['messages'])
->condition('prpe.nid', $node->nid)
->execute()->fetchField());
if (!empty($rows)) {
drupal_set_message(theme('item_list', [
'title' => t('Packaging error messages'),
'items' => $rows,
]), 'error');
}
}
}
}
......
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