commit e9734207004e215093a291e20e51372d50d5c605
Author: Assos Assos <assos+forge@centrale-marseille.fr>
Date:   Wed Sep 25 23:41:41 2019 +0200

    Weekly update of contrib modules

diff --git a/drupal7/sites/all/modules/forum_access/CHANGELOG.txt b/drupal7/sites/all/modules/forum_access/CHANGELOG.txt
index 76d1ffd8..9dda2d15 100644
--- a/drupal7/sites/all/modules/forum_access/CHANGELOG.txt
+++ b/drupal7/sites/all/modules/forum_access/CHANGELOG.txt
@@ -5,8 +5,20 @@ CHANGELOG for Forum Access for Drupal 7
 forum_access 7.x-1.x-dev:
 
 
+forum_access 7.x-1.4 (2019-09-25):
+  Bugs fixed:
+    - #3003279 by salvis, ron_s: Forum node migration generates warning errors.
+    - #3002918 by ron_s: Define primary key for the {forum_access} table.
+    - #3068844 by salvis: Fix PhpStorm red flags (no functional change).
+    - #3068829 by salvis: Fix Warning: count(): Parameter must be an array or an object that implements Countable in form_process_radios() (line 3183 of includes\form.inc).
+    - Avoid notices in a test.
+  Enhancement:
+    - #3083683 by salvis: Hide inaccessible forums from the forum list.
+    - #2958547 by salvis: Support non-forum nodes with optional forum_taxonomy field.
+
+
 forum_access 7.x-1.3 (2016-08-16):
-  Bug fixed:
+  Bugs fixed:
     - #2783863: Remove call to non-existent _forum_access_preprocess_comment() function.
     - #2463055 by DrCord: Fix 'Use of undefined constant uids' notice.
     - #2276445 by Bastlynn: Avoid a notice when a comment pending for notification has been deleted.
@@ -16,7 +28,6 @@ forum_access 7.x-1.3 (2016-08-16):
     - Avoid a notice on admin/index.
     - #1793504 by RedRat: Fix non-translatable string.
 
-
 forum_access 7.x-1.2 (2012-09-15):
   Bug fixed:
     - #1775204: Avoid crashing the site if FA encounters CMA 1.x (when the upgrade instructions aren't being followed).
