commit 5e632cae7f8f0d804d020d9e12124bd0acbf1711
Author: Assos Assos <assos+forge@centrale-marseille.fr>
Date:   Wed Dec 30 23:11:24 2020 +0100

    Weekly update of contrib modules

diff --git a/drupal7/sites/all/modules/field_collection/ctools/relationships/field_collection_from_field.inc b/drupal7/sites/all/modules/field_collection/ctools/relationships/field_collection_from_field.inc
index 8fbd0992..3150764e 100644
--- a/drupal7/sites/all/modules/field_collection/ctools/relationships/field_collection_from_field.inc
+++ b/drupal7/sites/all/modules/field_collection/ctools/relationships/field_collection_from_field.inc
@@ -88,10 +88,8 @@ function field_collection_field_collection_from_field_context($context, $conf) {
     }
 
     if (!empty($items) && isset($items[$delta]['value'])) {
-      $field_collection_item = field_collection_item_load($items[$delta]['value']);
+      return ctools_context_create('entity:field_collection_item', $items[$delta]['value']);
     }
-
-    return ctools_context_create('entity:field_collection_item', $items[$delta]['value']);
   }
 
   return ctools_context_create_empty('entity:field_collection_item', NULL);
diff --git a/drupal7/sites/all/modules/field_collection/field-collection-item.tpl.php b/drupal7/sites/all/modules/field_collection/field-collection-item.tpl.php
index c6cdbbab..a3a7c1dc 100644
--- a/drupal7/sites/all/modules/field_collection/field-collection-item.tpl.php
+++ b/drupal7/sites/all/modules/field_collection/field-collection-item.tpl.php
@@ -28,7 +28,7 @@
  * @see template_process()
  */
 ?>
-<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
+<div <?php print $attributes; ?>>
   <div class="content"<?php print $content_attributes; ?>>
     <?php
       print render($content);
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.api.php b/drupal7/sites/all/modules/field_collection/field_collection.api.php
index 4fa56ee9..0d135a80 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.api.php
+++ b/drupal7/sites/all/modules/field_collection/field_collection.api.php
@@ -113,6 +113,22 @@ function hook_field_collection_item_delete(FieldCollectionItemEntity $field_coll
     ->execute();
 }
 
