Now that #341382: Add primary key to signup_log table is in place, we can simplify a bunch of the code for node/N/signups which is doing some slightly weird things to key the users with either uid or anon_mail. Now, we can always key on sid. This will make the patch for #55168: tracking actual attendance easier, too.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dww’s picture

Status: Active » Needs review
FileSize
10.04 KB

This removes a bunch of ugly code. The functionality is the same, yet the patch removes 57 lines and only adds 41 (9 of which are expanded PHPdoc comments). ;) I think the API for signup_cancel_signup() is more sane, now, too, given the sid key. And, since it's the 6.x-2.* series, I don't mind breaking compatibility to fix the API.

Any thoughts/objections/reviews/testing before I commit?

add1sun’s picture

Status: Needs review » Reviewed & tested by the community

yay for saner code and saner referencing. I think breaking API in V2 is fine since this makes so much more sense.

dww’s picture

Status: Reviewed & tested by the community » Fixed

Great, thanks for the review. Committed to HEAD: http://drupal.org/cvs?commit=159262

dww’s picture

Title: Use {signup_log}.sid to simplify node/N/signup code » Use {signup_log}.sid to simplify node/N/signup code and fix the API for hook_signup_cancel()
Status: Fixed » Active

Actually, the more I think about it, I think the new API for hook_signup_cancel() should be:

/**
 * @param $node
 *   The fully-loaded node object that the signup is being canceled from.
 * @param $signup
 *   An object containing all the known information about the signup being canceled.
 *   Contains all the data from the {signup_log} row representing the canceled signup.
 *   See the schema definition for descriptions of each field and what they represent.
 */
function hook_signup_cancel($node, $signup) {
  ...
}

We've already got the fully loaded $signup object in signup_cancel_signup(). Why just pass the sid and uid, when we can pass an object with everything? Seems much more useful that way, doesn't cost us anything, and if we're already breaking the API, we might as well do it right. ;)

Thoughts?

dww’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Status: Active » Needs review
FileSize
3.76 KB

FYI: After further consideration, I just backported this (and related changes) into DRUPAL-6--1: http://drupal.org/cvs?commit=159750

Furthermore, as I think about hook_signup_cancel, it seems like the API should really be: hook_signup_cancel($signup, $node). The $signup object is more important than the $node, so it should come first. And, since we're breaking the API, we might as well break it all the way. Attached patch does this, and adds a signup.api.php file to document signup hooks (along the lines of the new convention in D7 core).

deviantintegral’s picture

The hook looks good to me. Flipping the order makes sense; following my own convention of "make the code talk", I'd always say to someone "Cancel signup 1337 for node 123", so I would expect the API to be the same.

This is going to make notifications so much more powerful. Sweet!

dww’s picture

Status: Needs review » Fixed

Great, we're all agreed. Committed to HEAD and DRUPAL-6--1. Yay. ;)

Status: Fixed » Closed (fixed)

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