I've found a couple of issues with (almost) the same error message, but haven't found a solution. So I opened a new issue (hope thats ok?).

I'm using D7 with Drupal Commerce, every module up-to-date. When I add an action to an existing (Commerce) rule, I get this error message in the log:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, created, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 324 [:db_insert_placeholder_1] => 1378422251 [:db_insert_placeholder_2] => a:1:{s:20:"l10n_client_disabled";b:0;} ) in drupal_write_record() (regel 7166 van /drupal/includes/common.inc).

Export of the (standard) working rule is:

{ "commerce_checkout_new_account" : {
    "LABEL" : "Create a new account for an anonymous order",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "2",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "rules", "commerce", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:uid" ], "value" : "0" } },
      { "NOT entity_exists" : {
          "type" : "user",
          "property" : "mail",
          "value" : [ "commerce-order:mail" ]
        }
      },
      { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_name" : [ "commerce-order:mail-username" ],
            "param_mail" : [ "commerce-order:mail" ]
          },
          "PROVIDE" : { "entity_created" : { "account_created" : "Created account" } }
        }
      },
      { "data_set" : { "data" : [ "account-created:status" ], "value" : 1 } },
      { "entity_save" : { "data" : [ "account-created" ], "immediate" : 1 } },
      { "entity_query" : {
          "USING" : {
            "type" : "user",
            "property" : "mail",
            "value" : [ "commerce-order:mail" ],
            "limit" : 1
          },
          "PROVIDE" : { "entity_fetched" : { "account_fetched" : "Fetched account" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "account-fetched" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "send_account_email" : { "account" : [ "list-item" ], "email_type" : "register_admin_created" } },
            { "data_set" : { "data" : [ "commerce-order:uid" ], "value" : [ "list-item:uid" ] } },
            { "data_set" : {
                "data" : [ "commerce-order:commerce-customer-billing:uid" ],
                "value" : [ "list-item:uid" ]
              }
            },
            { "data_set" : {
                "data" : [ "commerce-order:commerce-customer-woonadres:uid" ],
                "value" : [ "list-item:uid" ]
              }
            }
          ]
        }
      }
    ]
  }
}

The changed (and not working) rule is:

{ "commerce_checkout_new_account" : {
    "LABEL" : "Create a new account for an anonymous order",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "2",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "rules", "commerce", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:uid" ], "value" : "0" } },
      { "NOT entity_exists" : {
          "type" : "user",
          "property" : "mail",
          "value" : [ "commerce-order:mail" ]
        }
      },
      { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_name" : [ "commerce-order:mail-username" ],
            "param_mail" : [ "commerce-order:mail" ]
          },
          "PROVIDE" : { "entity_created" : { "account_created" : "Created account" } }
        }
      },
      { "data_set" : { "data" : [ "account-created:status" ], "value" : 1 } },
      { "data_set" : {
          "data" : [ "account-created:roles" ],
          "value" : { "value" : { "4" : "4" } }
        }
      },
      { "entity_save" : { "data" : [ "account-created" ], "immediate" : 1 } },
      { "entity_query" : {
          "USING" : {
            "type" : "user",
            "property" : "mail",
            "value" : [ "commerce-order:mail" ],
            "limit" : 1
          },
          "PROVIDE" : { "entity_fetched" : { "account_fetched" : "Fetched account" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "account-fetched" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "send_account_email" : { "account" : [ "list-item" ], "email_type" : "register_admin_created" } },
            { "data_set" : { "data" : [ "commerce-order:uid" ], "value" : [ "list-item:uid" ] } },
            { "data_set" : {
                "data" : [ "commerce-order:commerce-customer-billing:uid" ],
                "value" : [ "list-item:uid" ]
              }
            },
            { "data_set" : {
                "data" : [ "commerce-order:commerce-customer-woonadres:uid" ],
                "value" : [ "list-item:uid" ]
              }
            }
          ]
        }
      }
    ]
  }
}

I hope someone can help?

Thanks,

Mike.

Comments

sportel’s picture

I forgot to tell something that might be important:

When I first made the change to the rule, it worked! I just recently noticed the error, and it's probably because of an updated module.

sportel’s picture

Update:

I've tried the latest dev version of Rules: same result.

I went back to the previous stable version (7.x-2.2): everything seems to work fine again!

So, something changed in the 7.x-2.3 release which makes the error occur.

I hope this helps the devs to fix this. If you need more info just let me know.

Mike.

dagomar’s picture

I have the same problem, but shouldnt this be a commerce issue?

Note that I am running Rules 2.5.

Edit> I just checked with version 2.2, and I still have this issue. Investigating!

dagomar’s picture

First of all, this is related: #2095811: Rules disappear in ui when adding them to features

There is some serious problem with rules that come from code.

I was able to fix this by disabling the rule causing this issue, and then cloning it and make the changes there. Seriously buggy!

{edit}

I forgot, I also had to change the rule to use the email as the login name! It's not asking for a user name...

dibyadel’s picture

i m facing this problem
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, name, pass, mail, theme, signature, signature_format, created, access, login, status, timezone, language, picture, init, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => 143 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => [:db_insert_placeholder_12] => [:db_insert_placeholder_13] => 0 [:db_insert_placeholder_14] => [:db_insert_placeholder_15] => a:2:{s:7:"contact";i:1;s:23:"geoip_location_original";a:2:{s:10:"ip_address";s:9:"127.0.0.1";s:9:"timestamp";i:1382151116;}} ) in drupal_write_record() (line 7136 of C:\wampserver\www\neeranchal111013\includes\common.inc).

Miguelos’s picture

I had the same problem. It was a problem with a contrib commerce module:
#2119743: Anonymous PDO exception when using payment tokens

It wasn't a rules problem: I've tried before different rules versions (2.2, 2.5 and latest dev).

The issue happens when the commerce module tries to complete the anonymous checkout.

fago’s picture

Status: Active » Closed (duplicate)
sportel’s picture

Status: Closed (duplicate) » Active

@fago: you are linking to this issue. And an issue is always related to itself.

fago’s picture

grml, sry - this keeps happening to me.

Here is one related issue, not sure it's exactly the same though? #1771666: Integrity constraint violation when saving a user account after creation
Else, please try searching the error in the queue - similar errors have been popping up already.

fago’s picture

Status: Active » Closed (duplicate)
ipwa’s picture

If anyone gets here through Google, I solved this issue by making my additional profile fields not required.

Joe Huggans’s picture

I'm getting this error, not with Rules but from when I am doing both user_save() and user_multiple_role_edit()

I have figured out this doesn't happen if I run user_multiple_role_edit() before user_save, the other way around throws this error