Problem/Motivation
Drupal 7 supports differing public and private file directories. The file source plugin has a single source_base_path, so a given file migration can only migrate one or the other. The front end can easily instantiate two file migrations, one for public files and one for private files, with distinct source_base_paths, but each needs a different condition on the query (e.g., uri LIKE 'public://%').
Proposed resolution
Add an option to the file source plugin allowing filtering. To help support other file schemes from contrib, I would suggest it take a string value for the scheme to filter on ('public', 'private', 'youtube', etc.).
Remaining tasks
Submit a patch.
User interface changes
N/A
API changes
New configuration option on file source plugins.
Data model changes
N/A
Comment | File | Size | Author |
---|---|---|---|
#19 | 2547125-19.patch | 4.08 KB | phenaproxima |
#16 | interdiff-2547125-8-16.txt | 1.27 KB | phenaproxima |
#16 | 2547125-16.patch | 4.03 KB | phenaproxima |
#8 | 2547125-8.patch | 3.31 KB | phenaproxima |
#6 | 2547125-6.patch | 1.38 KB | phenaproxima |
Comments
Comment #2
webchickIt's not currently possible to import private files in D7 without this, so I believe that makes this a Migrate D7 critical.
Comment #3
mikeryanTagging for Barcelona sprinting.
Comment #4
adooo CreditAttribution: adooo as a volunteer commentedI'll try this one!
Comment #5
adooo CreditAttribution: adooo as a volunteer commentedCouldn't figure out how to simulate migrations...
Someone else can try this one :)
Comment #6
phenaproximaInitial patch; the unit tests will need to be updated.
Comment #7
phenaproximaComment #8
phenaproximaAdded a unit test.
Comment #9
mikeryanWhat's here looks good. But, I'd like to see the d7_file tests trying this out - adding at least one private:// to the dumps, and verifying that migrations passing scheme: public:// and scheme: private:// to the source plugin actually get the right rows from the source table.
Comment #11
phenaproximaUh...what? No it didn't. I see green. What are you smoking, testbot? Too much green, perhaps?
Comment #12
mikeryanMade a first pass at implementing private file migration in the drush migrate-upgrade command at https://www.drupal.org/node/2505283#comment-10366951, this patch works fine. I'm not going to insist on the additional tests, ready to go for me.
Comment #13
mikeryanHrrm... I'm realizing that my patch partly worked by accident (because I was migrating my private files directly from their location on the source site). Not a bug in this patch, but I think we may need to refactor some of the existing stuff that constructs file paths a bit to fully support private files.
Comment #14
mikeryanMy problem was:
Can you spot it? I knew you could... get() isn't going to dig into child fields, so get('destination.source_base_path') always returns NULL (and my source_base_path doesn't get stripped, so it gets added again by the destination). We need to get the destination then extract the source_base_path.
This is a pre-existing bug, but let's fix that in this patch, since it's necessary to making private files work.
Comment #15
mikeryanBy the way, it's horrifying that the source plugin is extracting stuff from the destination configuration, but fixing that is more refactoring than we can deal with here...
Comment #16
phenaproximaHow's this?
Comment #17
benjy CreditAttribution: benjy at PreviousNext commentedNeeds an issue
Comment #18
benjy CreditAttribution: benjy at PreviousNext commentedRest looks good, RTBC once we have a link to that issue I mentioned in #17
Comment #19
phenaproximaAdded a link to #2577871: d7_file plugin should receive source_base_path configuration option.
Comment #20
mikeryanLooks good, and works with the patch at #2505283: Handle import of private files.
Comment #21
webchickMaybe let's get a follow-up to explicitly test a file with both a private:// and "flickr://" (or something) scheme, but overall this looks great.
Committed and pushed to 8.0.x. Thanks!