Run drush imports as user=1

Created on 6 May 2020, almost 5 years ago
Updated 13 March 2023, about 2 years ago

Problem/Motivation

If someone wants to turn on entity validation for a migration, then you need to run the drush command as the root user. Otherwise simple things like filter format allowed values list will fail validation because you only give "Full HTML" to admins and "Restricted HTML" and/or Plain Text to anonymous users. By default, Drush runs as anonymous. Let's fix this.

Proposed resolution

This could lead to some possible problems, if someone was relying on the fact that migrations run as anonymous. So let's see if others feel this needs a way to toggle this automatic feature off.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

RTBC

Version

5.0

Component

Code

Created by

heddn Nicaragua

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly robertom

    Reroll patch.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine osab Germany, Baden-Wรผrttemberg; Ukraine, Kharkiv

    #12 works fine for me also, D10.1.5 php8.1. It fixed the error 'User %user not allowed to go from state %sid1 to %sid2' from workflow module, as it made migrate as anonymous.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    > @Wim Leers, it is on text filters/formats. Full HTML is secured to only admin users. But drush runs everything as anonymous. And my content has a very common thing called a body field and entity validation running as anonymous fails validation. It isn't an issue running from migrate_drupal_ui, as it requires you to run the upgrade as user=1.

    Furthermore, with entity types that don't have an owner such as block_content, EntityContentBase::validateEntity() won't do any account switching.

  • Status changed to Needs work 3 months ago
  • heddn Nicaragua

    Instead of defaulting to user=1, let's make this a configurable for _which_ user we want to execute as. Similar to how drush used to work .i.e. drush mim --uid=33 my_migration. My logic being that user=1 is no longer always a full admin user since https://www.drupal.org/node/2910500 โ†’

  • Pipeline finished with Failed
    29 days ago
    #441038
  • First commit to issue fork.
  • ๐Ÿ‡ท๐Ÿ‡ดRomania vasike Ramnicu Valcea
  • ๐Ÿ‡ท๐Ÿ‡ดRomania vasike Ramnicu Valcea

    vasike โ†’ changed the visibility of the branch 3134245-run-drush-imports-uid-option to hidden.

  • Pipeline finished with Success
    29 days ago
    Total: 222s
    #441042
  • ๐Ÿ‡ท๐Ÿ‡ดRomania vasike Ramnicu Valcea

    Created a MR with new uid option for import only using the account_switcher service.

    I tested within a project doing Migrate Source CSV dependant migration imports, using ECA Models to control different entities data.
    And it worked as expected.
    Needs review ... for now ... to get some feedback.
    Do we need also for other "commands"?

    Note: For ECA models "alteration" this could also achieved, but currently the option is to have the user set for all models ...

    Also it seems the issue was previously for an older version, so initially I created a "bad" branch
    which seems I can't delete it
    https://git.drupalcode.org/issue/migrate_tools-3134245/-/tree/3134245-ru...

  • ๐Ÿ‡ท๐Ÿ‡ดRomania vasike Ramnicu Valcea
Production build 0.71.5 2024