There are some contrib entities without uuid support that leads to SQL errors

 SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS #012FROM #012crm_core_contact t#012WHERE  (contact_id IN  ('2816'))' at line 1: SELECT t.contact_id AS contact_id, t. AS #012FROM #012{crm_core_contact} t#012WHERE  (contact_id IN  (:db_condition_placeholder_0)) ; Array#012(#012    [:db_condition_placeholder_0] => 2816#012)#012 in entity_get_uuid_by_id() (line 476 of /var/www/sj-lou/sites/all/modules/contrib/uuid/uuid.entity.inc).

also this fix an error during uuid_update_7103

[error]
SQL syntax; check the manual that corresponds to your MySQL server version for the
right syntax to use near 'AS , t.nid AS nid
FROM 
node t
WHERE  ( IN  ('b0558664-c94b-3674-d9df-3e1696b2e4' at line 1
Performed update: uuid_update_7103

I have attached a patch for ability to skip them during conversion from references to uuid

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

podarok’s picture

Issue summary: View changes
dixon_’s picture

FileSize
905 bytes
+++ b/uuid.entity.inc
@@ -468,6 +468,11 @@ function entity_get_uuid_by_id($entity_type, $ids, $revision = FALSE) {
+  // Some contrib entities has no support for UUID, let's skip them.
+  // This means reference will be lost during conversion.
+  if ($uuid_key == NULL) {
+    return array();
+  }

Everywhere else in the UUID module we do the checks on $info['uuid'] so I think that would be better and more consistent.

I've also added the same check in entity_get_id_by_uuid().

@podarok If all tests still pass, and you think this looks good then I'll commit this soon.

Status: Needs review » Needs work

The last submitted patch, 2: 2356305-2.patch, failed testing.

podarok’s picture

We should't add check additionally. It is enouph to check it only once in the place, added by my patch

dixon_’s picture

Status: Needs work » Needs review
FileSize
891 bytes

We should't add check additionally. It is enouph to check it only once in the place, added by my patch

Yes, you might not see the problem in your setup. But the same problem still exist in entity_get_id_by_uuid().

I used the wrong variable name in the previous patch, here's a new one. The tests should come back green for this one...

dixon_’s picture

Assigned: Unassigned » skwashd

Passing to @skwashd for him to review.

skwashd’s picture

Assigned: skwashd » dixon_
Status: Needs review » Reviewed & tested by the community

Patch looks good to me.

skwashd’s picture

podarok’s picture

+1 RTBC

skwashd’s picture

Status: Reviewed & tested by the community » Fixed

This was committed by @dixon_ but he stuffed up the commit message so it didn't reference the issue. Closing.

Status: Fixed » Closed (fixed)

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