Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you run cron, it runs as anonymous. Database gets populated with user 0 creating revisions etc. In addition, other workflow modules that use scheduler modify their states as anonymous. You should be able to specify which user you want to act as the publish/unpublisher.
Comment | File | Size | Author |
---|---|---|---|
#13 | publish_and_unpublish_specific_user-2397423-13.patch | 11.1 KB | lily.yan |
| |||
#9 | publish_and_unpublish_specific_user-2397423-9.patch | 11.16 KB | lily.yan |
#7 | publish_and_unpublish_specific_user-2397423-7.patch | 10.61 KB | iStryker |
#4 | 2014-12-24_Workbench_publish_anonymous.png | 49.95 KB | iStryker |
Comments
Comment #1
iStryker CreditAttribution: iStryker commentedI know this module want to keep things simple, but publishing and unpublishing stuff anonymously doesn't make sense. This should be an option to the site managers.
Comment #2
jonathan1055 CreditAttribution: jonathan1055 commentedHello iStryker,
Thanks for this - it's a nice idea. Do you think this is widely needed? It's never been asked for before, as far as I know. If a node is published by scheduler doesn't it add confusion if the revision appears to be authored by a real person? I'm not slamming your idea, just want to have a discussion about it. I'll try out your patch and see how it goes.
Jonathan
Comment #3
pfrenssenThe messing with the global $user and session juggling looks scary to me. We are allowing external code to run by invoking hook_scheduler_api(). This means that all code that uses that hook will also have the tampered session data and global $user. This might break existing implementations.
Comment #4
iStryker CreditAttribution: iStryker commented@jonathan1055, I think this is widely needed, but no one cares about it. Not a lot of people check to see who create/revised the content. All they care about is that on Monday morning at 9 am the content is published, or the end of the school term the content is unpublished.
I do not think it does. The person who specify the user, knows what they are doing. They want that person to one who publish it. One example, say you have 1 user edit the content and set a publish date. Then another person or two make edits to it before it publishes. When the cron runs it will be published as anonymous and you will never know which user set the publish date (unless you use some kind of diff program/module).
Attached is a screenshot of Workbench moderation to give you a better idea after a cron job run to publish and unpublish a node.
FYI the messing with global $user follows Safely Impersonating Another User on drupal.org
@pfrenssen, yes messing with global $user is messy. I cannot think of any existing implementation this could break (unless they are trying to do a similar thing....ie run all cron jobs as a user called "Cron Job User" instead of anonymous).
Comment #5
iStryker CreditAttribution: iStryker commentedNew Patch.
Fixed:
Comment #6
iStryker CreditAttribution: iStryker commentedComment #7
iStryker CreditAttribution: iStryker commentedNew Patch. If you try to edit a node that doesn't have an publish_on or unpublish_on then it
Warning: Creating default object from empty value in _scheduler_form_alter() (line 59 of/var/www/drupal/profiles/uw_base_profile/modules/contrib/scheduler/scheduler.edit.inc).
Error. Solve by adding one line:
$defaults = new StdClss;
Comment #8
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi iStryker,
Thanks for your patch, and the explanations. The patch file no longer applies due to newer code committed to .install. I fixed it manually and tested the change but there seemed to be an unwanted side-effect of blanking the scheduled date when editing an existing scheduled node. I reversed out the changes and the pre-existing scheduled dates reappeared.
However, I do not think we would add this feature anyway - it is a major change to make a new field in the Scheduler table specifically for this one purpose, a relatively minor enhancement that no other users have asked for. If you still want this functionality, it would need to go into 8.x first, anyway.
I do not consider it a good idea to give editors the power to make a node appear to be published by someone else. The revisions log currently clearly shows that Scheduler has done the publishing. Scheduler does not alter the owner of the node, so your change is only for information/logging. I do not think we want to "Impersonate Another User" even if the code changes are done via the accepted method. This will just add more confusion than it resolves.
So, unless pfrenssen has significantly changed his view from what was said above, I agree with him that this is not something we want to do.
I have some ideas about how we can expand the capabilities of Scheduler in 8.x in a generic customisable way, so that sub-modules or third-party modules could add bespoke modifications for these types of requirement without 'hard-coding' all the changes in the module codebase. If/when that happens then it could also be ported back to 7.x so keep a watch-out for that.
Thank you for your interest in this module - your contributions and comments are always useful and thought-provoking, even if we don't actually implement them they way you want.
Jonathan
Comment #9
lily.yan CreditAttribution: lily.yan commentedI worked with iStryker. The patch is based on the current 7.x-1.x-dev and currently works with 7.x-1.5.
Comment #10
Liam MorlandComment #13
lily.yan CreditAttribution: lily.yan commentedNew Patch. The patch is based on the current 7.x-1.x-dev (acf0a892).
Comment #14
iStryker CreditAttribution: iStryker commentedComment #15
hmdnawaz CreditAttribution: hmdnawaz commentedThe patch is not working. I can still see
Revised by Anonymous (not verified)
The
$node
object does not contains thepublisher_user
property.$node->publisher_user
Comment #16
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi hmdnawaz,
This enhancement is not going to be added to Scheduler, see my comments in #8 above. The issue should have been closed before now.
Jonathan
Comment #17
Liam MorlandPerhaps a better solution is #3077633: Anonymous (not verified) after scheduler updates.