Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rafamd’s picture

Issue tags: +Novice

Added correct code sample and Novice tag.

rafamd’s picture

Version: 7.x-dev » 8.x-dev
Component: documentation » user.module
Priority: Minor » Normal
Status: Needs work » Active

This is also wrong in D8, see: http://api.drupal.org/api/drupal/core!modules!user!user.api.php/function...

Maybe the correction should be the opposite ? I mean:
$edit['data']['mymodule_foo'] = $edit['mymodule_bar'];

ps: unrelated, but where did $category param go in D8 version of hook_user_presave ? already found out... all the "category" mechanism was taken away.

rafamd’s picture

Version: 7.x-dev » 8.x-dev
Component: user.module » documentation
Priority: Normal » Minor
chertzog’s picture

Status: Active » Needs review
FileSize
534 bytes

Patch attached.

chertzog’s picture

Version: 8.x-dev » 7.x-dev
FileSize
525 bytes

D7 Patch.

rafamd’s picture

Status: Needs review » Needs work
Issue tags: -Novice

Thanks chertzog!

Looking at your patches, seems the same line is removed and introduced both times. Shouldn't the correct new line be:
+ $edit['data']['mymodule_foo'] = $edit['mymodule_bar']; ??

rafamd’s picture

Issue tags: +Novice

restore tag

rafamd’s picture

hummm ... taking another look at the example, I think I was a confused in #2 and #6 and would like to stick to the recommended solution in the original post (and improve the inline comment to make it more informative).

Something like this:

<?php
function hook_user_presave(&$edit, $account, $category) {
  // Make sure that the form value 'mymodule_foo' is also stored as
  // 'mymodule_bar' in the 'data' (serialized) column.
  if (isset($edit['mymodule_foo'])) {
    $edit['data']['mymodule_bar'] = $edit['mymodule_foo'];
  }
}
?>
nmudgal’s picture

Version: 8.x-dev » 7.x-dev
Component: user.module » documentation
Priority: Normal » Minor
Status: Active » Needs review
FileSize
681 bytes

Patch attached after updating as per comment.

nmudgal’s picture

Version: 7.x-dev » 8.x-dev
FileSize
690 bytes

8.x -> Patch attached after updating as per comment.

chertzog’s picture

nice catch. At first glance all that i saw as the problem was the "my_module" change. I didnt notice the "_foo" to "_bar" change.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! Patch looks good; I'll get it committed soon.

nmudgal’s picture

@jhodgdon
It would my first commit to core then :-)
Thanks.

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Uh oh. Actually I just noticed that the comment doesn't seem to match the patch (mymodule_foo vs. my_module_foo, and same for bar).

nmudgal’s picture

Status: Needs work » Needs review
FileSize
688 bytes

oops here is the updated patch.

Thanks

rafamd’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs review » Needs work

Thanks nmudgal, looks better now. Care to re-roll the 7.x patch also ?

nmudgal’s picture

Status: Needs work » Needs review
FileSize
679 bytes

here is one, just was waiting for review of 8.x.

Thanks

rafamd’s picture

Status: Needs review » Reviewed & tested by the community

Thanks !

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice

The last submitted patch, hook_user_presave-d7-1483664-14.patch, failed testing.

boombatower’s picture

Status: Needs work » Needs review
Issue tags: +Novice
nmudgal’s picture

Couldn't understand why it failed ?

boombatower’s picture

Seems unrelated and I don't know why someone would be using hook documentation in a test.

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev

Please leave this at 8.x until 8.x is done -- read http://drupal.org/node/1488414#comment-5748422

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #15 is RTBC for 8.x.

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

The patch in #15 has been committed to Drupal 8. Can we have a patch for Drupal 7 that puts the same code/doc in there too? The patch above for D7 is missing some of the comments.

nmudgal’s picture

Couldn't find anything missing. I think D7 has same comment.

nmudgal’s picture

Status: Patch (to be ported) » Needs review
FileSize
679 bytes

Attached for D7.

jhodgdon’s picture

Status: Needs review » Fixed

Oh sorry, I got confused with all the patches up there. :)

Committed patch in #17 to 7.x.

nmudgal’s picture

Thanks :-)

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

Anonymous’s picture

Issue summary: View changes

adding code sample