Go to a party that can attach a user but doesn't.

Try to attach one via the dataset add form.

Breakage!

Comments

rerooting’s picture

StatusFileSize
new25.09 KB

This actually works for me, kinda. It creates a new fieldset for every attached user. Not sure why. But it seems to work (after the other user entity attachment patch you just made), only error messages I get are related to username label plugin.

Attach User to Existing Party

joachim’s picture

Weird.

I get:


    Notice: Undefined property: stdClass::$uid in party_attached_entity_edit_form_submit() (line 307 of /Users/joachim/Sites/crm-drupal/sites/all/modules/contrib/party/party.pages.inc).
    Notice: Undefined property: stdClass::$uid in PartyDefaultDataSet->getEntityDelta() (line 143 of /Users/joachim/Sites/crm-drupal/sites/all/modules/contrib/party/includes/party.data.inc).
    Notice: Undefined property: stdClass::$uid in PartyDefaultDataSet->save() (line 531 of /Users/joachim/Sites/crm-drupal/sites/all/modules/contrib/party/includes/party.data.inc).
    PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'eid' cannot be null: INSERT INTO {party_attached_entity} (pid, eid, delta, data_set, entity_type, entity_bundle) 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); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => user [:db_insert_placeholder_4] => user [:db_insert_placeholder_5] => user ) in PartyDefaultDataSet->save() (line 543 of /Users/joachim/Sites/crm-drupal/sites/all/modules/contrib/party/includes/party.data.inc).

Are you adding a user at party/1/user/add?

joachim’s picture

I suspect that part of the problem is that party_attached_entity_edit_form() is based on the idea that you are either:

- attaching and creating a new entity
- editing an existing attached entity

Whereas what we want here is:

- attach an existing entity

rerooting’s picture

Huh, i dont get a party/1/user/add uri...

I am at party/2/party/edit which presents the form above.

If it helps, I am using the #1612368: Clean up old controller uses #9 patch and not the commit? The last commit in my log is Issue #1644336 by andrewbelcher: Fixed party_user for removal of party bundles.. I patched using the #9 mentioned and have been working from that, created a fresh install based on testing that patch.

joachim’s picture

My suspicion therefore is that we need to know that sometimes party_attached_entity_edit_form() is in the 'attach existing' case instead of 'attach new'.

And that this distinction is a property of the *data set*. Ie, if you're working with users, you're attaching one rather than creating one. Though I can see a case for an admin creating new user accounts...arg.

So okay, it's a property of the data set that you can have the 3rd action available. (Because for P2, you can't.)

Does that seem to make sense?

joachim’s picture

Or really, attaching existing should be a whole other form from party_attached_entity_edit_form(), because it's based on finding something exsting so will need different fields.

So data sets need to say:

- ui for attaching existing?
- ui for creating new?

joachim’s picture

Ah, I see this idea is in party_user_form_user() (which is the data set form callback -- see #1669942: clean up (or at least document) nests of forms for an explanation!)

    // Mark down that we're selecting which user to connect.
    $user_form['op'] = array(
      '#type' => 'value',
      '#value' => 'select',
    );

Could do to be moved further up I think.

rerooting’s picture

Yes, i think it makes alot of sense. Use cases abound.

Attach new is not available though. It would be nice to allow a toggle between attach existing and attach new - say with a combo box.

Quick sketch:

[ Existing User [V]]
[ Autocomplete Field O ]

(switch combo option, AJAX form update)

[ New User [V]]
[ Text Input Field ]

rerooting’s picture

Ok I have a better idea, wireframing....

joachim’s picture

Let's leave AJAX stuff for another day...

I'm not sure what you're seeing that's different. You probably need to clear caches a few times; I made some changes today. Regarding patches -- best is to be on HEAD.

joachim’s picture

It looks like we get to PartyDefaultDataSet::Save() TWICE for the user data set, setting the correct user ID the first time and then clobbering it with NULL the second!

joachim’s picture

Status: Active » Fixed
StatusFileSize
new1.1 KB

Finally got it.

Saving in party_user_form_user_submit() isn't needed; rather, we should be dosing up the form state so the central party_attached_entity_edit_form_submit() can take care of it.

joachim’s picture

rerooting’s picture

Works fine

rerooting’s picture

Works fine

rerooting’s picture

oops shoulda looked at the commit log already been committed. yeah it works!

rerooting’s picture

On a fresh install, with the latest 7.x-1.x branch (includes commit of patch #12 above), I get this error when adding a party:

Notice: Undefined property: stdClass::$uid in PartyDefaultDataSet->getEntityDelta() (line 143 of /var/www/partytests/sites/all/modules/party/includes/party.data.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => 1341334183 ) in drupal_write_record() (line 7013 of /var/www/partytests/includes/common.inc).

Specifically this happens when I refer to a user that does not already exist at party/add. It looks like it tries to create user 1 again?

FYI I only have party and party_user enabled.

rerooting’s picture

Ok actually, it doesnt work with existing users either.

Same error output:

Notice: Undefined property: stdClass::$uid in PartyDefaultDataSet->getEntityDelta() (line 143 of /var/www/partytests/sites/all/modules/party/includes/party.data.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 5 [:db_insert_placeholder_1] => 1341335066 ) in drupal_write_record() (line 7013 of /var/www/partytests/includes/common.inc).

Note that this is all happening on add/party. This was 'kind of' working before the latest commit, with the funny output above.

rerooting’s picture

By the way, I can find the uri you were talking about above, e.g. party/1/user/add which looks the same as the form on pary/1/edit. Submitting that form does attach the specified existing user, however the immediate result is a WSOD with a label related error message Notice: Undefined property: stdClass::$delta in party_view_data_set() (line 360 of [..]/party/party.pages.inc). which is different from when I add or register users, which displays that error as a status message after returning to /admin/community.

Also, worth nothing that party/1/edit form still looks like the screenshot above. Am I missing something? This is on my fifth fresh install (thank bejeezus for drush si!). Remember I only have party and party_user installed, so possibly that factor could explain it. It's good to see that /user/add works (despite label plugin issues) but I don't see how in the UI someone would get there as it looks with a fresh install.

joachim’s picture

> however the immediate result is a WSOD with a label related error message Notice: Undefined property: stdClass::$delta in party_view_data_set()

Yup, that's the follow-on bug.

The edit form is totally broken on my install, from before I started tinkering with stuff.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.