Over at #2215493: Services Entity API + Entity UUID Deploy/UUID compatibility is being discussed. One possible place to fix this is in uuid_services.module. It's a bit hacky, but it works well.

Since services_entity provides custom entity resources at my-endpoint/entity_<entitytype>/* this patch has to be used in conjunction with Services resource aliases to make the resource path match the entity type name which is what Deploy module expects. Resource aliases are entered in the textfields on the resource overview page (admin/structure/services/list/<endpoint>/resources).

Note: I might provide an alternative, more lightweight, solution to services_entity inside uuid_services instead. So there's no guarantee that this patch will get committed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dixon_’s picture

There might be a better/cleaner solution to this. But the patch attached in OP is a first working iteration at least.

dixon_’s picture

Issue summary: View changes
dixon_’s picture

Issue summary: View changes
joachim’s picture

> There might be a better/cleaner solution to this. But the patch attached in OP is a first working iteration at least.

What if we added a property to the resources definition to say what entity type it works with?

dixon_’s picture

Attached is a much simpler patch that adds optional Services integration for all entities with a UUID key, without the need for Service Entity module. This patch essentially makes that module obsolete.

@joachim I don't think an additional property is needed. In theory it should work with all entities that has UUID support. And in practice it have worked with the entity types I've tested with :)

Moving to @skwashd for a quick review before I commit this.

dixon_’s picture

Title: Alter non-standard Services resources (like those provided by services_entity module) » Provide optional support for all UUID entity types
jneubert’s picture

After applying the patch at #5, deployment of custom entities worked fine for me. However, when I edited the content on the source system and tried to re-deploy, I got a HTTP error:

DeployServiceException: Service error: 403 :Access denied for user admin in DeployServiceRest->httpRequest() (line 70 of /opt/drupal/sites/all/modules/deploy/includes/DeployServiceRest.inc).

The last request the source system tried to execute was a PUT request on a custom entity. Updates on different custom entity types failed, while updates on standard or quasi-standard types (such as user or file_entity) worked smoothly within the same deployment.

The 403 is reported in Apaches access_log. Watchdog on the target system does not report an error.

jneubert’s picture

The update operation in my custom entites' access callback were named "edit". After renaming them to "update", everything worked fine.

  • dixon_ committed 88bf7f1 on 7.x-1.x
    Issue #2241469 by dixon_: Added Provide optional support for all UUID...
dixon_’s picture

Status: Needs review » Fixed

I've committed my patch from #5.

Thanks @jneubert for testing and providing feedback!

Status: Fixed » Closed (fixed)

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

jimkeller’s picture

Status: Closed (fixed) » Needs work

I believe there's a problem with this patch due to the fact that the following line still exists in entity_get_id_by_uuid in uuid.entity.inc:

  if (empty($info['uuid'])) {
    return array();
  }

it doesn't matter whether you have the checkbox for all entities to use uuid checked; they won't be loaded in the services retrieve method if 'uuid' isn't set to true in the entity info, due to the line above. I was running into an issue where my uuid entities weren't being retrieved, and this was the reason why.

I'm not sure whether we still care about this or not since it should (theoretically) be trivial to ensure that the entities have $entity_info['uuid'] set to non-false, but I think this points to the previous patch being incomplete. Maybe it would be better to iterate over the entity info and explicitly set uuid to true, if the checkbox for "uuid on all entities" is checked?