+/**
+ * Responds to field collection item archiving.
+ *
+ * This hook is invoked after the field collection item has been archived while
+ * removing it from its host entity.
+ *
+ * @param FieldCollectionItemEntity $field_collection_item
+ *   The field collection item that is being archived.
+ */
+function hook_field_collection_item_archive(FieldCollectionItemEntity $field_collection_item) {
+  db_update('mytable')
+    ->fields(array('archived' => 1))
+    ->condition('id', entity_id('field_collection_item', $field_collection_item))
+    ->execute();
+}
+
 /**
  * Act on a field collection item that is being assembled before rendering.
  *
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.entity.inc b/drupal7/sites/all/modules/field_collection/field_collection.entity.inc
index 1f9306d9..bc504c2e 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.entity.inc
+++ b/drupal7/sites/all/modules/field_collection/field_collection.entity.inc
@@ -127,7 +127,7 @@ class FieldCollectionItemEntity extends Entity {
   public function translatedInstanceLabel($langcode = NULL) {
     if ($info = $this->instanceInfo()) {
       if (module_exists('i18n_field')) {
-        return i18n_string("field:{$this->field_name}:{$info['bundle']}:label", $info['label'], array('langcode' => $langcode));
+        return i18n_string("field:{$this->field_name}:{$info['bundle']}:label", $info['label'], array('langcode' => $langcode, 'sanitize' => FALSE));
       }
       return $info['label'];
     }
@@ -330,8 +330,10 @@ class FieldCollectionItemEntity extends Entity {
           $query->entityCondition('entity_type', $entity_type);
           $query->entityCondition('entity_id', $hostEntity->{$key});
           $query->entityCondition('bundle', $bundle);
-          if (isset($entity_info['entity keys']['language'])) {
-            $query->propertyCondition('language', $hostEntity->language);
+          // Only filter by language if this entity type has a language key that
+          // has a corresponding field in its base table.
+          if (!empty($entity_info['entity keys']['language']) && !empty($entity_info['schema_fields_sql']['base table']) && in_array($entity_info['entity keys']['language'], $entity_info['schema_fields_sql']['base table'], TRUE)) {
+            $query->propertyCondition($entity_info['entity keys']['language'], $hostEntity->{$entity_info['entity keys']['language']});
           }
         }
         $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
@@ -607,6 +609,10 @@ class FieldCollectionItemEntity extends Entity {
           ->fields(array('archived' => 1, 'revision_id' => $row['revision_id']))
           ->condition('item_id', $this->item_id)
           ->execute();
+
+        // Let other modules know about the archived item.
+        entity_get_controller('field_collection_item')->invoke('archive', $this);
+
         entity_get_controller('field_collection_item')->resetCache(array($this->item_id));
         entity_revision_delete('field_collection_item', $this->revision_id);
       }
@@ -648,8 +654,7 @@ class FieldCollectionItemEntity extends Entity {
    */
   public function __sleep() {
     $vars = get_object_vars($this);
-    unset($vars['entityInfo'], $vars['idKey'], $vars['nameKey'], $vars['statusKey']);
-    unset($vars['fieldInfo']);
+    unset($vars['entityInfo'], $vars['idKey'], $vars['nameKey'], $vars['statusKey'], $vars['fieldInfo']);
     // Also do not serialize the host entity, but only if it has already an id.
     if ($this->hostEntity && ($this->hostEntityId || $this->hostEntityRevisionId)) {
       unset($vars['hostEntity']);
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.info b/drupal7/sites/all/modules/field_collection/field_collection.info
index b312deea..24c579b9 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.info
+++ b/drupal7/sites/all/modules/field_collection/field_collection.info
@@ -12,8 +12,8 @@ files[] = field_collection.migrate.inc
 configure = admin/structure/field-collections
 package = Fields
 
-; Information added by Drupal.org packaging script on 2019-09-03
-version = "7.x-1.1"
+; Information added by Drupal.org packaging script on 2020-12-26
+version = "7.x-1.2"
 core = "7.x"
 project = "field_collection"
-datestamp = "1567537827"
+datestamp = "1609006493"
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.info.inc b/drupal7/sites/all/modules/field_collection/field_collection.info.inc
index e8680a89..8126243b 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.info.inc
+++ b/drupal7/sites/all/modules/field_collection/field_collection.info.inc
@@ -32,7 +32,7 @@ class FieldCollectionItemMetadataController extends EntityDefaultMetadataControl
       foreach ($bundles as $bundle => $fields) {
         if (array_intersect_key($fields, $field_collection_fields)) {
           $args = array('@type' => $entity_types[$entity_type]['label']);
-          $properties["host_entity_$entity_type"] = array(
+          $properties["host_entity_{$entity_type}"] = array(
             'label' => t('Host entity (@type)', $args),
             'type' => $entity_type,
             'description' => t('The @type containing the field collection field (empty if this field collection is attached to an item of a different type).', $args),
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.install b/drupal7/sites/all/modules/field_collection/field_collection.install
index c2d8b82e..e8791e28 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.install
+++ b/drupal7/sites/all/modules/field_collection/field_collection.install
@@ -425,8 +425,7 @@ function field_collection_update_7009(&$sandbox) {
     ->fields('t', array("{$sandbox['field_name']}_revision_id"))
     ->range($sandbox['current_field_collection_item'], $items_per_pass)
     ->groupBy("t.{$sandbox['field_name']}_revision_id");
-  $query->addExpression("COUNT(t.{$sandbox['field_name']}_revision_id)", 'vidcount');
-  $query->havingCondition('vidcount', 2, '>=');
+  $query->having("COUNT(t.{$sandbox['field_name']}_revision_id) >= 2");
   $vids = $query->execute()->fetchCol();
 
   // Each revision ID that occurs more than once.
@@ -488,19 +487,21 @@ function field_collection_update_7009(&$sandbox) {
         ->condition('delta', $row_to_replace->delta)
         ->condition('language', $row_to_replace->language)
         ->execute();
-    }
 
-    if ($field_collection_item_current_revision == $field_collection_duplicated_revision_id) {
-      _field_collection_update_7009_update_data($new_revision_id, $field_collection_duplicated_revision_id);
+      if ($field_collection_item_current_revision == $field_collection_duplicated_revision_id) {
+        _field_collection_update_7009_update_data($new_revision_id, $field_collection_duplicated_revision_id);
 
-      // Update the current field collection item data in its host.
-      db_update("field_data_{$sandbox['field_name']}")
-        ->fields(array('revision_id' => $new_revision))
-        ->condition('revision_id', $old_revision)
-        ->condition('entity_type', $row_to_replace->entity_type)
-        ->execute();
+        // Update the current field collection item data in its host.
+        db_update("field_data_{$sandbox['field_name']}")
+          ->fields(array('revision_id' => $new_revision_id))
+          ->condition('revision_id', $field_collection_duplicated_revision_id)
+          ->condition('entity_type', $row_to_replace->entity_type)
+          ->execute();
+      }
     }
 
+
+
     foreach ($modern_revisions as $each_modern_revision) {
       $new_revision_id = _field_collection_update_7009_new_revision($field_collection_item_id, $each_modern_revision, $sandbox['inner_fields'], $sandbox['field_name']);
 
@@ -523,12 +524,12 @@ function field_collection_update_7009(&$sandbox) {
         ->execute();
 
       if ($field_collection_item_current_revision == $each_modern_revision->{"{$sandbox['field_name']}_revision_id"}) {
-        _field_collection_update_7009_update_data($new_revision_id, $each_modern_revision->{"{$sandbox['field_name']}_revision_id"});
+        _field_collection_update_7009_update_data($new_revision_id, $field_collection_item_current_revision);
 
         // Update the current field collection item data in its host.
         db_update("field_data_{$sandbox['field_name']}")
-          ->fields(array('revision_id' => $new_revision))
-          ->condition('revision_id', $old_revision)
+          ->fields(array('revision_id' => $new_revision_id))
+          ->condition('revision_id', $field_collection_item_current_revision)
           ->condition('entity_type', $each_modern_revision->entity_type)
           ->execute();
       }
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.migrate.inc b/drupal7/sites/all/modules/field_collection/field_collection.migrate.inc
index 16ad444c..4879ad94 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.migrate.inc
+++ b/drupal7/sites/all/modules/field_collection/field_collection.migrate.inc
@@ -41,7 +41,7 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
    */
   protected $hostEntityType;
 
-  static public function getKeySchema() {
+  public static function getKeySchema() {
     return array(
       'item_id' => array(
         'type' => 'int',
@@ -191,8 +191,7 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
  * Implements migrate hook_migrate_api().
  */
 function field_collection_migrate_api() {
-  $api = array(
+  return array(
     'api' => 2,
   );
-  return $api;
 }
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.module b/drupal7/sites/all/modules/field_collection/field_collection.module
index 8e1b8092..eb9c2cd2 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.module
+++ b/drupal7/sites/all/modules/field_collection/field_collection.module
@@ -44,7 +44,7 @@ function field_collection_form_field_ui_field_overview_form_alter(&$form, &$form
       if (!isset($field['type']['#title'])) {
         continue;
       }
-      if ($field['type']['#title'] == 'Field collection') {
+      if ($field['type']['#title'] === 'Field collection') {
         $form['fields'][$fieldname]['field_name']['#markup'] =
           l($form['fields'][$fieldname]['field_name']['#markup'], 'admin/structure/field-collections/' . str_replace('_', '-', $fieldname) . '/fields');
       }
@@ -56,7 +56,7 @@ function field_collection_form_field_ui_field_overview_form_alter(&$form, &$form
  * Implements hook_ctools_plugin_directory().
  */
 function field_collection_ctools_plugin_directory($module, $plugin) {
-  if ($module == 'ctools') {
+  if ($module === 'ctools') {
     return 'ctools/' . $plugin;
   }
 }
@@ -164,7 +164,7 @@ function field_collection_entity_language($entity_type, $entity) {
  */
 function field_collection_field_name_load($arg) {
   $field_name = strtr($arg, array('-' => '_'));
-  if (($field = field_info_field($field_name)) && $field['type'] == 'field_collection') {
+  if (($field = field_info_field($field_name)) && $field['type'] === 'field_collection') {
     return $field_name;
   }
 }
@@ -232,7 +232,7 @@ function field_collection_menu() {
 
   // Add menu paths for viewing/editing/deleting field collection items.
   foreach (field_info_fields() as $field) {
-    if ($field['type'] == 'field_collection') {
+    if ($field['type'] === 'field_collection') {
       $path = field_collection_field_get_path($field);
       $count = substr_count($path, '/') + 1;
 
@@ -291,7 +291,9 @@ function field_collection_menu() {
 }
 
 /**
- * Implements hook_menu_alter() to fix the field collections admin UI tabs.
+ * Implements hook_menu_alter().
+ *
+ * Fix the field collections admin UI tabs.
  */
 function field_collection_menu_alter(&$items) {
   if (isset($items['admin/structure/field-collections/%field_collection_field_name/fields']) && module_exists('field_ui')) {
@@ -369,7 +371,7 @@ function field_collection_item_access($op, FieldCollectionItemEntity $item = NUL
   // We do not support editing field collection revisions that are not used at
   // the hosts default revision as saving the host might result in a new default
   // revision.
-  if ($op != 'view' && isset($item) && !$item->isInUse()) {
+  if ($op !== 'view' && isset($item) && !$item->isInUse()) {
     return FALSE;
   }
   if (user_access('edit field collections', $account)) {
@@ -381,12 +383,12 @@ function field_collection_item_access($op, FieldCollectionItemEntity $item = NUL
   if (!isset($item)) {
     return FALSE;
   }
-  $op = $op == 'view' ? 'view' : 'edit';
+  $op = $op === 'view' ? 'view' : 'edit';
 
   // Access is determined by the entity and field containing the reference.
   $field = field_info_field($item->field_name);
   $hostEntity = $item->hostEntity() !== FALSE ? $item->hostEntity() : NULL;
-  $entity_access = entity_access($op == 'view' ? 'view' : 'update', $item->hostEntityType(), $hostEntity, $account);
+  $entity_access = entity_access($op === 'view' ? 'view' : 'update', $item->hostEntityType(), $hostEntity, $account);
 
   return $entity_access && field_access($op, $field, $item->hostEntityType(), $hostEntity, $account);
 }
@@ -535,6 +537,11 @@ function field_collection_field_insert($host_entity_type, $host_entity, $field,
         'value' => $entity->item_id,
         'revision_id' => $entity->revision_id,
       );
+
+      if (module_exists('pathauto')) {
+        module_load_include('inc', 'field_collection', 'field_collection.pathauto');
+        field_collection_pathauto_create_alias($host_entity, $entity, 'insert');
+      }
     }
   }
 }
@@ -583,7 +590,8 @@ function field_collection_field_update($host_entity_type, $host_entity, $field,
         if (!empty($host_entity->revision) || !empty($host_entity->is_new_revision)) {
           $entity->revision = TRUE;
           // Without this cache clear entity_revision_is_default will
-          // incorrectly return false here when creating a new published revision
+          // incorrectly return false here when creating a new published
+          // revision.
           if (!isset($cleared_host_entity_cache)) {
             list($entity_id) = entity_extract_ids($host_entity_type, $host_entity);
             entity_get_controller($host_entity_type)->resetCache(array($entity_id));
@@ -614,6 +622,11 @@ function field_collection_field_update($host_entity_type, $host_entity, $field,
           'value' => $entity->item_id,
           'revision_id' => $entity->revision_id,
         );
+
+        if (module_exists('pathauto')) {
+          module_load_include('inc', 'field_collection', 'field_collection.pathauto');
+          field_collection_pathauto_create_alias($host_entity, $entity, 'update');
+        }
       }
     }
 
@@ -631,6 +644,13 @@ function field_collection_field_update($host_entity_type, $host_entity, $field,
         ->fields(array('archived' => 1))
         ->condition('item_id', $ids, 'IN')
         ->execute();
+
+      // Let other modules know about the archived items.
+      foreach (field_collection_item_load_multiple($ids) as $un_item) {
+        entity_get_controller('field_collection_item')->invoke('archive', $un_item);
+
+        entity_get_controller('field_collection_item')->resetCache(array($un_item->item_id));
+      }
     }
     else {
       // Load items from the original entity from all languages checking which
@@ -646,6 +666,10 @@ function field_collection_field_update($host_entity_type, $host_entity, $field,
       foreach (field_collection_item_load_multiple($items_to_remove) as $un_item) {
         $un_item->updateHostEntity($host_entity, $host_entity_type);
         $un_item->deleteRevision(TRUE);
+
+        if (module_exists('pathauto')) {
+          pathauto_entity_path_delete_all('field_collection_item', $un_item);
+        }
       }
     }
   }
@@ -689,6 +713,10 @@ function field_collection_field_delete($entity_type, $entity, $field, $instance,
           $hostEntity->field_collection_deleting = TRUE;
         }
       }
+
+      if (module_exists('pathauto')) {
+        pathauto_path_delete_all('field-collection/' . str_replace('_', '-', $field['field_name']) . '/' . $id);
+      }
     }
 
     entity_delete_multiple('field_collection_item', $ids);
@@ -752,7 +780,8 @@ function field_collection_field_is_empty($item, $field) {
 }
 
 /**
- * Determines whether a field collection item entity is empty based on the collection-fields.
+ * Determines whether a field collection item entity is empty based on the
+ * collection-fields.
  */
 function field_collection_item_is_empty(FieldCollectionItemEntity $item) {
   $instances = field_info_instances('field_collection_item', $item->field_name);
@@ -767,7 +796,7 @@ function field_collection_item_is_empty(FieldCollectionItemEntity $item) {
 
     // Boolean fields as those are always considered non-empty, thus their
     // information is not useful and can be skipped by default.
-    if (!$all_boolean && $field['type'] == 'list_boolean') {
+    if (!$all_boolean && $field['type'] === 'list_boolean') {
       continue;
     }
 
@@ -797,7 +826,7 @@ function field_collection_item_is_empty(FieldCollectionItemEntity $item) {
  */
 function _field_collection_field_is_not_boolean($instance) {
   $field = field_info_field($instance['field_name']);
-  return $field['type'] != 'list_boolean';
+  return $field['type'] !== 'list_boolean';
 }
 
 /**
@@ -846,7 +875,7 @@ function field_collection_field_formatter_settings_form($field, $instance, $view
   $settings = $display['settings'];
   $elements = array();
 
-  if ($display['type'] != 'field_collection_fields') {
+  if ($display['type'] !== 'field_collection_fields') {
     $elements['add'] = array(
       '#type' => 'textfield',
       '#title' => t('Add link title'),
@@ -880,7 +909,8 @@ function field_collection_field_formatter_settings_form($field, $instance, $view
     );
   }
 
-  // Add a select form element for view_mode if viewing the rendered field_collection.
+  // Add a select form element for view_mode if viewing the rendered
+  // field_collection.
   if ($display['type'] !== 'field_collection_list') {
 
     $entity_type = entity_get_info('field_collection_item');
@@ -933,12 +963,17 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
   static $local_entity_cache = array();
 
   $fc_ids = array();
-
+  $new_items = array();
   // Collect every possible term attached to any of the fieldable entities.
   foreach ($entities as $id => $entity) {
     foreach ($items[$id] as $delta => $item) {
 
-      // Check if this item is in our local entity cache
+      // Check if the entity already exists.
+      if (isset($item['entity'])) {
+        continue;
+      }
+
+      // Check if this item is in our local entity cache.
       if (isset($local_entity_cache[$item['value']])) {
         $items[$id][$delta]['field_collection'] = $local_entity_cache[$item['value']];
         continue;
@@ -952,6 +987,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
   if ($fc_ids) {
     $new_entities = array();
     $terms = field_collection_item_load_multiple($fc_ids);
+    $new_items == $items;
 
     // Iterate through the fieldable entities again to attach the loaded
     // field collection data.
@@ -959,37 +995,38 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
       $rekey = FALSE;
 
       foreach ($items[$id] as $delta => $item) {
-        // Check whether the field collection field instance value could be loaded.
+        // Check whether the field collection field instance value could be
+        // loaded.
         if (isset($terms[$item['value']])) {
           // Replace the instance value with the term data.
           $e = $terms[$item['value']];
           $local_entity_cache[$item['value']] = $e;
           $items[$id][$delta]['field_collection'] = $e;
 
-	  foreach ($fields as $field_name => $field) {
+          foreach ($fields as $field_name => $field) {
             if (isset($e->$field_name)) {
               $field_data = $e->$field_name;
               if (isset($field_data[$langcode])) {
                 $new_entities[$e->item_id] = $e->item_id;
-                $items[$e->item_id] = $field_data[$langcode];
+                $new_items[$e->item_id] = $field_data[$langcode];
               }
             }
           }
         }
-        // Otherwise, unset the instance value, since the field colletion entity does not exist.
+        // Otherwise, unset the instance value, since the field colletion entity
+        // does not exist.
         else {
-          unset($items[$id][$delta]);
+          unset($new_items[$id][$delta]);
           $rekey = TRUE;
         }
       }
 
       if ($rekey) {
         // Rekey the items array.
-        $items[$id] = array_values($items[$id]);
+        $new_items[$id] = array_values($new_items[$id]);
       }
     }
-
-    field_collection_entity_preload($new_entities, $langcode, $items, $fields);
+    field_collection_entity_preload($new_entities, $langcode, $new_items, $fields);
   }
 }
 
@@ -1013,7 +1050,7 @@ function field_collection_field_formatter_view($entity_type, $entity, $field, $i
           $output = l($field_collection->label(), $field_collection->path());
           $links = array();
           foreach (field_collection_get_operations($settings) as $op => $label) {
-            if ($settings[$op] && entity_access($op == 'edit' ? 'update' : $op, 'field_collection_item', $field_collection)) {
+            if ($settings[$op] && entity_access($op === 'edit' ? 'update' : $op, 'field_collection_item', $field_collection)) {
               $title = entity_i18n_string("field:{$field['field_name']}:{$instance['bundle']}:setting_$op", $settings[$op]);
               $links[] = l($title, $field_collection->path() . '/' . $op, array('query' => drupal_get_destination()));
             }
@@ -1053,7 +1090,7 @@ function field_collection_field_formatter_view($entity_type, $entity, $field, $i
           );
           $links['#attributes']['class'][] = 'field-collection-view-links';
           foreach (field_collection_get_operations($settings) as $op => $label) {
-            if ($settings[$op] && entity_access($op == 'edit' ? 'update' : $op, 'field_collection_item', $field_collection)) {
+            if ($settings[$op] && entity_access($op === 'edit' ? 'update' : $op, 'field_collection_item', $field_collection)) {
               $links['#links'][$op] = array(
                 'title' => entity_i18n_string("field:{$field['field_name']}:{$instance['bundle']}:setting_$op", $settings[$op]),
                 'href' => $field_collection->path() . '/' . $op,
@@ -1124,14 +1161,15 @@ function field_collection_field_formatter_links(&$element, $entity_type, $entity
       $path = field_collection_field_get_path($field);
       list($id) = entity_extract_ids($entity_type, $entity);
       $element['#suffix'] = '';
-      if ($entity_type != 'node' && !empty($settings['description'])) {
+      if ($entity_type !== 'node' && !empty($settings['description'])) {
         $element['#suffix'] .= '<div class="description field-collection-description">' . field_filter_xss($instance['description']) . '</div>';
       }
       $title = entity_i18n_string("field:{$field['field_name']}:{$instance['bundle']}:setting_add", $settings['add']);
       $add_path = $path . '/add/' . $entity_type . '/' . $id;
-      $element['#suffix'] .= '<ul class="action-links action-links-field-collection-add"><li>';
-      $element['#suffix'] .= l($title, $add_path, array('query' => drupal_get_destination()));
-      $element['#suffix'] .= '</li></ul>';
+      $element['#suffix'] .=
+        '<ul class="action-links action-links-field-collection-add"><li>' .
+        l($title, $add_path, array('query' => drupal_get_destination())) .
+        '</li></ul>';
     }
   }
   // If there is no add link, add a special class to the last item.
@@ -1268,7 +1306,7 @@ function field_collection_field_widget_form(&$form, &$form_state, $field, $insta
         if (!isset($field_collection_item->entity_translation_handler_id)) {
           list($id, $revision_id) = entity_extract_ids('field_collection_item', $field_collection_item);
           $revision_id = isset($revision_id) ? $revision_id : 0;
-          $field_collection_item->entity_translation_handler_id = 'field_collection_item' . '-' . (!empty($id) ? 'eid-' . $id . '-' . $revision_id : 'new-' . rand());
+          $field_collection_item->entity_translation_handler_id = 'field_collection_item' . '-' . (!empty($id) ? 'eid-' . $id . '-' . $revision_id : 'new-' . mt_rand());
         }
         $element['#field_collection_item'] = $field_collection_item;
         field_collection_add_child_translation_handler($element);
@@ -1283,7 +1321,7 @@ function field_collection_field_widget_form(&$form, &$form_state, $field, $insta
         }
       }
 
-      // Add the subform
+      // Add the subform.
       field_form_set_state($field_parents, $field_name, $language, $form_state, $field_state);
       // Set the language to to parent entity language, because
       // field_content_languages() will always set $language to LANGUAGE_NONE.
@@ -1339,15 +1377,15 @@ function field_collection_field_widget_form(&$form, &$form_state, $field, $insta
         $item_id = isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL;
         $revision_id = isset($items[$delta]['revision_id']) ? $items[$delta]['revision_id'] : NULL;
 
-        // add a label component to visually identify this field collection item
+        // Add a label component to visually identify this field collection item.
         $element['label'] = array();
         if ($item_id) {
           $item = field_collection_item_load($item_id);
           $element['label']['#markup'] = $item ? $item->label() : $item_id;
         }
 
-        // the field stored value (item_id) and revision_id values
-        // so we need hidden fields to represent them
+        // The field stored value (item_id) and revision_id values so we need
+        // hidden fields to represent them.
         $element['value'] = array(
           '#type' => 'hidden',
           '#default_value' => $item_id,
@@ -1381,7 +1419,7 @@ function field_collection_field_widget_form(&$form, &$form_state, $field, $insta
           '#title' => check_plain($instance['label']),
           '#required' => FALSE,
           '#description' => field_filter_xss($instance['description']),
-          '#max_delta' => $count-1,
+          '#max_delta' => $count - 1,
         );
       }
 
@@ -1390,7 +1428,7 @@ function field_collection_field_widget_form(&$form, &$form_state, $field, $insta
 }
 
 /**
- * Implements hook_entity_translation_source_field_state_alter()
+ * Implements hook_entity_translation_source_field_state_alter().
  */
 function field_collection_entity_translation_source_field_state_alter(&$field_state) {
   if (isset($field_state['entity'])) {
@@ -1429,19 +1467,22 @@ function field_collection_field_attach_form($entity_type, $entity, &$form, &$for
         && field_access('edit', $field, $entity_type)) {
 
       $element_langcode = $form[$field_name]['#language'];
-      if ($form[$field_name][$element_langcode]['#max_delta'] > 0) {
+      if (!empty($form[$field_name][$element_langcode]['#max_delta']) && $form[$field_name][$element_langcode]['#max_delta'] > 0) {
         $form[$field_name][$element_langcode]['#max_delta']--;
       }
       // Remove blank form elements and force user to explicitly add a field
       // collection if both 'hide_initial_item' and 'hide_blank_items' are TRUE.
       if ($field['settings']['hide_initial_item']
         && $field['settings']['hide_blank_items']
+        && !empty($form[$field_name][$element_langcode][0]['#entity'])
         && $form[$field_name][$element_langcode][0]['#entity'] instanceof FieldCollectionItemEntity
         && field_collection_item_is_empty($form[$field_name][$element_langcode][0]['#entity'])) {
 
         _field_collection_process_children_attached($form[$field_name][$element_langcode][0]);
-        unset($form[$field_name][$element_langcode][0]);
-        unset($form_state['field']['#parents'][$field_name][$element_langcode][0]);
+        unset(
+          $form[$field_name][$element_langcode][0],
+          $form_state['field']['#parents'][$field_name][$element_langcode][0]
+        );
       }
     }
 
@@ -1580,7 +1621,7 @@ function field_collection_remove_submit($form, &$form_state) {
   }
 
   // Replace the deleted entity with an empty one. This helps to ensure that
-  // trying to add a new entity won't ressurect a deleted entity from the
+  // trying to add a new entity won't resurrect a deleted entity from the
   // trash bin.
   $count = count($field_state['entity']);
   $field_state['entity'][$count] = entity_create('field_collection_item', array('field_name' => $field_name));
@@ -1600,7 +1641,7 @@ function field_collection_remove_submit($form, &$form_state) {
   // the 3, the order of the two 3s now is undefined and may not match what
   // the user had selected.
   $input = drupal_array_get_nested_value($form_state['input'], $values_address);
-  // Sort by weight
+  // Sort by weight.
   uasort($input, '_field_sort_items_helper');
 
   // Reweight everything in the correct order.
@@ -1740,7 +1781,7 @@ function field_collection_field_widget_embed_validate($element, &$form_state, $c
         $is_empty_multiple = $is_countable && (!count($elements['#value']));
         $is_empty_string = (is_string($elements['#value']) && drupal_strlen(trim($elements['#value'])) == 0);
         $is_empty_value = ($elements['#value'] === 0);
-        $is_empty_option = (isset($elements['#options']['_none']) && $elements['#value'] == '_none');
+        $is_empty_option = (isset($elements['#options']['_none']) && $elements['#value'] === '_none');
 
         // Validate fields with hook_field_is_empty. This will handle cases when
         // file entity passes validation when it shouldn't.
@@ -1808,7 +1849,7 @@ function field_collection_field_widget_embed_validate($element, &$form_state, $c
  * Implements hook_field_create_field().
  */
 function field_collection_field_create_field($field) {
-  if ($field['type'] == 'field_collection') {
+  if ($field['type'] === 'field_collection') {
     field_attach_create_bundle('field_collection_item', $field['field_name']);
 
     // Clear caches.
@@ -1824,7 +1865,7 @@ function field_collection_field_create_field($field) {
  * Implements hook_field_delete_field().
  */
 function field_collection_field_delete_field($field) {
-  if ($field['type'] == 'field_collection') {
+  if ($field['type'] === 'field_collection') {
     // Notify field.module that field collection was deleted.
     field_attach_delete_bundle('field_collection_item', $field['field_name']);
 
@@ -1841,14 +1882,19 @@ function field_collection_field_delete_field($field) {
  * Implements hook_i18n_string_list_{textgroup}_alter().
  */
 function field_collection_i18n_string_list_field_alter(&$properties, $type, $instance) {
-  if ($type == 'field_instance') {
+  if ($type === 'field_instance') {
     $field = field_info_field($instance['field_name']);
 
-    if ($field['type'] == 'field_collection' && !empty($instance['display'])) {
+    if ($field['type'] === 'field_collection' && !empty($instance['display'])) {
 
       foreach ($instance['display'] as $view_mode => $display) {
-        if ($display['type'] != 'field_collection_fields') {
-          $display['settings'] += array('edit' => 'edit', 'translate' => 'translate', 'delete' => 'delete', 'add' => 'add');
+        if ($display['type'] !== 'field_collection_fields') {
+          $display['settings'] += array(
+            'edit' => 'edit',
+            'translate' => 'translate',
+            'delete' => 'delete',
+            'add' => 'add',
+          );
 
           $properties['field'][$instance['field_name']][$instance['bundle']]['setting_edit'] = array(
             'title' => t('Edit link title'),
@@ -1896,7 +1942,7 @@ function field_collection_features_pipe_field_alter(&$pipe, $data, $export) {
   if (!function_exists('field_instance_features_export_options')) {
     // Add the fields of the field collection entity to the pipe.
     foreach ($data as $identifier) {
-      if (($field = features_field_load($identifier)) && $field['field_config']['type'] == 'field_collection') {
+      if (($field = features_field_load($identifier)) && $field['field_config']['type'] === 'field_collection') {
         $fields = field_info_instances('field_collection_item', $field['field_config']['field_name']);
         foreach ($fields as $name => $field) {
           $pipe['field'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
@@ -1914,7 +1960,7 @@ function field_collection_features_pipe_field_alter(&$pipe, $data, $export) {
 function field_collection_features_pipe_field_instance_alter(&$pipe, $data, $export) {
   // Add the fields of the field collection entity to the pipe.
   foreach ($data as $identifier) {
-    if (($field = features_field_load($identifier)) && $field['field_config']['type'] == 'field_collection') {
+    if (($field = features_field_load($identifier)) && $field['field_config']['type'] === 'field_collection') {
       $fields = field_info_instances('field_collection_item', $field['field_config']['field_name']);
       foreach ($fields as $name => $field) {
         $pipe['field_instance'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
@@ -1968,7 +2014,7 @@ function field_collection_item_get_host_entity($item) {
  */
 function field_collection_item_get_specific_type_host_entity($item, array $options, $name) {
   // These properties' machine names have the form "host_entity_TYPE".
-  if (substr($name, 0, 12) !== 'host_entity_') {
+  if (strpos($name, 'host_entity_') !== 0) {
     return NULL;
   }
   return $item->hostEntityType() === substr($name, 12) ? $item->hostEntity() : NULL;
@@ -2085,7 +2131,7 @@ function field_collection_entity_translation_delete($entity_type, $entity, $lang
       $field_name = $instance['field_name'];
       $field = field_info_field($field_name);
 
-      if ($field['type'] == 'field_collection') {
+      if ($field['type'] === 'field_collection') {
         $field_langcode = field_is_translatable($entity_type, $field) ? $langcode : LANGUAGE_NONE;
 
         if (!empty($entity->{$field_name}[$field_langcode])) {
@@ -2134,33 +2180,34 @@ function field_collection_admin_menu_map() {
 }
 
 /**
- * implements hook_entity_translation_insert
+ * Implements hook_entity_translation_insert().
  */
 function field_collection_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
-  // Check if some of the values inserted are of a field_collection field
+  // Check if some of the values inserted are of a field_collection field.
   if (!empty($values)) {
     foreach ($values as $field_name => $value) {
       $field = field_info_field($field_name);
 
-      if ($field['type'] == 'field_collection') {
-        // We have found a field collection
+      if ($field['type'] === 'field_collection') {
+        // We have found a field collection.
         $language = $translation['language'];
         $source_language = $translation['source'];
 
         if (!empty($value[$language])) {
           $source_items = !empty($entity->{$field_name}[$source_language]) ? field_collection_field_item_to_ids($entity->{$field_name}[$source_language]) : array();
           foreach ($value[$language] as $delta => $field_value) {
-            // Check if this field collection item belongs to the source language
+            // Check if this field collection item belongs to the source language.
             if (!isset($field_value['entity'])
               && ($fc_entity = field_collection_field_get_entity($field_value))
-              && in_array($fc_entity->item_id, $source_items)) {
-              // Clone the field collection item
+              && in_array($fc_entity->item_id, $source_items)
+            ) {
+              // Clone the field collection item.
               $new_fc_entity = clone $fc_entity;
               $new_fc_entity->item_id = NULL;
               $new_fc_entity->revision_id = NULL;
               $new_fc_entity->is_new = TRUE;
 
-              // Set the new entity for saving it later
+              // Set the new entity for saving it later.
               $entity->{$field_name}[$language][$delta]['entity'] = $new_fc_entity;
             }
           }
@@ -2172,7 +2219,7 @@ function field_collection_entity_translation_insert($entity_type, $entity, $tran
 
 
 /**
- * Implements hook_feeds_processor_targets_alter()
+ * Implements hook_feeds_processor_targets_alter().
  */
 function field_collection_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
 
@@ -2192,7 +2239,7 @@ function field_collection_feeds_processor_targets_alter(&$targets, $entity_type,
 
   foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
     $info = field_info_field($name);
-    if ($info['type'] == 'field_collection') {
+    if ($info['type'] === 'field_collection') {
 
       $sub_type = 'field_collection_item';
       $new_targets = module_invoke_all('feeds_processor_targets', $sub_type, $info['field_name']);
@@ -2255,7 +2302,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
     while (isset($value[$delta])) {
 
       // Zero out.
-      $field_collection_item = null;
+      $field_collection_item = NULL;
 
       // FC is already set on host entity.
       if (isset($field[LANGUAGE_NONE][$delta]['entity'])) {
@@ -2266,7 +2313,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
         $field_collection_item = field_collection_item_load($field[LANGUAGE_NONE][$delta]['value']);
 
         // Zero out field so that we don't just keep accumulating values.
-        unset($field_collection_item->{$sub_target}[LANGUAGE_NONE] );
+        unset($field_collection_item->{$sub_target}[LANGUAGE_NONE]);
       }
 
       // Host entity does not have any attached FCs yet.
@@ -2279,7 +2326,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
       $config = $source->importer()->getConfig();
       if (!empty($config['processor']['config']['mappings'])) {
         foreach ($config['processor']['config']['mappings'] as $mapping) {
-          if ($mapping['target'] == $target . ':' . $sub_target) {
+          if ($mapping['target'] === $target . ':' . $sub_target) {
             $sub_mapping = $mapping;
             $sub_mapping['target'] = $sub_target;
             // Needs language or feeds mappers shout php notices.
@@ -2292,7 +2339,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
       if (isset($_sub_targets[$sub_target]['callback']) && function_exists($_sub_targets[$sub_target]['callback'])) {
         $callback = $_sub_targets[$sub_target]['callback'];
 
-        // Normalize
+        // Normalize.
         if (!is_array($value[$delta])) {
           $value[$delta] = array($value[$delta]);
         }
@@ -2303,7 +2350,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
         }
 
         // HiJack the file callback so we can make it work.
-        if ($callback == 'file_feeds_set_target') {
+        if ($callback === 'file_feeds_set_target') {
           $callback = 'field_collection_file_feeds_set_target';
         }
 
@@ -2393,8 +2440,9 @@ function field_collection_file_feeds_set_target($source, $entity, $target, $valu
       watchdog('feeds', check_plain($e->getMessage()));
     }
     if ($file) {
-      $field[LANGUAGE_NONE][$i] = (array)$file;
-      $field[LANGUAGE_NONE][$i]['display'] = 1; // @todo: Figure out how to properly populate this field.
+      $field[LANGUAGE_NONE][$i] = (array) $file;
+      // @todo: Figure out how to properly populate this field.
+      $field[LANGUAGE_NONE][$i]['display'] = 1;
       if ($info['cardinality'] == 1) {
         break;
       }
@@ -2405,9 +2453,9 @@ function field_collection_file_feeds_set_target($source, $entity, $target, $valu
 
 }
 
-
 /**
  * Implementation of hook_feeds_presave().
+ *
  * Invoked before a feed item is saved.
  *
  * @param FeedsSource $source
@@ -2436,7 +2484,7 @@ function field_collection_feeds_presave(FeedsSource $source, $entity, $item, $en
         $info = field_info_field($fc_name);
 
         // If the field is not a field collection, skip it.
-        if ($info['type'] != 'field_collection') {
+        if ($info['type'] !== 'field_collection') {
           continue;
         }
 
@@ -2454,4 +2502,3 @@ function field_collection_feeds_presave(FeedsSource $source, $entity, $item, $en
     }
   }
 }
-
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.pages.inc b/drupal7/sites/all/modules/field_collection/field_collection.pages.inc
index 1d3a5a20..143b3b63 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.pages.inc
+++ b/drupal7/sites/all/modules/field_collection/field_collection.pages.inc
@@ -86,7 +86,7 @@ function field_collection_item_delete_confirm($form, &$form_state, $field_collec
  */
 function field_collection_item_delete_confirm_submit($form, &$form_state) {
   $field_collection_item = $form_state['field_collection_item'];
-  entity_delete('field_collection_item',$field_collection_item->item_id);
+  entity_delete('field_collection_item', $field_collection_item->item_id);
   drupal_set_message(t('%label has been deleted.', array('%label' => drupal_ucfirst($field_collection_item->label()))));
   $form_state['redirect'] = '<front>';
 }
@@ -118,8 +118,7 @@ function field_collection_item_add($field_name, $entity_type, $entity_id, $revis
   $langcode = !empty($field['translatable']) ? entity_language($entity_type, $entity) : LANGUAGE_NONE;
 
   if (!($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || !isset($entity->{$field_name}[$langcode]) || count($entity->{$field_name}[$langcode]) < $field['cardinality'])) {
-    drupal_set_message(t('Too many items.'), 'error');
-    return '';
+    return MENU_ACCESS_DENIED;
   }
 
   $field_collection_item = entity_create('field_collection_item', array('field_name' => $field_name));
@@ -130,7 +129,7 @@ function field_collection_item_add($field_name, $entity_type, $entity_id, $revis
   $field_collection_item->setHostEntity($entity_type, $entity, $langcode, FALSE);
 
   $label = $field_collection_item->translatedInstanceLabel();
-  $title = ($field['cardinality'] == 1) ? $label : t('Add new !instance_label', array('!instance_label' => $label));
+  $title = $field['cardinality'] == 1 ? $label : t('Add new !instance_label', array('!instance_label' => $label));
   drupal_set_title($title);
 
   // Make sure the current user has access to create a field collection item.
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.pathauto.inc b/drupal7/sites/all/modules/field_collection/field_collection.pathauto.inc
new file mode 100644
index 00000000..01a009b6
--- /dev/null
+++ b/drupal7/sites/all/modules/field_collection/field_collection.pathauto.inc
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Implements hook_pathauto().
+ */
+function field_collection_pathauto($op) {
+  if ('settings' === $op) {
+    $settings = array();
+    $settings['module'] = 'field_collection';
+    $settings['token_type'] = 'field_collection_item';
+    $settings['groupheader'] = t('Field collection item paths');
+    $settings['patterndescr'] = t('Default path pattern (applies to all field collections with blank patterns below)');
+    $settings['patterndefault'] = '';
+    // @todo Implement bulk update:
+    // $settings['batch_update_callback'] = 'field_collection_pathauto_bulk_update_batch_process';
+    // $settings['batch_file'] = drupal_get_path('module', 'field_collection') . '/field_collection.pathauto.inc';
+
+    $settings['patternitems'] = array();
+    $instances = field_info_instances();
+    foreach ($instances as $entity_type => $type_bundles) {
+      foreach ($type_bundles as $bundle => $bundle_instances) {
+        foreach ($bundle_instances as $field_name => $instance) {
+          $field = field_info_field($field_name);
+          if ($field['type'] === 'field_collection') {
+            // @todo We may need different patterns depending on the.
+            // host entity type or the host bundle. If so we need to prefix
+            // field-name with $entity_type . '_' . $bundle . '_' and also need
+            // to implement our own version of pathauto_pattern_load_by_entity()
+            // searching for the best matching pattern.
+            $settings['patternitems'][$field_name] = t('Pattern for all field collection @field-collection paths', array('@field-collection' => $field_name));
+          }
+        }
+      }
+    }
+
+    return (object) $settings;
+  }
+}
+
+/**
+ * Create a path alias for a field collection item.
+ *
+ * @param object $host_entity
+ *   Entity to which the field collection item belongs.
+ * @param object $entity
+ *   Field collection item.
+ * @param string $op
+ *   Operation to perform for pathauto_create_alias(). Can be 'insert', 'update', 'return', or 'bulkupdate'.
+ *
+ * @see field_collection_field_update()
+ */
+function field_collection_pathauto_create_alias($host_entity, $entity, $op, $options = array()) {
+  module_load_include('inc', 'pathauto');
+
+  pathauto_create_alias('field_collection', $op, 'field-collection/' . str_replace('_', '-', $entity->field_name) . '/' . $entity->item_id, array('field_collection_item' => $entity), $entity->field_name);
+}
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.test b/drupal7/sites/all/modules/field_collection/field_collection.test
index 82b311b6..66854ee9 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.test
+++ b/drupal7/sites/all/modules/field_collection/field_collection.test
@@ -35,9 +35,9 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
       'field_name' => $this->field_name,
       'entity_type' => 'node',
       'bundle' => 'article',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
-      'weight' => mt_rand(0, 127),
+      'label' => self::randomName() . '_label',
+      'description' => self::randomName() . '_description',
+      'weight' => random_int(0, 127),
       'settings' => array(),
       'widget' => array(
         'type' => 'hidden',
@@ -340,13 +340,13 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
     $this->drupalGet($path);
     $this->assertText(t('Test text field'), 'Add form is shown.');
 
-    $edit['field_text[und][0][value]'] = $this->randomName();
+    $edit['field_text[und][0][value]'] = self::randomName();
     $this->drupalPost($path, $edit, t('Save'));
     $this->assertText(t('The changes have been saved.'), 'Field collection saved.');
 
     $this->assertText($edit['field_text[und][0][value]'], 'Added field value is shown.');
 
-    $edit['field_text[und][0][value]'] = $this->randomName();
+    $edit['field_text[und][0][value]'] = self::randomName();
     $this->drupalPost('field-collection/field-test-collection/1/edit', $edit, t('Save'));
     $this->assertText(t('The changes have been saved.'), 'Field collection saved.');
     $this->assertText($edit['field_text[und][0][value]'], 'Field collection has been edited.');
@@ -361,7 +361,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
     // Make sure adding doesn't work any more as we have restricted cardinality
     // to 1.
     $this->drupalGet($path);
-    $this->assertText(t('Too many items.'), 'Maxium cardinality has been reached.');
+    $this->assertResponse(403);
 
     $this->drupalPost('field-collection/field-test-collection/1/delete', array(), t('Delete'));
     $this->drupalGet($path);
@@ -457,9 +457,9 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
       'field_name' => $this->field_name,
       'entity_type' => 'node',
       'bundle' => 'article',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
-      'weight' => mt_rand(0, 127),
+      'label' => self::randomName() . '_label',
+      'description' => self::randomName() . '_description',
+      'weight' => random_int(0, 127),
       'settings' => array(),
       'widget' => array(
         'type' => 'hidden',
@@ -572,9 +572,9 @@ class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
       'field_name' => $this->field_name,
       'entity_type' => 'node',
       'bundle' => 'article',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
-      'weight' => mt_rand(0, 127),
+      'label' => self::randomName() . '_label',
+      'description' => self::randomName() . '_description',
+      'weight' => random_int(0, 127),
       'settings' => array(),
       'widget' => array(
         'type' => 'field_collection_embed',
@@ -618,11 +618,11 @@ class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
    */
   public function testContentTranslation() {
     // Create "Article" content.
-    $edit['title'] = $this->randomName();
-    $edit['body[' . LANGUAGE_NONE . '][0][value]'] = $this->randomName();
+    $edit['title'] = self::randomName();
+    $edit['body[' . LANGUAGE_NONE . '][0][value]'] = self::randomName();
     $edit['language'] = 'en';
     $field_collection_name = 'field_test_collection[' . LANGUAGE_NONE . '][0][field_text][' . LANGUAGE_NONE . '][0][value]';
-    $edit[$field_collection_name] = $this->randomName();
+    $edit[$field_collection_name] = self::randomName();
 
     $this->drupalPost('node/add/article', $edit, t('Save'));
     $this->assertRaw(t('Article %title has been created.', array('%title' => $edit['title'])), 'Article created.');
@@ -787,9 +787,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
       'field_name' => $this->field_name,
       'entity_type' => 'node',
       'bundle' => 'page',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
-      'weight' => mt_rand(0, 127),
+      'label' => self::randomName() . '_label',
+      'description' => self::randomName() . '_description',
+      'weight' => random_int(0, 127),
       'settings' => array(),
       'widget' => array(
         'type' => 'field_collection_embed',
@@ -864,7 +864,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
       $num_values = self::NUM_VALUES;
     }
 
-    $title = $this->randomName();
+    $title = self::randomName();
 
     $this->drupalGet('node/add/page');
 
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.theme.css b/drupal7/sites/all/modules/field_collection/field_collection.theme.css
index 2060e20b..81627c4a 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.theme.css
+++ b/drupal7/sites/all/modules/field_collection/field_collection.theme.css
@@ -1,7 +1,7 @@
 @charset "UTF-8";
 
 .field-collection-container {
-  border-bottom: 1px solid #D3D7D9;
+  border-bottom: 1px solid #d3d7d9;
   margin-bottom: 1em;
 }
 
@@ -16,7 +16,7 @@
 .field-collection-view {
   padding: 1em 0 0.3em 0;
   margin: 0 1em 0 1em;
-  border-bottom: 1px dotted #D3D7D9;
+  border-bottom: 1px dotted #d3d7d9;
 }
 
 /* If there is no add link, don't show the final border. */
diff --git a/drupal7/sites/all/modules/field_collection/field_collection.tokens.inc b/drupal7/sites/all/modules/field_collection/field_collection.tokens.inc
index 96912953..fecdbaa2 100644
--- a/drupal7/sites/all/modules/field_collection/field_collection.tokens.inc
+++ b/drupal7/sites/all/modules/field_collection/field_collection.tokens.inc
@@ -66,7 +66,6 @@ function field_collection_token_info_alter(&$data) {
   );
 }
 
-
 /**
  * Implements hook_tokens().
  */
@@ -75,7 +74,7 @@ function field_collection_tokens($type, $tokens, array $data = array(), array $o
 
   // Provide a complete set of tokens for type == 'host', and a supplementary
   // token 'host' for type == 'field_collection_item'.
-  if (($type == 'field_collection_item' or $type == 'host') and !empty($data['field_collection_item'])) {
+  if (($type === 'field_collection_item' || $type === 'host') && !empty($data['field_collection_item'])) {
     $collection = $data['field_collection_item'];
     // When saving revisions, only $collection->original has valid state about
     // its host entity.
@@ -83,7 +82,7 @@ function field_collection_tokens($type, $tokens, array $data = array(), array $o
       $collection = $collection->original;
     }
 
-    if ($type == 'field_collection_item') {
+    if ($type === 'field_collection_item') {
       if (!empty($tokens['host'])) {
         $replacements[$tokens['host']] = $collection->hostEntityId();
       }
diff --git a/drupal7/sites/all/modules/field_collection/views/field_collection_handler_relationship.inc b/drupal7/sites/all/modules/field_collection/views/field_collection_handler_relationship.inc
index 7f4ed145..76839ecf 100644
--- a/drupal7/sites/all/modules/field_collection/views/field_collection_handler_relationship.inc
+++ b/drupal7/sites/all/modules/field_collection/views/field_collection_handler_relationship.inc
@@ -4,6 +4,7 @@
  * @file
  * Provide relationship handler for field collection fields.
  */
+
 class field_collection_handler_relationship extends views_handler_relationship {
 
   function option_definition() {
diff --git a/drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc b/drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc
index b6362157..0d4a4ee2 100644
--- a/drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc
+++ b/drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc
@@ -111,15 +111,25 @@ class MediaInternetYouTubeHandler extends MediaInternetBaseHandler {
     $uri = file_stream_wrapper_uri_normalize('youtube://' . $type . '/' . check_plain($id));
     $external_url = file_create_url($uri);
     $oembed_url = url('https://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
-    $response = drupal_http_request($oembed_url, array('method' => 'HEAD'));
+    $response = drupal_http_request($oembed_url);
 
-    if ($response->code == 401) {
-      throw new MediaInternetValidationException('Embedding has been disabled for this YouTube video.');
+    if (!isset($response->error)) {
+      $data = drupal_json_decode($response->data);
+      if (!empty($data)) {
+        return TRUE;
+      }
+      else {
+        $error_data = t('Unspecific');
+        if (is_string($response->data)) {
+          $error_data = $response->data;
+        }
+        throw new MediaInternetValidationException("The YouTube video ID is invalid, video was deleted or is disabled for embedding. Error: {$error_data}");
+        return;
+      }
     }
-    elseif ($response->code != 200) {
-      throw new MediaInternetValidationException('The YouTube video ID is invalid or the video was deleted.');
+    else {
+      throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
+      return;
     }
-
-    return TRUE;
   }
 }
diff --git a/drupal7/sites/all/modules/media_youtube/media_youtube.info b/drupal7/sites/all/modules/media_youtube/media_youtube.info
index 4318215e..cf360f76 100644
--- a/drupal7/sites/all/modules/media_youtube/media_youtube.info
+++ b/drupal7/sites/all/modules/media_youtube/media_youtube.info
@@ -11,8 +11,8 @@ files[] = media_youtube.test
 files[] = includes/MediaYouTubeStreamWrapper.inc
 files[] = includes/MediaInternetYouTubeHandler.inc
 
-; Information added by Drupal.org packaging script on 2019-10-03
-version = "7.x-3.9"
+; Information added by Drupal.org packaging script on 2020-12-28
+version = "7.x-3.10"
 core = "7.x"
 project = "media_youtube"
-datestamp = "1570113188"
+datestamp = "1609172349"
diff --git a/drupal7/sites/all/modules/media_youtube/tests/media_youtube_test.info b/drupal7/sites/all/modules/media_youtube/tests/media_youtube_test.info
index dcd8d97a..4ff37ce2 100644
--- a/drupal7/sites/all/modules/media_youtube/tests/media_youtube_test.info
+++ b/drupal7/sites/all/modules/media_youtube/tests/media_youtube_test.info
@@ -8,8 +8,8 @@ hidden = TRUE
 files[] = includes/MediaYouTubeTestStreamWrapper.inc
 files[] = includes/MediaYouTubeTestHandler.inc
 
-; Information added by Drupal.org packaging script on 2019-10-03
-version = "7.x-3.9"
+; Information added by Drupal.org packaging script on 2020-12-28
+version = "7.x-3.10"
 core = "7.x"
 project = "media_youtube"
-datestamp = "1570113188"
+datestamp = "1609172349"
