Minor issue, but I noticed that the call to registration_save is actually returning the $ret variable. On successful save this is evaluated as true (1). The comment for that function says that this function returns the saved registration object, which would imply that is should be returning $registration (which has the registration_id at this point?). I think the latter is correct, because otherwise there's no clean way to get the registration_id for a registration you just saved.

Comments

seanbfuller’s picture

Title: Function registration_save returns ret instead of registration object » Function registration_save should return registration_id

Or, of course, just add an ampersand on the $registration parameter so that the registration_id (and anything else is added to the reference) is magically available to the calling function. Either way, updating the comment to match what is actually happening also needs to be done.

seanbfuller’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

While developing some custom functions against registration, we also found a related issue in registration_save() where the wrong parameter was being passed in to module_invoke_all() for 'registration_save'. The $ret (true or false) was being passed in, as opposed to the $registration object, which was probably the intent.

Attached is a quick patch to fix these issues. It does the following:

  • Add the ampersand to the $registration parameter so that the registration_id is available after the call.
  • Passes on the $registration object to the implementation of hook_registration_save()
  • Updates the comment block for this function (including the return)

Obviously this is a minor issue, but will probably become more critial as other modules try to leverage this module. Thanks!

levelos’s picture

Status: Needs review » Fixed

Actually Entity API handles all the hook invokations. But you're correct in that the return value was incorrect. Fixed in #5a43789.

Status: Fixed » Closed (fixed)

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

  • levelos committed 5a43789 on 7.x-1.x, panels, any-entity, slots, integrations, hold_state
    Update return value in registration_save() and set default values in...