Problem/Motivation
Some modules that perform field validations, perform checks against the current logged in user. This can cause issues when imports run during cron, where the current logged in user is anonymous. This issue was partly fixed by #2541944: Switch to feed author or user 1 during imports (taxonomy mapping does not work with cron): when importing, an account switch happens to either the author of the feed node (if the importer is attached to a content type) or to user 1 (if using the standalone form).
However, some modules validating against the current user even disallow user 1 to edit a certain field. This is for example the case for the OG reference field, that requires the current logged in user to be a member of the group when importing content for that group.
For the OG reference field, that check can be bypassed by setting the value 'field_mode' to 'admin', but that addition is being handled in #2922268: Standalone import works, cron import has field validation errors.
Note that #2541944-20: Switch to feed author or user 1 during imports (taxonomy mapping does not work with cron) says the following:
The patch doesn't fix the issue with the "Authorize" option. An extra switch should happen during the import when that option is checked to verify the author has privileges to do a certain thing.
This is what will be handled in this issue.
The code for this is already available in #2922268: Standalone import works, cron import has field validation errors, but I like to spin it off here in order to make reviewing that other issue easier.
Proposed resolution
When the "Authorize" option is checked, make sure an extra account switch happens for each item. All field validations are then performed against the author of each item, as if that author was logged in. This is expected to fix most issues for field validations that perform checks against the current logged in user.
Remaining tasks
- Review.
- Commit.
User interface changes
None.
API changes
Extra account switches happen during import when the "Authorize" option is checked.
Data model changes
None.
Patch will follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | feeds-authorize-item-author-switch-3046797-2.patch | 15.63 KB | megachriz |
Comments
Comment #2
megachrizIn functional terms of speaking, this patch is the same as #2922268-20: Standalone import works, cron import has field validation errors minus the code for the hook
hook_feeds_prevalidate()(which was already added to the module in #3046592: Add a hook to invoke before validation) and minus the specific code for Organic groups. Code comments are added for extra clarity.Comment #3
megachrizCommitted #2.