In #2625846, support for a run-as parameter to the drush commands was added to allow running the export as a particular user - typical scenario being exporting user data likely requires the command being run as user 1 to allow access to protected user properties like email address.
Drush natively provides support for this, with --user=[uid]. As mentioned by ao2 in https://www.drupal.org/node/2625846#comment-11965919, this means that the --run-as is not necessary.
I have tried to export a node with drush dcer node 12345, and the user it exported did not contain any private information (email & so on). Running drush dcer node 12345 --user=1 however did.
I think we could revert the change to add the run-as parameter, and instead update documentation to note the --user feature & that it is (likely) required if trying to export content/data anonymous users/drush user doesn't have access to?
Another suggestion by ao2 is to instead always run the export command as user 1 by switching to them in code regardless. Would that be a preferred solution?
Comments
Comment #2
ao2 commentedDuplicate of #2857589: Remove the run-as option in drush commands?
Comment #3
andypostNice catch!
I think that should be mentioned at https://www.drupal.org/docs/8/modules/default-content
..and probably readme
Comment #4
andypostWhy email is not exported #2699469-6: User entity exported without status, roles
Comment #5
geerlingguy commentedSo, a year later, it looks like the
--useroption might not be supported by Drush 9 anymore? I get the following when I try exporting with that option:See: What happen with --user option in Drush 9?. It looks like you have to support the user changes within the Drush command using the
AccountSwitcherInterface.So the
run-asparameter does seem to be necessary, unless a patch like #2861591-6: Export content as user 1 when running in a CLI context is adopted.Comment #6
ao2 commentedProbably this can be closed as "outdated", AFAIU the issue is going to be fixed by #2861591: Export content as user 1 when running in a CLI context.
Comment #7
berdirAgreed, also 2.0.x doesn't care about permissions anymore and the user switching for export is gone.