I've written a small Drush command to facilitate giving user ownership of a node and it's revisions or comment to a specified user. I mostly use it to correct my own blog postings or comments that I make when I'm logged into my blog with the wrong user account.

With such a weird and niche use case, I didn't think it belonged in core, but I thought it might have a place in Extras. Checking here before publishing elsewhere.

Comments

greg.1.anderson’s picture

Status: Needs review » Needs work

Looks useful; I'll gladly take it in extras, but first I need to (re) create the drush-extras project.

The patch looks good. My only comment is that you have a few drush_log 'notice' and 'warning' that inform the user that the operation could not be completed. These should all be drush_error. The places where you use drush_log 'success' are appropriate.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new5.01 KB

Updated to use drush_set_error().

greg.1.anderson’s picture

Status: Needs review » Needs work

Committed -- although I notice there are still a couple of missing dt()s, and a couple of drush_log()s that should be drush_set_error().

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new3.83 KB

Ack, sorry about that. Attached patch hopefully corrects the rest. Also added some quotation marks around node titles and user names to make it easier to read them.

greg.1.anderson’s picture

Status: Needs review » Needs work

Committed.

I did notice some minor errors that could still be corrected. The code seems to charge ahead even when there is a bad account:

$ drush @dev give-node 3 nosuchuser
Bad account.                                                         [error]
Node "test" <3> ownership updated to "" <>.                          [success]
Node revision(s) ownership updated for Node "test" <3>.              [success]
An error occurred at function : drush_drush_give_give_node 

You should use return drush_set_error(...); to bail out of the function. Also, -s is not respected.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new5.24 KB

Attached patch hopefully fixes the remaining drush_set_error() gaffs. While I was at it, I did some error message standardization and a few other tweaks.

Strange to keep enhancing it in the same issue. ;)

This patch should be applied to the command in the repo, it is not a new copy of the entirety of drush_give.