Hi, We have been running into an issue with content deployment on a site with many entity relationships. When entity dependency runs through all the relationships we have seen cases where this can take 10 minutes + (up to an hour) to deploy the content and all it's related entities. We have added some code to our deployment faeture on the source side, which checks to see if the dependent content has been deployed. If it has it removes the dependency, stopping the "re-deployment" of all the related content. It only does this to content that has the field_shared_content field.

I was wondering if this has this been seen before?

I was thinking this could be a solution adopted by the distribution, possibly with a flag to enable or disable the deployment of related entities?

Here is the code we used:

/**
 * Implements hook_entity_dependencies_alter()
 * to only deploy dependencies that have not already been deployed
 */
function module_entity_dependencies_alter(&$dependencies, $entity, $type) {
  // cycle through the dependencies and check if they are deployed, if so remove them
  foreach ($dependencies as $index => $dependency) {
    // get the entity's bundle 
    $wrapper = entity_metadata_wrapper($dependency['type'], $dependency['id']);
    $bundle = $wrapper->getBundle();
    // only look at dependencies that have the shared_content field
    if (field_info_instance($dependency['type'], 'field_shared_content', $bundle)) {
      // build an efq to see if the dependency/content has been deployed
      $query = new EntityFieldQuery();
      $query->entityCondition('entity_type', $dependency['type'], '=');
      $query->entityCondition('entity_id', $dependency['id'], '=');
      $query->fieldCondition('field_shared_content', 'value', TRUE, '=');    
      // if it's a node it must be published
      if ($dependency['type'] == 'node') {
        $query->propertyCondition('status', 1);
      }
      // if the deploy to destination field exists, it must be checked/deployed
      if (field_info_instance($dependency['type'], 'field_deploy_to_destination_site', $bundle)) {
        $query->fieldCondition('field_deploy_to_destination_site', 'value', TRUE, '=');    
      }
      $result = $query->execute();
      // if the query returns that the content has been deployed remove the dependency
      if (isset($result[$dependency['type']]) && count($result[$dependency['type']]) == 1) {
        unset($dependencies[$index]);
      }
    }
  }
}

Comments

natew created an issue. See original summary.

sylus’s picture

Status: Active » Fixed

I have added a new form under wetkit_deployment_source calling this code if the toggle is checked. In the form I marked this as experimental and isn't enabled by default.

Committed and attributed.

Thx!

  • sylus committed 1bdfe45 on 7.x-4.x
    Fixed WetKit Deployment for Issue #2704741: Content Deployment...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lampson’s picture

I used this and it drastically improved deployment via shared content. I however wasn't able to find where to configure this. I looked at the commit and then set "drush wetkit_deployment_source_ed_perf 1" to turn this option on.

lampson’s picture

If anybody is wondering where to find this in the admin menu, it's under Wxt / Deployment Sources. Check "Enable the Entity Dependency Query Alteration for Performance"