Private files need a separate migration from public files, because their source path will differ. Haven't looked too closely, but this probably requires core support - like, an option on the file source plugin to select only public or only private files.
The hard part here is the UX - from comment #3 below:
In Drupal 6, the files directory is either all public or private, so there's only one file directory configuration to worry about. In Drupal 7 you can have a public file directory and and private file directory (and the latter isn't necessarily in the docroot), so we need to configure two file migration processes, one for each. In our current workflow, we don't know whether we're dealing with a D6 or D7 site (and thus whether we need to prompt for a private file directory) until submitting the credential form. How do we deal with this?
- Instead of auto-detecting the source version, prompt for it on the credentials form, and use ajax to show/hide the private directory prompt (submitting the form would still detect the version and throw an error if it didn't match the selected version).
- Have a separate page after the credentials form for file configuration, which can easily have one or two file directory prompts as appropriate. And perhaps other version-specific prompts as well...
- Other ideas?
Comment | File | Size | Author |
---|---|---|---|
#78 | 2505283-78.patch | 24 KB | maxocub |
#78 | interdiff-76-78.txt | 3.98 KB | maxocub |
interdiff-74-76.txt | 1.02 KB | maxocub | |
2505283-76.patch | 24.38 KB | maxocub | |
#74 | interdiff-73-74.txt | 1.68 KB | maxocub |
Comments
Comment #1
mikeryanBlocked on #2547125: D7 file migration should allow selecting public/private/all files.
Comment #2
mikeryanTagged for Barcelona sprinting. Note that D6 has a global public/private switch, so only needs one file source to run, but D7 has separate public and private file directories (and private files aren't necessarily in the docroot), so the UI should only prompt for a private file directories if the source site is D7, and is configured for private files. Not quite sure how "novice" this is...
Comment #3
mikeryanI've added the following to the design doc:
So, private files... In Drupal 6, the files directory is either all public or private, so there's only one file directory configuration to worry about. In Drupal 7 you can have a public file directory and and private file directory (and the latter isn't necessarily in the docroot), so we need to configure two file migration processes, one for each. In our current workflow, we don't know whether we're dealing with a D6 or D7 site (and thus whether we need to prompt for a private file directory) until submitting the credential form. How do we deal with this?
Comment #4
mikeryanA first pass at implementing private file handling in the drush command (with added option --legacy-root-private), which works with the core patch at #2547125: D7 file migration should allow selecting public/private/all files. This stage is basically just to demonstrate that the core patch works for reals.
Comment #5
mikeryanJust a note on that patch - the big hole is that for any references to the private files (i.e., file fields) to work, the private file migration needs to be referenced by the migration process plugin. So, we'll need to rewrite other migrations to add it there, as well as to migrate_dependencies...
Comment #6
mikeryanHere's the patch with some ugly code to rewrite references to d7_file. Haven't done anything with the UI, not quite sure yet where/when we should prompt for the private files.
Comment #7
abhishek-anand CreditAttribution: abhishek-anand at Acquia commentedComment #8
imalabyaComment #10
xjmComment #11
AjitSI think this is not a suitable candidate for the "novice" contributors as per https://www.drupal.org/core-mentoring/novice-tasks.
The process to this issue looks to be open-ended. The scope too is not defined clearly. Please correct if you feel otherwise.
Comment #13
xjmSince private files are a core feature, we need to have a migration path for them, so this is a Migrate critical.
Comment #14
xjmPostponing on #2695297: Refactor EntityFile and use process plugins instead per discussion with @alexpott, @weal, and @mikeryan.
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedAdding a related issue, we are considering this blocked by #2695297: Refactor EntityFile and use process plugins instead.
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #18
mikeryanEntityFile patch is in, this can proceed.
Comment #19
chriscalip CreditAttribution: chriscalip commentedI am confused by patch. I am unable to apply patch see @screenshot 2505283-unable-to-apply-patch.png
Also looks like this patch apply to contrib module drupal.org/project/migrate_upgrade
Comment #20
mikeryanThe last patch is ancient, from before upgrade UI was folded into core, it needs to be rerolled against the current core UI.
Comment #21
nlisgo CreditAttribution: nlisgo commentedGoing to attempt a reroll.
Comment #22
nlisgo CreditAttribution: nlisgo commentedComment #23
penyaskitoThis has changed so much that I don't think we can reroll anything, so let's start from scratch.
Comment #24
penyaskitoWork in progress. I managed to do the part of the patch that should be applied to migrate_update. Still work in core needed.
Comment #25
chriscalip CreditAttribution: chriscalip commentedhmm.. am i missing something here? migrate_upgrade is a contrib module.I guess it doesnt matter, comment withdrawn.
Comment #26
penyaskitoWhat I tried in #24 is to generate another migration in getMigrations(), but at that point we don't have yet control over the settings we are passing.
Generating them as soon as we have the settings would mean duplicating code in the UpgradeForm and the Upgrade Drush Runner.
I'm wondering if we should generate the d7_files_private when we already have that info, but the user won't see a "d7_files_private" migration at all.
Comment #27
kekkisPatch at #24 is not valid since it's from a diff taken at module level, not Drupal root directory level. I'm unable to find the migrate_upgrade.drush.inc file in Drupal core at all, even after running composer install.
Comment #28
mikeryanThis patch was begun when the upgrade UI was still in the migrate_upgrade contrib module, and thus covered both the UI (now in core) and the drush command (still in contrib). The MigrationCreationTrait needs to be redone against the core MigrationConfigurationTrait - then, the equivalent of what was being done here for the drush command needs to be done in the core UI.
Comment #29
mikeryanThe hard part here is the UX - from comment #3 above:
Comment #30
mikeryanComment #32
quietone CreditAttribution: quietone as a volunteer commentedMaking a start. This implements changes to the UI only, option #1.
Comment #33
mikeryanComment #34
anish.a CreditAttribution: anish.a at Axelerant commentedComment #35
mikeryanThere are many more Drupal 7 than Drupal 6 sites out there, I would make Drupal 7 the default.
s/t/$this->t/
It'd be nice if for Drupal 7 this would change to "To import *public* files..." (and the title change to "Public file directory").
Site address won't work for private files (because they're private!) - only a local file directory will work.
Comment #36
quietone CreditAttribution: quietone as a volunteer commentedFixes for 1-4 in #35. There may be a better way to resolve #3. Don't know why but I was getting errors on d6_statistics_settings, so I changed that to the correct name.
Comment #38
quietone CreditAttribution: quietone as a volunteer commentedWrong patch. Try this one.
Comment #40
quietone CreditAttribution: quietone as a volunteer commentedThe form has a new field for the d6 source base path, now make sure MigrateUpgradeTest knows about it.
Comment #42
quietone CreditAttribution: quietone as a volunteer commentedWell, that was a silly mistake. Edited out the setting of source_base_path.
Comment #43
quietone CreditAttribution: quietone as a volunteer commentedAdded a private file migration and test, using the existing file migration as a guide. But the private file migration test fails because the call to realpath returns 'private:' and not the realpath. How should the private file stream be setup for tests?
Also, changed d7_file to use the scheme configuration parameter to select only public files.
Comment #44
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedThe patch doesn't use the new short array syntax of , made change to the short array. Applying the patch, please review.
Comment #47
quietone CreditAttribution: quietone as a volunteer commented@Pavan B S, thanks for helping out. However, the migrate test fixtures don't use the short array syntax. The first lines of the fixture are
There is some more information at Generating database fixtures for D8 Migrate tests.
Comment #48
jofitz CreditAttribution: jofitz at ComputerMinds commentedI'm pretty sure this is not the correct/final method, but after a lot of playing around I have at least got the tests to pass.
The register() method appears to be the way to enable the private stream (which means realpath() returns the values we need) - I obtained this concept from FileTestBase.
I'm not happy with:
but I suspect the str_replace() is pointless without it. Whatever we end up doing in this if() probably should also be applied to the "else".
The file system is now obtained from the container, rather than \Drupal::service() which feels right.
Hopefully this gets us a step closer.
I think we can remove the Needs Tests tag too.
Comment #50
jofitz CreditAttribution: jofitz at ComputerMinds commentedLet's make sure the directory exists first.
Comment #52
quietone CreditAttribution: quietone as a volunteer commented@Jo Fitzgerald, thanks. Getting the file system from the container and the new register method makes sense. If this is the way to go these changes should be made in MigrateFileTest as well.
This patch changes changes the file entity count in MigrateUpgrade7Test to include the new private file migration.
Comment #53
jofitz CreditAttribution: jofitz at ComputerMinds commentedI have opened a follow-up ticket for copying the changes from here to MigrateFileTest: #2860760: Match setup() functionality of MigrateFileTest with MigratePrivateFileTest
Comment #54
mikeryanComment #55
quietone CreditAttribution: quietone as a volunteer commentedCame back to check for an error I thought I left in the patch. Good news, I didn't. So, yes, ready for review.
I decided to add some screenshots.
Comment #56
heddnAssigning to mikeryan to review.
Comment #58
mikeryanPatch no longer applies, so not tested. However, I did do a quick code review:
Ideally, we would use the same constant name, source_base_path, for both public and private migrations in the migration itself (of course, the form field name needs to differ). Since there's only one path being specified in the migration, we don't need a different name.
As above, I think we can just keep this.
So, I would say that here we need to explicitly use the form's source_private_file_path when the migration ID is 'd7_file_private', and otherwise use source_base_path.
Thanks!
Comment #59
quietone CreditAttribution: quietone as a volunteer commentedOnly the reroll. Still need to respond to #58.
Comment #61
quietone CreditAttribution: quietone as a volunteer commentedThe reroll without the typo.
Comment #63
quietone CreditAttribution: quietone as a volunteer commentedAnd adjust the count.
Comment #64
mikeryanNeeds work for #58.
Comment #65
quietone CreditAttribution: quietone as a volunteer commentedI thought I uploaded a patch for #58! Assigning to myself until I have time to go hunting for it.
Comment #66
quietone CreditAttribution: quietone as a volunteer commentedAddressing #58. Unfortunately, this isn't passing all tests locally. But since PhpStorm has decided (for the Nth time) to stop debugging I'm going to take a long pause.
Comment #68
jofitz CreditAttribution: jofitz at ComputerMinds commentedI took some queues from
Drupal\Core\StreamWrapper\PublicStream::basePath()
for settingfile_private_path
and using a virtual file system (vfs), similar to MigrateFileTest.I also made a couple of corrections to d7_file_private.yml to bring it in line with d7_file.yml and
$source['constants']['source_base_path'] = $fs->realpath('private://');
in the test setup.If this needs any further changes then I expect they will need to be applied to the public equivalent too.
Comment #70
mikeryanThis should be 'source_base_path', no?
Comment #71
jofitz CreditAttribution: jofitz at ComputerMinds commentedNo, because that will replicate the preceding line (but I can't be any more helpful than that, sorry).
Comment #72
jofitz CreditAttribution: jofitz at ComputerMinds commentedI've spent all day on this and I've got nowhere.
In MigrateUpgrade6Test,
$user = User::load(2);
returns null in both patches since #63 (#66 & #68), but I can't fathom why. I assume the User migration is failing due to changes in importing files. Running WebTestBase tests takes forever and is awkward to debug.Can someone else take a look at this? I'd love to know what is causing the problem.
Comment #73
maxocub CreditAttribution: maxocub commentedGood news, MigrateUpgradeTestBase no longer extends WTB, but BTB instead, so this will be easier to debug.
Here's a re-roll.
Comment #74
maxocub CreditAttribution: maxocub commentedI think this should take care of problem mentioned in #72.
We needed to specify the source Drupal version, the newly added radio button.
Now only the private files migration are still failing.
Comment #77
phenaproximaThis looks real good, but I have a few requests...
We can just get rid of this. Commented-out code is non-great :)
Needs @inheritdoc.
This should be assertInstanceOf().
We might be able to use assertFileExists() here.
These states are redundant. We only need to specify either invisible or visible, but not both.
Same here.
And here.
Comment #78
maxocub CreditAttribution: maxocub commentedCorrections from #77.
Comment #79
phenaproximaThis should be targeted against 8.4.x.
Comment #80
phenaproximaLooks great to me!
Comment #81
phenaproximaBrought to you by the smart people at DrupalCamp Montréal!
Also, as per discussion with @xjm, this can be targeted against 8.3.x. My bad on that one.
Comment #83
xjmYep, to clarify #81, Migrate Drupal is still in alpha, and although the migrations technically live in the stable module that provides them, we've been treating them as covered by the experimental module backport exception. (Reference: https://www.drupal.org/core/d8-allowed-changes#experimental)
Comment #85
catchCommitted/pushed to 8.4.x and cherry-picked to 8.3.x. Thanks!
Comment #88
maxocub CreditAttribution: maxocub for Acquia commentedComment #89
maxocub CreditAttribution: maxocub as a volunteer and for Acquia commentedComment #90
maxocub CreditAttribution: maxocub as a volunteer and commented