AWESOME AND EASY :D, patch follows...
But _uuid_services_entity_access() is being a pain in the ass (again), the access callback for a field collection item is:
function field_collection_item_access($op, FieldCollectionItemEntity $item = NULL, $account = NULL) {
if (user_access('administer field collections', $account)) {
return TRUE;
}
if (!isset($item)) {
return FALSE;
}
$op = $op == 'view' ? 'view' : 'edit';
// Access is determined by the entity and field containing the reference.
$field = field_info_field($item->field_name);
$entity_access = entity_access($op == 'view' ? 'view' : 'update', $item->hostEntityType(), $item->hostEntity(), $account);
return $entity_access && field_access($op, $field, $item->hostEntityType(), $item->hostEntity(), $account);
}
It type hints FieldCollectionItemEntity and than everything explodes. When I comment that out and just return true (for testing purpose) the field_collection gets transfered.
Comments
Comment #1
aspilicious commentedHere it is
Comment #2
cracu commentedDoes not work for me :(.
But still... if I remove FieldCollectionItemEntity and force the function to return TRUE, it will transfer the field_collection as you said.
Do you have any news on this issue?
Comment #4
David_Rothstein commentedI'm not sure this patch actually belongs in Deploy... Normally, when deploying content you don't even need the Deploy module enabled on the target site, right (only on the source site)? But with the above patch you would need to.
Seems like it would be better off in either UUID or Field Collection itself. For now, I'm trying it in UUID because (a) that's the module where all the magic happens that allows the above patch to work even with 'field_collection_item' set to an empty array :), and (b) that allows us to fix the bug with _uuid_services_entity_access() described above, all in one patch.
With the attacehd patch applied, I was able to deploy field collections after (1) clearing caches, (2) enabling the field collection 'update' operation on the services endpoint of the target site, and (3) making sure the user I was using for content deployment had access to create field collections on the target site (easiest way is to give that user the 'administer field collections' permission).
The part of the patch that fixes the type hinting issue is this:
As far as I can tell, that's a reasonable thing to do for all entities, not just field collections (and UUID Services already depends on the Entity module anyway).
Without that change, you get this when deploying a field collection:
But with it, things seem to work fine.
Assuming that is the correct change, note that there's another line of code in UUID Services that seems like it would make sense to change in a similar way:
I didn't need it for this patch so I didn't do it, but it may make sense to do that either here or in a separate issue.
Comment #5
David_Rothstein commentedSorry, that patch was relative to the wrong directory. Try this one instead.
Comment #6
johnpitcairn commentedPatch does not apply using git apply -v for me. There's no output.
Patch applies using patch, from the uuid_services directory. But if using patch, when attempting to add field collections as a deployable resource at the endpoint, you'll get:
Fatal error: Call to undefined function _field_collection_resource_definition() in /Volumes/Opus Locus/Sites/_drupal7/sites/all/modules/contrib/uuid/uuid_services/uuid_services.module on line 219
Because the "resources" subdirectory is not being created, and the resource file is created at top level.
Comment #7
David_Rothstein commentedYou're right, I managed to create a patch from the wrong directory twice in a row. Third time's the charm (I hope)...
Comment #8
johnpitcairn commentedRe #6, with everything in the correct place, I can deploy nodes containing field collections. That's probably just saved me a couple of days on a site rebuild, massive thanks!
So if the patch in #7 applies, it's good...
Comment #9
Dean Reilly commentedI can confirm the patch works well and resolved the problem.
Comment #10
dixon_Thanks all for the work on this. I've carefully looked through this small and simple patch and I see no hurdles. It has a low impact on other things, so I've committed the patch from David in #7.
Thanks!
Comment #12
picardmyhero commentedI have a Source Server that is trying to deploy a photo_gallery content type which has a field_collection,
to a Destination Server. I applied the above patch:
uuid-services-field-collection-1504444-7.patch+
to both servers, but when I try to deploy the photo_gallery, I'm still getting:
a. Source Server Log error:
DeployServiceException: Service error: 404 Not found: Could not find resource field_collection_item. in DeployServiceRest->httpRequest() (line 70 of /data/timeinc/content/test.drupal-staging/drupal/sites/all/modules/deploy/includes/DeployServiceRest.inc).
b. Destination Server Log error:
Notice: Undefined index: source in RESTServer->checkNumberOfArguments() (line 681 of /data/timeinc/content/test.drupal-prod-nj2x/drupal/sites/all/modules/services/servers/rest_server/includes/RESTServer.inc).
After I applied the patches I cleared cache with drush.
Also, for this post above:
"enabling the field collection 'update' operation on the services endpoint of the target site"
on the Destination Server, for the endpoint, I do not see a field collection item. Should I?
I would appreciate any help anyone can provide for this issue.
Comment #13
timaholt commentedThis hasn't been updated in a while, but @picardmyhero this is caused by not enabling the field_collection in the services endpoint on the destination site. If you still have this error after confirming that is set correctly, let us know.
Comment #14
damok commentedI know this is a bit old now but I'm receiving the error 'Could not find resource field_collection_item' when attempting to deploy any nodes with field collections.
@timaholt: You mention enabling the field_collection in the services endpoint on the destination site, how would I achieve this? Is there an obvious setting I'm missing?
Comment #15
damok commentedI managed to get it working and it was something obvious, after clearing the cache on the destination site the field_collection_item showed in the services endpoint resources.
Comment #16
jeremygrajales commentedI had the same problem but had to resolve it by enabling "Support all UUID entity types" in /admin/config/services/uuid-services
Then, the field_collection_item resource was display in services.