Problem/Motivation
Typed config's Mapping and Sequence implement ComplexDataInterface and ListInterface. Both implementations are wrong, have a lot of bugs/issues and still worse, none of the interfaces fits 100% these classes intended behavior. Some of the issues:
- Sequence *cannot* implement ListInterface::getItemDefinition() as we simply don't have a unique definition for all items
- Sequence keys may not be numeric if we pretend it to fit any configuration sequence. For this reason and the previous one doesn't fit at all ListInterface
- None of these interfaces can fit some use cases in configuration data, like the ones explained in #2 and #3 (Variable list of items keyed by strings or without explicit keys , like for the case of plugin lists)
- Since the list of items (for both Mapping and Sequence) is built dinamically and we need to parse the actual configuration data for it, they need additional methods on top of those of generic typed data.
- Some parameters of these interfaces like ComplexDataInterface::getProperties($include_computed = FALSE) are meaningless for this usage of them
- Other methods implemented by Mapping and Sequence like get() can take nested keys that while handy for configuration, don't fit the interface definition
Also they are poorly documented and documentation is not up to latest coding standards.
All this is due to a number of reasons, from a poor original implementation to interfaces evolving later on and classes not being properly updated for it -sometimes a method was just copied over, sometimes it was just not possible to implement new methods properly-. But mostly because ComplexDataInterface and ListInterface are more targetted at Entities/Fields/FieldItems that doesn't really fit their usage in Typed Config.
Proposed resolution
Add a new interface that really fits typed configuration and can be cleanly implemented.
Simplify Mapping and Sequence from the unneeded complexity inherited from trying to reuse/implement these interfaces.
Further simplification, moving common code of Sequence/Mapping elements one level up to ArrayElement.
Add proper documentation for all these classes and interfaces and explain existing classes.
Remaining tasks
Review and commit.
Further simplification is still possible, though we are trying to keep the patch as small as possible.
User interface changes
None
API changes
Some, but all of them internal to the configuration system. Changes in core modules or other components are really small -a few parameter types- since most of these methods were never used, so only tests need to be updated.
These API changes are:
- New TypedConfigInterface that is used by both Mapping and Sequence instead of ComplexDataInterface/ListInterface
- Mapping and Sequence are not implementing anymore ArrayAccess interface, that was only used in texts anyway
- TypedConfigManager::get() returns TypedConfigInterface instead of Element (that was an abstract parent class)
Original report by @chx
- The class doxygen is useless. Is it a list of items? Can the keys be strings? What are some examples? When should I use something else for an array
getItemDefinition
contains a fatal error. No, seriously, look at it:buildDataDefinition
is called with two arguments, it requires three. What does this say about test coverage? Do we need this method if it's not called anywhere, code or test?- All the method doxygen are the old style implements instead of inheritdoc.
onChange
is looking forparent
which is not a defined property nor is it clear how would it be set.
This is the diagram of how classes interfaces look before and after this patch.
Comment | File | Size | Author |
---|---|---|---|
#78 | 2298687-78.patch | 31.55 KB | tstoeckler |
#51 | 2298687-previous.patch | 29.04 KB | tstoeckler |
Comments
Comment #1
vijaycs85Comment #2
Jose Reyero CreditAttribution: Jose Reyero commented@chx,
Yes, good points, this still needs some more clean up and documentation.
Mostly we are trying to keep up with TypedDataInterface / ListInterface, which is quite a moving target, so I was thinking of doing the clean up maybe later but anyway now is a good moment for starting too.
Intended to map any yaml sequence, now it will only work for sequences without indexes because of ListInterface (these ones will become numeric indexes at some point in the parsing).
For string keys, check out mapping (Mapping), will it work for you?
To do: Add some docs for both Mapping and Sequence.
True. Method implemented because the interface requires it, not actually used.
To do: Implement properly, add test coverage, so at least tests use it :-)
Right, though I would leave this for a final cleanup, just in case they change their mind again...
It is defined, 'parent' is inherited from TypedData which is the root class for all this.
But you are right it is badly defined, implementation is plain wrong in \Drupal\Core\TypedData\Plugin\DataType\ItemList which is from where I guess someone copied and pasted that from.
(Note $parent is type TypedDataInterface and we, and ItemList, and Map, and everyone else, are calling a method on 'parent' that is not part of the interface)
If we can ever fix TypedData and related interfaces and objects we can copy whatever ends up there.
<whinning> The worst of it is every time someone adds some 'feature' to TypedDataInterface & Family they add here whatever implementation so php parser just won't complain :-( </whinning>
Asigning it to me, I'll be working on a patch to address all these issues in typed configuration, but still, we should fix the "root issue" which is TypedDataInterface / ComplexInterface.
Comment #3
chx CreditAttribution: chx commented> Right, though I would leave this for a final cleanup, just in case they change their mind again...
I believe this standard has been in place for a year. Or two?
> For string keys, check out mapping (Mapping), will it work for you?
No, Mapping only works for known string keys. I have (check config_devel) an array of filename => something.
> It is defined, 'parent' is inherited from TypedData which is the root class for all this.
Erm, nope, TypedData has no property on it called parent
Comment #4
Jose Reyero CreditAttribution: Jose Reyero commentedOk, let's get this fixed.
Really, there is no way Sequence implements properly ListInterface (because we cannot have a single itemdefinition). Also the related Mapping doesn't properly implement ComplexDataInterface. We've been for ages playing catch up with those interfaces and it is becoming worse as they evolve...
This patch:
- Adds a new ListElementInterface that is the one to use for typed config replacing ListInterface and ComplexDataInterface. We don't need the overhead of ComplexDataInterface.
- Simplifies everything, we can get rid of a dozen methods or so, half of them were not properly sticking to the interface anyway.
- Adds some documentation for Sequence and Mapping.
- Replaces occurrences of 'instanceof ArrayElement' with a proper interface, getting rid of some ugly parts (like the test that cannot mock an ArrayElement....)
- **** Allows Sequences to have any type or number of keys. This should work for your configuration data I guess (?)
Comment #6
chx CreditAttribution: chx commented- public function toArray() {
- return $this->getValue();
+ return $this;
That is _odd_ . toArray returns an object? OK, ArrayAccess but it's not an array.
Comment #7
Jose Reyero CreditAttribution: Jose Reyero commented@chk,
Not sure what you mean, $this->value should be either an array or null, it returns the plain config value.
Fixed minor issues, updated tests for the new interface.
(Needed to add onChange() because some contained elements may need it)
@chx,
Do you think this will work for your sequence or array elements?
Still wondering whether to rename ArrayElement to ListElement or ElementListInterface to ArrayElementInterface, but I think name should be the same... any idea about this?
Comment #9
chx CreditAttribution: chx commentedNevermind me, that was a patch artefact; notice it removed the function too.
Comment #10
Jose Reyero CreditAttribution: Jose Reyero commentedLooking at the failed test...
Fixed test mock builder, now using interface instead of class.
Comment #12
Gábor HojtsyRetitled, adding config tag. I think moving the common code one level up makes sense, less maintenance, the differences clearly show.
I think the name is strange. This is not for an element of a list but an element that IS a list.
This combined with the doc on get() that says gets an element is confusing :D
Why?
Also needs issue summary update.
Comment #13
Jose Reyero CreditAttribution: Jose Reyero commentedNew revision of the patch:
- Trying to fix the failing test, ConfigMapperManagerTest, maybe better not changing that part (which was changed by this patch before)
- Fixed issue 1. above, better comment: "Gets a contained typed configuration element."
- About 2. That's a php generic reminder for interfaces that extend Traversable, just copied it from ComplexDataInterface.
Not sure whether you ask 'why the comment', or why the interface behaves like that, which is explained here, http://php.net/manual/en/class.traversable.php
Also I'm thinking, for next patch, that we don't really need ArrayAccess here (we have get/set), I'll be giving a try to removing it. It makes everything confusing by allowing two different ways of accessing contained properties.
Comment #14
Gábor HojtsyThanks! The ListElement class naming still sounds iffy to me. It is not an element OF a list but an element that IS a list. Don't know what better name to suggest though :/ Why not just make it just List? After all other types are not "Element"s either.
Comment #15
Jose Reyero CreditAttribution: Jose Reyero commentedYet another twist to these ugly interfaces:
- Renamed ListElementInterface to TypedConfigListInterface
- Renamed ArrayElement to TypedConfigListBase
- Created a TypedConfig wrapper that extends ConfigBase *************
- Moved SchemaCheckTrait into this new wrapper ********** (No need for trait anymore)
- LocaleTypedConfig extends TypedConfig (and fits nicely into the wrapper structure).
Some notes:
- TypedConfig is not typed data, but a wrapper for typed config items, similar to Config objects (which are wrappers for config data),
- No need for dotted notation in TypedConfigListInterface::get() anymore, so our typed data objects look more like other typed data objects.
In short what we are doing is using still typed data, but also proper config wrapper that doesn't need to implement TypedDataInterface. There are other issues about similar moves for entitites, etc...
Then all the rest fits nicely (included SchemaCheckTrait that doesn't need to be a trait anymore), typed config wrappers just get the ability to test their own schema.
To do:
- Minor clean up, some methods may not be needed anymore, review docs, etc..
- Rename SchemaCheckTraitTest accordingly (just kept for now to point out this works just the same).
- Further simplifications are possible for config translation, locale typed config, etc...
I don't think there's too much point in an interdiff, as this renames about everything...
Comment #17
Jose Reyero CreditAttribution: Jose Reyero commentedJust fixed some docs.
Comment #19
Gábor HojtsyAre all these things still in scope? On a first look this looks carried away a bit honestly :/
Comment #20
Jose Reyero CreditAttribution: Jose Reyero commentedRetaking this one, to be re-targetted and simplified. Assigning it to me.
Comment #21
Jose Reyero CreditAttribution: Jose Reyero commentedThis is a fresh restart from #13, re-rolling for current head.
I think that was the last version that was more or less in scope, quick summary:
- Add own interface for config maps / sequences (forget about ComplexDataInterface, ListInterface)
- Moved common methods from Mapping and Sequence to ArrayElement.
To do:
- Better name, maybe ConfigListInterface / ConfigArrayInterface.. ?
(Really, all the *Element names here are not the best ones, but we better don't get into renaming too much for the patch to be manageable, so good names only for new things, keep old names as they are)
- Simplify the interface, it doesn't need that many methods (most of them inherited from previous interfaces)
- See about reusing this one, #2346129: Introduce a TraversableTypedDataInterface and use that for typehinting instead of ArrayElement
("Needs review" is mostly for testbot to run)
Comment #22
tstoecklerSo this makes a lot of sense, but I think we should postpone it on #2346129: Introduce a TraversableTypedDataInterface and use that for typehinting instead of ArrayElement. Do you agree?
Comment #23
Jose Reyero CreditAttribution: Jose Reyero commented@tstoeckler, yes, agreed.
Comment #24
tstoecklerAwesome.
Comment #25
tstoecklerWell, that was quick.
Comment #28
Gábor HojtsyComment #29
Jose Reyero CreditAttribution: Jose Reyero commentedOk, still assigned to me, so this will be my homework for this week.
Comment #30
Jose Reyero CreditAttribution: Jose Reyero commentedRe-rolled for latest head, specially taking these changes into account #2346129: Introduce a TraversableTypedDataInterface and use that for typehinting instead of ArrayElement
Only for the tests, I'll post next iteration asap.
Comment #31
Jose Reyero CreditAttribution: Jose Reyero commentedAnd this is the patch with a few improvements (more old code being removed):
- Renamed ListElementInterface to TypedConfigInterface, I think better name, since this will be the outermost element of all typed config objects.
- Removed ArrayAccess from the interface. Not needed anywhere, since we have already get/set, and also it was only being used in tests.
- Updated docs, for some return types.
Example TypedConfigManager::get() returns always TypedConfigInterface
Comment #32
Jose Reyero CreditAttribution: Jose Reyero commentedUpdated title and issue summary.
Comment #33
Jose Reyero CreditAttribution: Jose Reyero commentedAdded parent issue
Comment #34
Jose Reyero CreditAttribution: Jose Reyero commentedNeeds re-roll after #2359449: TypedData calls onChange() parent's method that is not part of the interface
Comment #37
vijaycs85Comment #38
rpayanmrerolling...
Comment #39
vijaycs85awesome. Thanks @rpayanm. This is ready for review.
Comment #40
Gábor HojtsyDiscussed at last week's D8MI meeting that due to the patch size, it would be great to have a visual to help review before/after API structure, that would help reviewing immensely.
Comment #41
Jose Reyero CreditAttribution: Jose Reyero commentedRe-rolled the patch with a few changes from #38:
- Removed onChange() method from TypedConfigInterface (it is already defined on the parent interface)
- Fixed docs for isEmpty(), copied from ComplexDataInterface instead of ListInterface which didn't really match
- Renamed get($name) parameter for consistency with the other interfaces.
Further simplifications for TypedConfigInterface:
- Not implementing Countable anymore, not really needed, just updated test
- Removed method getElementDefinition(), again not needed -nor used- for anything, can be a protected method in the class
To do next: Update issue summary with some diagrams.
Comment #42
tstoecklerI think I now finally understand what this patch is trying to do and I like it a lot. It's the next step in making typed config actual typed data.
I still have to spend some time with it to be able to completely grok it, but so far I have one question:
Shouldn't this be
TraversableTypedDataInterface
? Since both Mapping and Sequence (the only implementations) implement both it shouldn't matter code-wise, but when traversing into objects, we never get further typed config objects inside other typed config objects, but we get sequences or mappings (i.e. traversable typed data) inside of config object.That might mean that we have to move
get()
ontoTraversableTypedDataInterface
but I think that would make sense anyway.Comment #43
Jose Reyero CreditAttribution: Jose Reyero commented@tstoecker,
Basically yes, though as you say:
And same for many other methods, if you can reconcile method signatures and exceptions in ComplexDataInterface and ListInterface, which if you look at them are not exactly the same.
However I am trying to keep this patch from touching anything in TypedData and change only the typed config part and for that, the safest bet atm is using 'TypedConfigInterface', which is the one implemented by all config structures and also defining the get() method.
Comment #44
Jose Reyero CreditAttribution: Jose Reyero commentedUpdated issues summary with some diagrams.
Comment #45
tstoecklerThanks for the diagrams, they are very, very helpful!
I'm reviewing the old and new code in context now, so this is me basically thinking out loud:
\Countable
is removed fromArrayElement
(as can be seen in the diagrams). This makes sense as being countable is nothing at all specific to configuration schema. IfTraversableTypedDataInterface
at some point wants to implement\Countable
then it's free to do so, but it makes total sense to remove it here.ArrayElement::validate()
is removed. According to my IDE it is unused within the configuration schema system. Also the parent classTypedData
implements it already. It implements it in a different way - by directly deferring to the constraint validator - but AFAIK the constraint validator should handle nested objects fine, so I don't think the explicit loop in the current implementation should be necessary.onChange()
andisEmpty()
are currently completely identical betweenMapping
andSequence
so they are movedArrayElement
. Nice!\ArrayAccess
.offsetSet()
is currently broken anyway, asTypedDataInterface
is not used. Also becauseMapping
currently inheritsoffsetSet()
there is a very strange mismatch between that andset()
.set()
andget()
are moved intoArrayElement
with this patch. This means that sequence gains support for nested keys. I.e. you can do$sequence->get('0.some.sub.key')
with this patch which strangely did not work before even though$mapping->get('key.some.sub.key')
worked before already (and still works with the patch)ArrayElement
declares anabstract function parse()
which bothMapping
andSequence
implement almost identically except that they get their information from themapping
andsequence
keys, respectively. This patch consolidates the actual parsing logic (because it is identical) inArrayElement
and instead delcares anabstract function getElementDefinition()
in whichMapping
reads themapping
key andSequence
reads thesequence
key. Btw, the end result of this patch is that those methods are the only thing that's left inMapping
andSequence
and that's a good thing. Even though they are conceptually different their native data structures are both arrays in PHP and thus the processing logic can be consolidated for both classes. The only difference is the key they get their information from.Element::parseElement()
andElement::buildDataDefinition()
are not used in any of the other subclasses ofElement
so they are moved toArrayElement
. This makes theprotected $value
the only thing left inElement
. Also,ArrayElement
no longer extends fromElement
but that is wrong because it still used$this->value
which is now referencing an undeclared variable. The fix to this is moving the declaration of$value
up intoTypedData
. That already references it (ingetValue()
but does not declare it. That way we could get rid ofElement
entirely.Mapping::set()
is removed. I'm fairly sure that's not needed anyway, and in any case that code is not present inSequence
so I think it's safe to remove.toArray()
is moved fromMapping
toArrayElement
(so thatSequence
has it as well now. Also it is being fixed to always return an array, even if no value exists.Mapping
no longer implementsComplexDataInterface
and as part of thatgetProperties()
is removed (although)toArray()
is kept. In the same lightSequence
no longer implementsListInterface
andfirst()
andgetItemDefinition()
are removed. It might be convered above, but I'm not sure why that is and this feels very wrong.Mapping
andSequence
are exactly the config-schema equivalents ofMap
andList
(the fact that we need to have config-schema specific versions of those is unfortunate but that's a separate problem)TypedConfigInterface
which extendsTraversableTypedDataInterface
. I think this is wrong and at least some of them should be moved directly toTraversableTypedDataInterface
. Note that bothComplexDataInterface
andListInterface
haveget()
,set()
, andisEmpty()
. So with this patch all three child interfaces ofTraversableTypedDataInterface
provide three identical methods. Let's not do that.toArray()
is only onComplexDataInterface
, not onListInterface
but I think that's an oversight, so IMO it should be added toTraversableTypedDataInterface
as well.getElements()
is sort of specific. Although I do see how we could implement that generically forMap
andList
in the future, it currently has config-specific semantics, so that should stay onTypedConfigInterface
for now, IMO.Some minor remarks on the patch:
Unused
getElements()
usage in the tests, I would prefer to use explicitget()
calls on the actually needed keys, but that's an implementation detail and definitely something I can live with.So in summary this patch is a lot of awesome, but the missing
$value
inArrayElement
is certainly a needs work and IMO theTypedConfigInterface
and the lack ofComplexDataInterface
andListInterface
need work as well.Comment #46
Jose Reyero CreditAttribution: Jose Reyero commented@tstoeckler,
Thanks for great review.
Re-rolled for latest 8.0.x
- Fixed both remarks in #45 (Removed unused TypedConfigInterface, added ArrayElement's $value)
- Removed leftover Sequence::filter() method, introduced in https://www.drupal.org/node/2365585
About the rest, not sure if there are any other actionables in there.
??
Comment #49
tstoecklerSorry for my absence on this issue. I have an updated patch which makes clear my current reservations against the patch and how I would envision this to work. Since it's not meant as an iteration on the previous patch but "my take on this" which we might ditch or adopt or meet somewhere in the middle I didn't want to spam this issue with a bunch of patches, so I've been "hiding" in a testing issue thus far. It's not quite green yet, as soon as it is, I will post it here together with some thoughts.
Comment #50
Gábor Hojtsy@tstoeckler, @reyero: The window for API changes is gradually closing. It would be great to come to some agreement ASAP so the perfect will not be the enemy of progress on this one :/
Comment #51
tstoecklerI had a big summary written up about this but lost it. So here is the patch for now. I rerolled the previous one to provide an interdiff. Will hopefully get around to explaining this later today.
This *should* pass but I did make one last-minute change so crossing fingers...
Comment #53
tstoecklerHehe, it passes on PHP 5.5...
Comment #54
tstoecklerOk, so here's my second attempt at explaining what my patch does.
In writing the below I noticed two oversights in my last patch, which the attached one fixes.
getItemDefinition()
,filter()
andfirst() are reintroduced to <code>Sequence
. Because the latter method is identical between Sequence and ItemList (and in general rather generic) I introduced a ListTrait for the two to share. I'm not a big fan of having to implement these methods, but to my mind the argument given above wins over that. I think we can explore removing those methods from ListInterface and e.g. into FieldItemListInterface as I suspect that is where they are actually being used. If you feel strongly about this we can also explore that here, of course.$notify
parameter, which I am not really excited about. Again, though, I think the consistency we gain with this is more important. We can always look into removing$notify
from the interface in the future.getProperties()
which I simply renamed. Again, we inherit the$include_computed
parameter from ComplexDataInterface, which is not great, but not terrible in my opinion. The consolidation also means that we have to implement this method in ItemList, which is rather trivial, though.$item_list->getItemDefinition()
and$map->getDataDefinition()->getPropertyDefinition($name)
. We could look into removing that function alltogether in the future, maybe. As callingListInterface::getItemDefinition()
(i.e. without a specific argument) is useful, I kept that method around.iterator_to_array()
.Note that in aggregate this makes ComplexDataInterface empty, which is strange, but perhaps also something we can explore improving in a follow-up.
$value
as a member variable.$this->value
is already used in its parent, TypedData, though, so it makes more sense to simply document it there. That lead to an interesting problem, which is also the reason it took me ages to get this patch green. SeeFieldItemBase::__construct()
if you feel like headdesking.$parent
in a few places.Comment #55
Jose Reyero CreditAttribution: Jose Reyero commented@tstoecker,
While I think it is a good idea to promote TraversableTypedDataInterface and move some methods there, and moving some part of ListInterface to FieldItemListInterface is a smart move, I don't think this really fixes the issue with typed config which was it not implementing these interfaces cleanly -just because it was not possible.
If you look at the list in the issue summary (Problem/Motivation), this latest patch doesn't really fix all those issues and we are still left without proper implementations. However the patch makes a lot of progress about cleaning up TypedData interfaces.
Some examples of this:
1. Sequence::getItemDefinition(). A Sequence doesn't really match ListInterface which:
• "contains only items of the same type", our (config) lists don't and that's why we cannot really implement getItemDefinition().
• Also Sequence::getItemDefinition() makes the assumption that keys are numeric, configuration keys may or may not be numeric.
2. TraversableTypedDataInterface::set()
* @throws \InvalidArgumentException
* If the specified property does not exist. ??? This was not previously consistent behavior for lists and maps. How are we supposed to add elements to a list then?
3. TraversableTypedDataInterface::get()
As per the interface it doesn't support dot-notation but config elements do support it.
ComplexData get() throws exception when the key doesn't exist
Itemlist::get() just creates a new item
Those are some of the reasons why I think we'd be better off with a proper typed config interface. Even when you try to fix these typed data interfaces they don't really match our case and that is why I'd rather consider having typed config as an extension of typed data.
Maybe, as all of the classes really lack documentation, it is some help trying to clarify the ideas behind all of these objects. This is some summary:
ComplexDataInterface (typed data)
Map (named keys). Keys must have some DataDefinition. Trying to get/set keys that don't throws exception.
ListInterface (typed data)
List (orderable, numeric keys) I understand keys don't really matter, just order...
Keys don't need to be defined...
Mapping (typed config)
Map (named keys)
Unlike complex data, we don't have / cannot create elements when we don't have the value, even if the key is defined.
Sequence (typed config)
Map with a generic definition that is used for all items (but unlike ListInterface, the definition needs to be computed with actual configuration values)
Also unlike ListInterface, keys are meaningful (maybe uuid, plugin id, etc...)
We should be able to add new elements on the fly, but only with set(), not with get()...
So, quick summary: I like the patch, though it doesn't really fix this issue, but it fixes many other things.
Comment #56
Gábor HojtsyFYI: #2414953-2: Element uses \Drupal::service() as a service locator and prevents injecting a custom typed config manager in config.
Comment #57
tstoecklerThanks for #55, I agree on all points.
So I basically moved all changes from my interdiff out into the following issues:
#2420055: Document $value in TypedData
#2420049: Move \ArrayAccess from ListInterface to FieldItemListInterface
#2420067: Promote usage of TraversableTypedDataInterface
That allows us to go back to your patch, which I rerolled. With an eye towards #2420067: Promote usage of TraversableTypedDataInterface I'm also uploading a patch with makes
ArrayElement::getElementDefinition()
public, as that one introduces such a (public) method onTraversableTypedDataInterface
.Marking RTBC regardless. It's @Jose Reyero's patch, I just re-rolled it (twice), and the change from protected to public doesn't count as a significant contribution IMO. And if the change to public is not deemed appropriate for some reason, then the other one is RTBC.
Comment #58
tstoecklerAhh, was about to open a bug against 8.0.x but realized there is in fact a problem introduced with this patch.
Also attaching the interdiff now, I meant to upload in the previous comment.
Comment #63
tstoecklerYeah, the re-roll after #2414953: Element uses \Drupal::service() as a service locator and prevents injecting a custom typed config manager in config was not quite correct yet.
Also fixed come incorrect docs that were introduced with this patch.
Comment #66
tstoecklerConflict on #2164601: Stop auto-creating FieldItems on mere reading of $entity->field[N]. Since that change was only added because
Sequence
implementsListInterface
in 8.0.x (but not with this patch) there's nothing we need to do here.Comment #67
tstoecklerBack to RTBC per #57.
Comment #68
Gábor HojtsyAs per the issue summary Both implementations are wrong, have a lot of bugs/issues and still worse, none of the interfaces fits 100% these classes intended behavior so should be bug.
Comment #69
alexpottWe should go with the non-public patch since making it public can easily be done in #2420067: Promote usage of TraversableTypedDataInterface
This is great clean up. Thank you. This issue is a normal bug fix, it's disruptive changes are disruptive to anything extending config schema internals - highly unlikely at this point - and the cleanup reduces complexity and fragility, so it is allowed per https://www.drupal.org/core/beta-changes.
Some things before I can commit:
This probably has been broken for sometime. There is no TypedDataInterface available in this scope to be able to make this comparison.
That should be
@param string $key
Comment #70
hussainwebFixing as per #69. The changes are against the non-public patch in #66, i.e. 2298687-66.patch
Comment #71
alexpott@hussainweb ah my point with #69.2 is that this must be dead code.
Comment #72
alexpottAnd untested :)
Comment #73
hussainweb@alexpott: I think you meant #69.1. I see what you mean about dead code. I quite agree, but what do you propose? Adding tests? I don't think you implied removing the code itself.
Comment #74
tstoecklerYes, I've seen that quite a few times before and was never quite sure what to do with it. That's why I opened #2420383: Missing typehint in ArrayElement last week. I think that's a non-trivial issue including test coverage and everything and since it's not introduced here (and this patch is already quite complex) I think it's fair to handle that in a separate issue.
Re-RTBC-ing because of that, but I hope that's not received as status ping pong. Feel free to disagree, as always, and un-RTBC.
Comment #75
tstoecklerAhh wait. The last patch already adds the use statement, so that contradicts solving it in a different issue. (... which still would make sense IMO.) That means the patch is not RTBC as it is.
Comment #76
alexpottyeah @tstoeckler I think we should remove it as it cannot be being used.
Also looking at it
Is also wrong because in the patch in #66 it can not be a TypedDataInterface and it can be in the patch in #70 but it is completely untested (and apparently not needed).
Comment #77
yched CreditAttribution: yched commentedThis is largely over my head atm, but sounds like an awesome cleanup from the outside. Sequence kept getting in my way when I was working on ItemListInterface :-)
Just - noob remark of the day :
core/lib/Drupal/Core/Config/Schema/Element.php has a stale "use" on TypedConfigManagerInterface
core/lib/Drupal/Core/Config/Schema/TypedConfigInterface.php has a stale "use" on TypedDataInterface
Side note : it's a bit sad that core/lib/Drupal/Core/Config/Schema is a unsorted bag of very different animals (some TypedData classes, two exceptions, a discovery, a trait...). Not introduced here, but... anything we can do here or in a followup ?
(then again, the parent directory is much scarier - ah well...)
Comment #78
tstoecklerSo I wanted to check every usage of
TypedConfigInterface::set()
with this patch. Now note that object creation in Drupal is very "multi-faceted" to say the least, so I certainly might have missed something, but I did give it my best shot and spent quite some time on this. I only found a single instance of this usage in all of core and that is inConfigSchemaTest
. A test patch I uploaded confirms this finding.So I will open a follow-up to discuss removing that function alltogether. But for the scope of this issue it most certainly is fine to remove the "ability" to pass in typed data objects (which doesn't work anyway, as stated above).
That's what this patch does. As this is my only code contribution to this patch and it has been specifically requested and signed off by @alexpott, I am being bold and setting this to RTBC directly. As always, feel free to be bold and disagree.
Edit: And that one usage in
ConfigSchemaTest
sets a simple value directly and not a typed data object.Comment #79
tstoecklerThat's #2429157: Remove TypedConfigInterface::set().
Comment #80
alexpottThis is an almighty cleanup. Thanks. Committed 4337033 and pushed to 8.0.x. Thanks!
Thanks @yched - fixed on commit.
Comment #82
alexpottReverted and committed 9026147 and pushed to 8.0.x to fix the docs:
Comment #84
Gábor HojtsyAmazing, unbelievable! Yay! Thanks @reyero and @tstoeckler for sticking to this for so long. It was worth it :)
Comment #85
yched CreditAttribution: yched commentedAwesome cleanup indeed! Congrat folks :-)
Comment #86
tstoecklerAhh, sorry forgot about the docs. Thanks @alexpott, also for bringing this forward. Awesome!