diff --git a/metatag.module b/metatag.module index 4d38c52..7c0bb1c 100644 --- a/metatag.module +++ b/metatag.module @@ -671,6 +671,11 @@ function metatag_entity_insert($entity, $entity_type) { return; } + // Support for the Deploy module. + if (_metatag_isdeployed($entity, $entity_type, $entity_id, $revision_id)) { + return; + } + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $langcode); } } @@ -707,6 +712,11 @@ function metatag_entity_update($entity, $entity_type) { } } + // Support for the Deploy module. + if (_metatag_isdeployed($entity, $entity_type, $entity_id, $revision_id)) { + return; + } + // Support for Workbench Moderation v1. if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { return; @@ -2028,6 +2038,44 @@ function _metatag_isdefaultrevision($entity) { } /** + * Checks if this entity is the byproduct of a deployment. + * + * If this is a deployment $entity->metatags[$lang->language] + * will already be populated for all defined languages using + * Entity Translation. + * + * @param object $entity + * The entity object, e.g., $node. + * + * @return bool + * TRUE if the entity is being used as part of a deployment, FALSE otherwise. + */ +function _metatag_isdeployed($entity, $entity_type, $entity_id, $revision_id) { + $was_deployed = FALSE; + if (module_exists('deploy')) { + $languages = language_list('enabled'); + foreach ($languages[1] as $lang) { + if (isset($entity->metatags[$lang->language])) { + // Save the record. + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags[$lang->language], $lang->language, $entity->old_vid); + $was_deployed = TRUE; + } + } + } + else if (module_exists('services')) { + $languages = language_list('enabled'); + foreach ($languages[1] as $lang) { + if (isset($entity->metatags[$lang->language])) { + // Save the record. + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags[$lang->language], $lang->language); + $was_deployed = TRUE; + } + } + } + return $was_deployed; +} + +/** * Generate the cache ID to use with metatag_cache_get/metatag_cache_set calls. * * @param array $cid_parts