diff --git a/drupal7/sites/all/modules/forum_access/forum_access.admin.inc b/drupal7/sites/all/modules/forum_access/forum_access.admin.inc
index 4dba751a..a972f067 100644
--- a/drupal7/sites/all/modules/forum_access/forum_access.admin.inc
+++ b/drupal7/sites/all/modules/forum_access/forum_access.admin.inc
@@ -64,7 +64,7 @@ function _forum_access_forum_form(&$form, &$form_state, $is_container) {
       '#type' => 'radios',
       '#title' => t('Update the permissions'),
       '#description' => t('<em>If</em> you make any node access changes, then each node in this forum needs to be updated. Hover over the radiobuttons for details.'),
-      '#options' => NULL,
+      '#options' => array(0, 1, 2),
       0 => array(
         '#type' => 'radio',
         '#title' => t('for all %count nodes immediately', array('%count' => $count)),
@@ -401,7 +401,7 @@ function _forum_access_forum_interference_form($is_container, $na_modules, $fa_p
         }
       }
       $ca_priority = content_access_get_settings('priority', 'forum');
-      $is_conflict = ($ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority);
+      $is_conflict = (($ca_priority >= $fa_priority && !empty($ca_interferes)) || $ca_priority > $fa_priority);
       $variables += array(
         '!link'     => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/structure/types/manage/forum/access', array('html' => TRUE)),
         '%Advanced' => $tr('Advanced'),
diff --git a/drupal7/sites/all/modules/forum_access/forum_access.info b/drupal7/sites/all/modules/forum_access/forum_access.info
index 2097a7cb..dc1c1a9f 100644
--- a/drupal7/sites/all/modules/forum_access/forum_access.info
+++ b/drupal7/sites/all/modules/forum_access/forum_access.info
@@ -10,9 +10,8 @@ configure = admin/structure/forum
 
 files[] = tests/forum_access.test
 
-; Information added by Drupal.org packaging script on 2016-08-16
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-09-25
+version = "7.x-1.4"
 core = "7.x"
 project = "forum_access"
-datestamp = "1471309440"
-
+datestamp = "1569441788"
diff --git a/drupal7/sites/all/modules/forum_access/forum_access.install b/drupal7/sites/all/modules/forum_access/forum_access.install
index fbda65bc..e33c008a 100644
--- a/drupal7/sites/all/modules/forum_access/forum_access.install
+++ b/drupal7/sites/all/modules/forum_access/forum_access.install
@@ -86,15 +86,14 @@ function forum_access_schema() {
         'unsigned'    => TRUE,
         'not null'    => TRUE,
         'default'     => 0),
-      'priority'  => array(
+      'priority'      => array(
         'description' => 'The priority of this grant.',
         'type'        => 'int',
         'size'        => 'small',
         'not null'    => TRUE,
         'default'     => 0)),
-    'indexes'         => array(
-      'tid'           => array('tid'),
-      'rid'           => array('rid')),
+    'primary key'     => array('tid', 'rid'),
+    'indexes'         => array('rid' => array('rid')),
     'foreign keys'    => array(
       'tid'           => array('taxonomy_term_data' => 'tid'),
       'rid'           => array('role' => 'rid')),
@@ -184,3 +183,11 @@ function forum_access_update_7001() {
 function forum_access_update_7002() {
   variable_del('forum_access_D5_legacy_mode');
 }
+
+/**
+ * Drop tid index and add primary key to forum_access table.
+ */
+function forum_access_update_7003() {
+  db_drop_index('forum_access', 'tid');
+  db_add_primary_key('forum_access', array('tid', 'rid'));
+}
diff --git a/drupal7/sites/all/modules/forum_access/forum_access.module b/drupal7/sites/all/modules/forum_access/forum_access.module
index 47dfa002..c2e872d9 100644
--- a/drupal7/sites/all/modules/forum_access/forum_access.module
+++ b/drupal7/sites/all/modules/forum_access/forum_access.module
@@ -26,7 +26,7 @@ function forum_access_requirements($phase) {
       $info = drupal_parse_info_file($path);
       $version = (isset($info['version']) ? $info['version'] : $t('Unknown'));
       $found = preg_match('/7\.x-([0-9]*)\./', $version, $matches);
-      if ($found && $matches[1] == 1 || !$found) {
+      if (($found && $matches[1] == 1) || !$found) {
         $cma = 'Chain Menu Access API';
         $variables = array('@Chain_Menu_Access_API' => $cma, '@module' => url('admin/modules'));
         $result[] = array(
@@ -115,6 +115,9 @@ function _forum_access_comment_access_callback($comment, $op) {
       return FALSE;
     }
   }
+  elseif (is_string($comment)) {
+    return FALSE;
+  }
   $node = node_load($comment->nid);
 
   // The remaining $ops are governed by OR, return FALSE by default.
@@ -283,6 +286,35 @@ function forum_access_form_alter(&$form, &$form_state, $form_id) {
   }
 }
 
+/**
+ * Implements hook_form_node_form_alter().
+ *
+ * Allows the forum field to be optional on non-forum nodes.
+ */
+function forum_access_form_node_form_alter(&$form, &$form_state, $form_id) {
+  if (isset($form['taxonomy_forums'])) {
+    $field = field_info_instance('node', 'taxonomy_forums', $form['type']['#value']);
+    // Make the vocabulary required for 'real' forum-nodes.
+    if (!$field['required']) {
+      $langcode = $form['taxonomy_forums']['#language'];
+      $form['taxonomy_forums'][$langcode]['#required'] = FALSE;
+    }
+  }
+}
+
+/**
+ * Implement hook_node_load().
+ *
+ * Sets $node->forum_tid to avoid confusing forum_node_view().
+ */
+function forum_access_node_load($nodes, $types) {
+  foreach ($nodes as $node) {
+    if (isset($node->taxonomy_forums) && empty($node->taxonomy_forums) && !isset($node->forum_tid)) {
+      $node->forum_tid = NULL;
+    }
+  }
+}
+
 /**
  * Implements hook_comment_load().
  */
@@ -299,6 +331,11 @@ function forum_access_query_alter($p1, $p2, $p3) {
   return;
 }
 
+/**
+ * Implements hook_query_term_access_alter().
+ *
+ * @param QueryAlterableInterface $query
+ */
 function forum_access_query_term_access_alter(QueryAlterableInterface $query) {
   global $user;
 
@@ -310,9 +347,9 @@ function forum_access_query_term_access_alter(QueryAlterableInterface $query) {
     $op = 'view';
   }
 
-  // If $account can bypass node access, or there are no node access
-  // modules, we don't need to alter the query.
-  if (user_access('bypass node access', $account)) {
+  // If $account can bypass node access, we let them administer the full forum
+  // structure and see the nodes, i.e. we don't restrict the query.
+  if (user_access('bypass node access', $account) && (strpos(current_path(), 'admin/structure/forum') === 0 || strpos(current_path(), 'node/') === 0)) {
     return;
   }
 
@@ -331,13 +368,25 @@ function forum_access_query_term_access_alter(QueryAlterableInterface $query) {
       // The node_access table has the access grants for any given node.
       $access_alias = $query->leftJoin('forum_access', 'fa', '%alias.tid = ' . $talias . '.tid');
       $acl_alias = $query->leftJoin('acl', 'acl', "%alias.number = $talias.tid AND %alias.module = 'forum_access'");
-      $aclu_alias = $query->leftJoin('acl_user', 'aclu', "%alias.acl_id = $acl_alias.acl_id AND %alias.uid = $account->uid");
-      $query->condition(db_or()
-        ->isNull("$access_alias.rid")
-        ->condition(db_and()
-          ->condition("$access_alias.rid", $rids, 'IN')
-          ->condition("$access_alias.grant_$op", 1, '>='))
-        ->condition("$aclu_alias.uid", $account->uid));
+      if (user_access('bypass node access', $account)) {
+        // If $account can bypass node access, we allow access if any role or
+        // account has access.
+        $aclu_alias = $query->leftJoin('acl_user', 'aclu', "%alias.acl_id = $acl_alias.acl_id");
+        $query->condition(db_or()
+          ->isNull("$access_alias.rid")
+          ->condition("$access_alias.grant_$op", 1, '>=')
+          ->isNotNull("$aclu_alias.uid")
+        );
+      }
+      else {
+        $aclu_alias = $query->leftJoin('acl_user', 'aclu', "%alias.acl_id = $acl_alias.acl_id AND %alias.uid = $account->uid");
+        $query->condition(db_or()
+          ->isNull("$access_alias.rid")
+          ->condition(db_and()
+            ->condition("$access_alias.rid", $rids, 'IN')
+            ->condition("$access_alias.grant_$op", 1, '>='))
+          ->condition("$aclu_alias.uid", $account->uid));
+      }
     }
   }
 }
@@ -348,9 +397,18 @@ function forum_access_query_term_access_alter(QueryAlterableInterface $query) {
 function forum_access_node_presave($node, $return_old_tid = FALSE) {
   $old_tid = &drupal_static('forum_access_node_presave');
   if (_forum_node_check_node_type($node)) {
-    $old_tid = db_query('SELECT tid FROM {forum} WHERE nid = :nid', array(
-      ':nid' => $node->nid,
-    ))->fetchField();
+    if (empty($node->nid)) {
+      // Added for migrations, which log errors due to no nid during presave, see #3003279.
+      $old_tid = NULL;
+    }
+    else {
+      $old_tid = db_query('SELECT tid FROM {forum} WHERE nid = :nid', array(
+        ':nid' => $node->nid,
+      ))->fetchField();
+    }
+  }
+  if (!empty($old_tid) && empty($node->taxonomy_forums['und'])) {
+    $node->forum_tid = null;
   }
 }
 
@@ -423,7 +481,7 @@ function forum_access_node_insert($node) {
 function forum_access_enable_moderator($enable = TRUE) {
   global $user;
 
-  if (!$enable || $enable && !user_access('administer comments')) {
+  if (!$enable || !user_access('administer comments')) {
     $perm = &drupal_static('user_access');
     if ($enable) {
       $perm[$user->uid]['administer comments'] = $enable;
@@ -508,13 +566,21 @@ function forum_access_preprocess_forum_list(&$variables) {
 /**
  * Implements hook_node_view_alter().
  *
- * Remove 'Add new comment' link if it shouldn't be there.
+ * Remove 'Add new comment' link and breadcrumb if they shouldn't be there.
  */
 function forum_access_node_view_alter(&$build) {
   if ($tid = _forum_access_get_tid($build['#node'])) {
     _forum_access_module_load_include('node.inc');
     _forum_access_node_view_alter($build, $tid);
   }
+
+  $breadcrumb = drupal_get_breadcrumb();
+  if (!$tid && count($breadcrumb) == 2 && strpos($breadcrumb[0], '<a href="/">') === 0 && strpos($breadcrumb[1], '<a href="/forum">') === 0) {
+    // We must hack away the bogus breadcrumb set by forum module
+    // (empty taxonomy_forums).
+    $stored_breadcrumb = &drupal_static('drupal_set_breadcrumb');
+    $stored_breadcrumb = NULL;
+  }
 }
 
 /**
@@ -564,8 +630,8 @@ function forum_access_node_access($node, $op, $account) {
         if (!forum_access_access('view', $tid, $account)) {
           return $cache[$account->uid][$op][$nid] = NODE_ACCESS_DENY;
         }
-        if ($op == 'update' && (user_access('edit any forum content', $account) || ($node->uid == $account->uid && user_access('edit own forum content', $account)))
-          || $op == 'delete' && (user_access('delete any forum content', $account) || ($node->uid == $account->uid && user_access('delete own forum content', $account)))) {
+        if (($op == 'update' && (user_access('edit any forum content', $account) || ($node->uid == $account->uid && user_access('edit own forum content', $account))))
+          || ($op == 'delete' && (user_access('delete any forum content', $account) || ($node->uid == $account->uid && user_access('delete own forum content', $account))))) {
           return $cache[$account->uid][$op][$nid] = forum_access_node_access($node, 'view', $account);
         }
         $access = forum_access_access($op, $tid, $account);
diff --git a/drupal7/sites/all/modules/forum_access/forum_access.node.inc b/drupal7/sites/all/modules/forum_access/forum_access.node.inc
index c6d1e995..c03f5b22 100644
--- a/drupal7/sites/all/modules/forum_access/forum_access.node.inc
+++ b/drupal7/sites/all/modules/forum_access/forum_access.node.inc
@@ -75,6 +75,7 @@ function _forum_access_comment_view_alter(&$build, $tid) {
         }
       }
       if (is_array($old_links)) {
+        /** @noinspection SlowArrayOperationsInLoopInspection */
         $links = array_merge($links, $old_links);
       }
     }
@@ -207,7 +208,7 @@ function _forum_access_comment_form(&$form, &$form_state) {
   global $user;
 
   $comment = $form_state['comment'];
-  if ($cid = $form['cid']['#value'] && isset($form['author']) && !empty($user->_forum_access_moderator)) {
+  if ($form['cid']['#value'] && isset($form['author']) && !empty($user->_forum_access_moderator)) {
     $editable_administration_elements = variable_get('forum_access_allowed_comment_edit_administration_elements', array('homepage', 'status', 'subscriptions_notify'));
     foreach (element_children($form['author']) as $key) {
       if (array_search($key, $editable_administration_elements) === FALSE) {
diff --git a/drupal7/sites/all/modules/forum_access/tests/forum_access_test_base.php b/drupal7/sites/all/modules/forum_access/tests/forum_access_test_base.php
index 834f20f1..01e706a3 100644
--- a/drupal7/sites/all/modules/forum_access/tests/forum_access_test_base.php
+++ b/drupal7/sites/all/modules/forum_access/tests/forum_access_test_base.php
@@ -32,6 +32,7 @@ class ForumAccessBaseTestCase extends ForumTestCase {
   protected $delete_any_content_user;
   protected $delete_own_content_user;
   protected $create_content_user;
+  protected $auth_user;
   protected $moderator;
   protected $time;
   protected $accounts;
@@ -487,7 +488,7 @@ class ForumAccessBaseTestCase extends ForumTestCase {
               $this->drupalGet("comment/$comment->cid/edit");
               $this->assertResponse(200);
               $this->assertText($comment->subject);
-              $comment->title .= ' (updated)';
+              $comment->subject .= ' (updated)';
               $this->drupalPost("comment/$comment->cid/edit", array(
                 'subject' => $comment->subject,
               ), t('Save'));
