From d85c1e9e6720c182e1e03555515955078219aa6c Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Fri, 14 Oct 2016 10:58:47 +0200 Subject: [PATCH] Resolve commons_activity_streams errors The commons_activity_streams_message_access_alter hook was not checking for empty arrays, and throw a ton of notice and warning messages. Related issue report: https://www.drupal.org/node/2596651 Change-Id: Ife614d97908758b01f927ed01656a0962e5a44cb --- commons.make | 3 ++- ...010-commons-activity-streams-warning.patch | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 patches/0010-commons-activity-streams-warning.patch diff --git a/commons.make b/commons.make index 431a0c5..405f81b 100644 --- a/commons.make +++ b/commons.make @@ -6,4 +6,5 @@ projects[commons][type] = "profile" projects[commons][version] = "3.39" projects[commons][patch][] = "patches/0005-commons-libraries-search-paths-alter.patch" projects[commons][patch][] = "patches/0004-accomodate-flag-v3.patch" -projects[commons][patch][] = "patches/0009-commons-flag-v3.patch" \ No newline at end of file +projects[commons][patch][] = "patches/0009-commons-flag-v3.patch" +projects[commons][patch][] = "patches/0010-commons-activity-streams-warning.patch" diff --git a/patches/0010-commons-activity-streams-warning.patch b/patches/0010-commons-activity-streams-warning.patch new file mode 100644 index 0000000..3fe07be --- /dev/null +++ b/patches/0010-commons-activity-streams-warning.patch @@ -0,0 +1,22 @@ +diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.module.orig b/modules/commons/commons_activity_streams/commons_activity_streams.module +index 854b4f3..30b0f92 100644 +--- a/modules/commons/commons_activity_streams/commons_activity_streams.module.orig ++++ b/modules/commons/commons_activity_streams/commons_activity_streams.module +@@ -98,7 +98,7 @@ function commons_activity_streams_message_access_alter(&$access, $context) { + + $message = $context['entity']; + // Verify view access to nodes referenced in the message. +- if (isset($message->field_target_nodes)) { ++ if ((isset($message->field_target_nodes)) && (!empty($message->field_target_nodes))) { + foreach ($message->field_target_nodes[LANGUAGE_NONE] as $key => $value) { + $node = node_load($value['target_id']); + if (!node_access('view', $node, $context['account'])) { +@@ -110,7 +110,7 @@ function commons_activity_streams_message_access_alter(&$access, $context) { + } + } + // Verify view access to comments referenced in the message. +- if (isset($message->field_target_comments)) { ++ if ((isset($message->field_target_comments)) && (!empty($message->field_target_comments))) { + foreach ($message->field_target_comments[LANGUAGE_NONE] as $key => $value) { + $comment = comment_load($value['target_id']); + if (!entity_access('view', 'comment', $comment, $context['account'])) {