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.
yeah looks good to go, but lets do it after next alpha so we don't break heaps of patches in queue.
Comment | File | Size | Author |
---|---|---|---|
#45 | 2614644-split-45.patch | 56.69 KB | andypost |
Comments
Comment #2
larowlan+1
Comment #3
jibran+1 with more tests. :)
Comment #4
claudiu.cristeaShouldn't the import process be handled as a normal migration, as we already have migrate as a core functionality?
Comment #5
claudiu.cristeaSome PROS for #4:
CONS:
Comment #6
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commented> Use of an official API for importing entities.
This module is implemented on top of cores REST and serialization services. The key thing here is that entities can be imported AND exported, which migrate isn't natively concerned with.
> The import can be done anytime, not only on module enabling.
All functionality is exposed via services. You can use these services anywhere.
This is of course one of the many possible solutions for default content. It has already had a surprising amount of battle-testing despite being so early in D8s life but you're of course welcome to create a solution based on Migrate, however it doesn't live in this project. I've discussed default content solutions based on Migrate previously, I believe the outcome was that it would be less "automatic" but with potentially other upsides.
Comment #7
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #8
andypostLooks great, only one nit that could be fixed on commit
nit, comment needs fix also
Comment #9
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedRetesting to see if this still applies.
Comment #11
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #12
vprocessor CreditAttribution: vprocessor at Skilld commentedComment #13
vprocessor CreditAttribution: vprocessor at Skilld commentedHi guys,
Reroll is ready (rerolled & fixed), check install/uninstall only because I am not sure about how to test this module properly
Comment #14
vprocessor CreditAttribution: vprocessor at Skilld commentedComment #15
vprocessor CreditAttribution: vprocessor at Skilld commentedUpdated with "git diff -M25%" to reduce size of patch
Comment #16
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI'll let someone else review and commit this having written the original patch.
Comment #17
andypostthat looks great but breaks a lot of patches in queue
@Larowlan please decide, this suppose to be in alpha 4 release, but maybe better to wait
Comment #18
larowlanminor nit to fix on commit
Comment #19
andypostComment #20
andypost@larowlan do you mind to keep BC shim for old manager?
And names should be
default_content.importer
&default_content.exporter
Comment #21
larowlan@andypost - given its still an alpha, I'm happy if we break BC, provided we have a change notice.
Comment #22
andypostproper title
Comment #23
AaronBaumanComment #24
AaronBauman#13 is old enough that i'm gonna have to re-roll from scratch.
significant divergences in the past 12 months
Comment #25
AaronBaumanIn this patch:
- Minimal changeset (in terms of class methods) to split import and export methods into two different classes
- Elimination of ununsed dependencies from constructors, use statements, and service definitions
- Elimination of unused setScanner() method
I don't think an interdiff will be helpful, because of the significant delta in codebase.
Comment #27
AaronBauman- Removes export methods from import interface
Comment #29
AaronBauman- Fix service arguments to match constructors
git is creating a difficult to read patch for this, with a copy and a couple rename operations.
Makes it somewhat hard to read.
Comment #31
AaronBaumanOK, looks like testbot is choking on the patch.
I'll have to hand-roll something to appease testbot.
Comment #32
AaronBaumanOK one more try with services DIC before i do a hand roll
Comment #33
andypostHere's a reroll after #2857589: Remove the run-as option in drush commands
Also I cleaned-up code a bit.
After that I think it makes sense
- to get rid of "DefaultContent" in interfaces and classes because they are namespaced already
- move dumplication of LINK_DOMAIN const somewhere, maybe container param?!
Comment #34
AaronBaumanSo, rename classes to "Importer", "Exporter", "ImporterInterface" and "ExporterInterface"?
And a container param goes where? services.yml?
Comment #35
andypostA bit more clean-up
Comment #36
andypost@aaronbauman yes, exactly, I think that will be more readable and while we do so destructive change better to architect it right
Comment #37
larowlanFuture follow up would be to put this behind a service too, so we could unit test
We should just refer to the constant on the exporter, no need to define twice
Follow up would be to put this behind another service
Why this change - we can't mock static methods
Comment #38
larowlanAlso, still need a change notice
Comment #39
AaronBaumanHere's a new change record: https://www.drupal.org/node/2862246
working on a re-roll now.
Comment #40
AaronBaumanwrt the file_* operations, i'm looking for examples from core. Looks like the preferred way to do this with a service is to create StreamWrapperInterfaces, extending LocalStream (for export) and LocalReadOnlyStream (for import). The stream wrapper would replace the existing Scanner altogether. The Gettext / PO components have a robust example.
To me, this seems like overkill to implement a new stream service just to wrap a handful of PHP functions, especially when we don't really have any special reading or parsing considerations like PO.
Importer::parseFile()
already provides a level indirection which we can mock for testing. RefactoringExporter::writeDefaultContent
to add indirection around function calls should, I think, be sufficient for unit testing. There are dozens of examples of core classes calling file_get_contents directly within a protected utility method, for example to read YAML files.What do you think?
Comment #41
AaronBaumanIn this patch:
- parameterizes link_domain in services.yml and updates relevant classes (Maybe this makes more sense as an install config or setting?)
- splits DefaultContentManager and its interface into Importer and Exporter
- rename DefaultContentScanner to Scanner
- Add ScannerInterface
- Expose Scanner as a service and inject dependency into Importer (rolls in #2861315)
- Add wrapper methods in Exporter for file_prepare_directory and file_put_contents
I had to fudge the interdiff a bit because i couldn't git wouldn't grok the file moves, should be readable though.
Comment #42
larowlanYeah the file_ changes are 100% out of scope here - but something we should create follow ups for.
If we had them behind a service/interface, we could mock or use vfsStream - leading to the ability to use pure unit tests.
But 100% follow ups.
Added some code samples to the change record.
This is ready in my book.
Comment #43
andypost@Berdir please confirm that
could be fixed on commit
Comment #44
andypostI still see this as Component and static implementation
directory totally injectable with vfs
Comment #45
andypostI'm going to commit this soon and continue with #2867579: Core 8.3 compatibility
Comment #46
andypostComment #47
larowlan+1
Comment #49
andypostNow a lot of patches will need re-roll
PS: CR published https://www.drupal.org/node/2862246
Comment #50
andypostI commited follow-up
http://drupalcode.org/default_content/commit/?id=2393ca1
http://drupalcode.org/default_content/commit/?id=8ce6a8f