Updated: Comment #0
Problem/Motivation
This is a follow-up of #1709960: declare a maximum length for entity and bundle machine names. There we agreed on a limit of 32 characters for entity bundle names, but comment bundles are somewhat special because it's a compound ID of the commented entity_type and the field name. Eg {entity_type}__{field_name} ala node__comment.
Proposed resolution
Add a comment-type simple config entity with name, description
Move description field setting to property of comment-type
Add selection form for comment-settings form to choose existing/add new comment-type. Can't be changed once field is created.
Remaining tasks
Write patch
User interface changes
A field setting would be nice as it would also allow to use the same comment bundle for different bundles, something that is right now not possible. That setting would need to be read-only. See original comment: https://drupal.org/node/1709960#comment-8606897
API changes
FieldItemInterface::settingsForm is passed $form by reference
\Drupal\comment\CommentFieldNameItem removed
\Drupal\comment\CommentFieldNameValue removed
\Drupal\comment\CommentInterface::getFieldId() removed
\Drupal\comment\CommentInterface::setFieldId() removed
\Drupal\comment\CommentInterface::setFieldName added
\Drupal\comment\CommentInterface::getTypeId() added
\Drupal\comment\Controller\AdminController::overviewBundles() removed
\Drupal\comment\CommentManagerInterface::getFieldUIPageTitle() removed
\Drupal\comment\CommentManagerInterface::addDefaultField now accepts 5th optional argument, comment type ID
\Drupal\comment\CommentManagerInterface::addBodyField arguments changed from entity type and field name, to comment type id
\Drupal\comment\Routing\CommentBundleEnhancer and associated test removed
| Comment | File | Size | Author |
|---|---|---|---|
| #162 | 2228763.162.patch | 135.37 KB | alexpott |
| #162 | 161-162-interdiff.txt | 4.41 KB | alexpott |
Comments
Comment #1
larowlanMakes sense, will tackle tomorrow unless someone beats me to it.
Comment #2
berdirWhile not directly blocked, it might be easier to tackle this after the related issue gets committed (which will hopefully be *soooooon*), as that adds some helpful constants.
Not sure about the issue status of this one, it is essentially part of a critical beta blocker, but that is more about defining the ruleset, enforcing it in the API is less important I think. As this is an API change on it's own, might still be a beta blocker. @xjm?
Comment #3
xjmTagging as a beta target. I don't think it's beta-blocking on its own since it's only going to affect the comment module API and functionality, not the data model or the Entity API itself. (I do think it's worth a mention in the release notes if we don't sort it by then; inventing a new tag to that end.)
Once #1709960: declare a maximum length for entity and bundle machine names lands, as far as I can tell, HEAD will be extremely restrictive for comment bundles, capping them at
EntityTypeInterface::BUNDLE_MAX_LENGTH... right? So if you try to make a comment field with a 16-character name on an entity type with a 16-character ID, it will blow up in your face, because that plus thecommentprefix and the magic underscores is over 32. Would we have to override the entire entity constructor for comments?It would be really great to put some examples in the summary of how the comment bundle is composed and what a few config object names with it would look like (a hypothetical field, instance, etc.). @Berdir has given me examples at least twice but I can't find a comment with them anywhere. :) The ones in my active config in my D8 installation are:
...but sometimes the word "comment" is the module name here, and I think other times it's the name of the shipped default comment field on nodes. Right?
Comment #4
berdirThe problem is that if we'd do the switch to use a setting of the field as bundle, it would completely break all comments unless we provide a possibly non-trivial upgrade path (ah, maybe not if we'd default them to use the current bundle as their setting).
No. HEAD can only validate known bundle entities, comment bundle's are a virtual construct, there's no way to do this. Even if we'd say that field_instances are the bundles of comments, that's a) not correct because we don't account for the . => __ replacement and it's limiting because right now, bundle_of is a 1:1 relationship. Nothing else could use field instances as bundles then.
The only thing we could do is validate them once they are defined in hook_entity_bundle_info(). But that would duplicate the preSave validation added in the parent issue, which is preferrable as we can validate that *before* we create the bundle, validating after won't make it go away.
The config bundle is
{commented_entity_type}__{fieldname}.One thing, as commented in the other issue is that we could make an exception to a certain degree because we *know* comment bundles only happen on comment, which only uses 7 of the allowed 32 characters, so it could give the 25 additional ones to the bundle length. That will however pose a problem when the bundle is stored somewhere on it's own and that relies on the new 32-constant. So not sure that's a good idea.
Comment #5
larowlanWhat about this?
Includes the constant
Comment #6
larowlanAnd probably should check the type
Comment #7
berdirThat adds validation for what we have, but the problem is that entity_types themself can be up to 32 characters long, which makes them un-commentable with the current implementation.
There's an example in #2220757: Limit length of Config::$id to something <= 166 characters about adding fields to commerce_order_line_item or an entity of similar length, the exact example there is no longer relevant, but that entity type is already 24 characters, which leaves 32-24-2=6 characters for the field name, and since the field_ prefix is 6 characters, it is impossible to add fields to that entity type without changing/removing the default prefix.
Comment #9
berdirThis also turned up in https://drupal.org/node/2116363, where we did run into a recursive loop because comment.module needed the field map to define the bundles but the new field map method there needs the bundles.
I think it would simplify the handling there if we could keep track of comment bundles in a simpler way, like a simple config file or a config entity and it's the only way we could support comment fields as base fields.
Comment #10
larowlanNew title?
Comment #11
larowlanWIP patch, progressing well, lots to move though obviously
This has to be major and beta blocker b/c database changes.
Comment #12
andypostIn real the bundle for comments is a field instance entity reference + label & admin description
At the same time having a real config entity nice idea, so +1 here.
Actually this entity could carry "entity_type" and "field_name" inside, allowing us to get rid of this fields in comment table.
So maybe file a follow-up to change schema as well, also performance could be affected by this change
Comment #13
xjmOnly critical issues are beta blockers, and only core maintainers should add the beta blocker tag. Have you discussed this issue with a core maintainer? How critical is this change?
Edit: didn't see at first that this started out as the comment bundle name length issue and I just tried to add it as a reference here. :P
If it's not critical, it can be either or both of "beta target" (we're not going to block the beta on it, but we should really have it done) or "beta deadline" (if it's not done by beta, it needs to wait for 8.1 or 9.0).
Comment #14
xjmFor the record, it does sound like a beta blocker to me, and a more sensible architecture. :) But let's get a maintainer to look at this.
Comment #15
larowlanMore work in progress
This allows us to clean up a lot of cruft fwiw.
Comment #16
alexpottTo quote @Berdir
If we're going to have the ability to add a comments to any entity type then we need to be able to add comments to them. This is both critical and beta blocker.
Comment #17
xjmThanks @alexpott!
Comment #18
larowlanAnother pass, getting some passes locally now.
Comment #19
berdirShould we check with testbot then? :)
Comment #22
larowlanAnother API change, FieldItemInterface::settingsForm needs to have $form passed by reference. Could be a separate issue t.b.h.
Comment #24
larowlanmissed an rdf mapping
Comment #25
larowlanComment #27
larowlanLet's see how this goes
Comment #28
larowlanGreen: bring on the reviews!
Comment #29
jibranI know you mean architecture review but here are some minor issues.
Let's do it then.
This is not @deprecated but I think we can also use injection here.
doc blocks missing.
I think we can use $entity->urlInfo()->toString() here
Why don't we have an access controller fo this?
add-form missing.
We can introduce $this->id() method.
Doc blocks missing.
typo
Comment #30
tim.plunkett#29.4, no this is correct. toString is for urls only, doesn't help with links.
Comment #31
jibranOk then we have to override the constructor so that we can inject
\Drupal::linkGenerator()Comment #32
larowlanNote to self: We need some local actions/tasks for the comment-type pages/forms
Comment #33
larowlan29.1, 29.3. 29.6-29.9, 32 fixed
29.2 its not a simple wrapper, so that would mean duplication, prefer to leave until it is deprecated.
29.4 ignored as per 30
29.5 Added new permission instead, its a simple config entity, so kept it simple.
Comment #35
larowlanMissed perm in tests
Comment #36
larowlanFixes 31
Ready for reviews again..
Comment #37
larowlanTo the fourteen followers here - any chance of a review? This is one of the criticals blocking a beta
Comment #38
andypostPatch is pretty solid, new functionality covered with tests.
Some points in my review are questionable because I still not fully understand the relation
"comment type" => field => commentthat causes toentity_load()the type config entity.the new schema changes needs adjust a size of fields and indexes
the api change with
&$formlooks reasonable just not clear is this affects a serialization of the forms.probably better to use static methods and
get_class()to attach additional validation & submitI think there should be a follow-up to move this field to config entity, probably with entity_type
not sure it make sense to provide default value
comment_type is not needed 32 limit as it is already.
field_id should be adjusted with current limit (probably 32)
entity_type is 32 new
great!
any reason to introduce API change
awesome!
Suppose in follow-up we add field_names[] to allow apply this for a set of fields
Suppose better to add getTypeiD() like TermInterface does
this needs inline comment about that "type" created silently
Defaults to "comment"
CommentTypeForm - no more formControllers now after #2238077: Rename EntityFormController to EntityForm
Suppose better make it in routing.yml
it's not clear why comment type does not know its fields
is this needed?
hook_schema() and other places defines this as "comment"
is this really not needed now?
Nice DX achievement!
needs follow-up
what for?
Comment #39
larowlanA comment-type contains the references to the targeted entity type only.
The field contains a reference to the comment-type.
Several fields on a given entity-type can use the same comment-type.
Eg this is allowed
Comment-type 'debate' - references node.
Node type 'debate' with field 'for' => uses 'public' comment type.
Node type 'debate' with field 'against' => uses 'public' comment type.
Node type 'bar' with field 'Comments' => uses 'public' comment type.
But this is not
Comment-type 'comments' - references node.
Custom block type 'comments thread' with field 'comments' => uses 'comments' comment-type.
Because the comment-type is only for nodes.
This is because of the entity_id field on Comment, the definition needs to set the target type based on bundle - so one comment-type (bundle) can only reference one target type.
Will address as per your detailed review
Typed-data doesn't support container-injection so there should be no container-services etc that can be injected.
1) The relationship goes the other way, several fields can reference one comment-type. See above for reasoning. Also this allowed for the smallest patch size, as much of the comment code is tied to field-names.
2) Will remove
3) Will fix
4) Not sure what you mean
5) :)
6) Its an exists callback for a machine name field only
7) :)
8) Again, relationship goes the other way field -> comment type
9) Not sure what you mean
10) Will do
11) Will do
12) Will do
13) Will do
14) Again, relationship goes the other way
15) This defaults to the form showing the 'add new comment-type' nested form
16) Yeah, we move it to the comment-type form instead - another major win from this patch
17) :)
18) #2053415: Allow typed data plugins to receive injected dependencies
19) They don't fire if #submit or #validate isn't null.
So that leaves 2,3, 10-13 to fix.
Not sure on 4 and 9 - can you get back to me on those so I can address in one pass?
Comment #40
berdir#2116363: Unified repository of field definitions (cache + API) will add a Fieldconfig::loadByName($entity_type_id, $field_name) :) that issue will also conflict quite a bit with this and is almost ready...
One question that came up there is if this will also allow to define an entity type with a comment base field and then manage it properly, that became obvious in that issue that this is currently impossible.
We're not doing this anymore... See #2190313: Add $EntityType::load() and loadMultiple() to simplify loading entities, reviews there would be great, want to get that in.
That help doesn't seem to make much sense?
Hardcoding that here seems... weird?
Do we need to care about config dependencies somehow here? Do we, can we, make the fields depend on this?
We should really have a base class for all those bundle config entity types that automatically invoke those methods :)
And some comments on the above two comments:
2. Yeah, schema-level default values will go away anyway in #2183231: Make ContentEntityDatabaseStorage generate static database schemas for content entities.
3./4.) entity_type and bundle lenght is now limited to 32 characters, so you don't need to limit the length on all those indexes.
9. As I understand it, he's suggesting to add a comment-specific method that returns the bundle, similar to getVocabularyId() on terms, as that often makes more sense when reading the code.
Comment #41
larowlanpostponed on #2190313: Add $EntityType::load() and loadMultiple() to simplify loading entities for now, but will re-roll in the meantime
Comment #42
andypost@larowan about 4/9 exactly what @berdir said:
4) no more need in 32 in index and key
9) special method to get bundle name (comment type)
Comment #43
xjm@larowlan, this is a beta blocker, but #2190313: Add $EntityType::load() and loadMultiple() to simplify loading entities is just a major task, so we probably shouldn't block this issue on that one. Setting back to NR for now. (That said, #2190313: Add $EntityType::load() and loadMultiple() to simplify loading entities is a personal favorite and I'd love to see it go in too.) :) Maybe we could provide a -do-not-test.patch that shows what it would be rolled against that change?
Comment #44
berdirThe changes/overlaps with the load issue are minor, it will not conflict with that I think.
The one that does overlap a lot is #2116363: Unified repository of field definitions (cache + API), which is a critical beta blocker as well, so postponing on that would be OK.
Two related small issues that I created in the meantime are #2261401: Automatically provide bundle info/list based on bundle_of annotation. and #2261369: Introduce a common config entity base class for all bundle config entity types, which will save a few lines of code but worth waiting for...
Comment #45
xjmMakes sense; postponing on #2116363: Unified repository of field definitions (cache + API).
Comment #46
xjmActually setting postponed.
Comment #47
jessebeach commentedUnpostponed!
Comment #48
jessebeach commentedComment #49
xjmCorrect status.
Comment #50
effulgentsia commented36: comment-type-2228763.10.patch queued for re-testing.
Comment #52
larowlantackling reroll and fixes
Comment #53
larowlanFixed 38.2-4, 38.9-13.
Fixed 40.1 via re-roll
40.2 still not in HEAD
Fixed 40.3
40.4 its how it is in HEAD now, an same functionality as D7
40.6 you did and its in, so re-rolled
40.5 attempted but had no luck - couldn't access protected dependencies property or protected addDependency method on the field config with type comment.
Comment #54
berdir40.4: True, it's an existing issue but you can't compare it with D7 because it wasn't configurable there. We don't need to fix it here, but we should open an issue for it so that we can expose it per field or something.
Comment #56
alexpott@Berdir and @larowlan re 40.5
You get bundle entity dependency for free with field instances!
field.instance.comment.comment.comment_body after installing the standard profile has the correct dependencies AFAICS.
field.instance.comment.comment_body after installing the standard profile has the correct dependencies AFAICS.
comment.type.comment after installing the standard profile has the correct dependencies AFAICS. N.b. the dependency on the comment module is implicit.
Also...
Having fun with behat? :)
Comment #57
alexpottTalked with @Berdir on IRC
So we in the examples above we need field.instance.comment.comment_body to depend on comment.type.comment because the field is linked in its settings to that particular bundle.
Comment #58
jessebeach commentedWhy is this function signature being changed?
Comment #59
jessebeach commentedThe 32 should be a constant.
This 32 should be a constant.
Comment #60
larowlan57 will file an issue and postpone this, have the patch in my head
58 so field types can add submit and validate callbacks
59 this is in head, can we open a new issue?
Comment #61
larowlanInterdiff towards fixing fails (just one in migrate to go, which is because of the change to field info)
Patch coming after re-roll
Comment #62
larowlanOk, I can't get MigrateDrupal6Test to pass, so chasing some help, seems related to #2116363: Unified repository of field definitions (cache + API)
On this list core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCommentTest.php:89
We're not getting the 'comment_body' field.
Clearing field definitions doesn't help.
The bundle is definitely correct (comment).
So something not right.
Any help would be appreciated.
Re-roll after #2190313: Add $EntityType::load() and loadMultiple() to simplify loading entities
Comment #64
larowlanAdded #2271419: Allow field types, widgets, formatters to specify config dependencies for 57
Comment #65
larowlanAnother re-roll, things move fast
Comment #67
larowlanmore fixes
Comment #69
larowlanMore fixes
Comment #71
larowlanThe fail is because line 89 of \Drupal\migrate\Plugin\migrate\destination\EntityBaseContent isn't returning the comment-body field.
The bundle looks to be correct.
Comment #72
berdirHad a look at the test, the setUp() is only executed for the single-run mode. MigrateDrupal6Test.php runs the test methods without calling the setUp() methods as it expects that the migrations alone create the complete environment.
Which makes sense, because that's what a real migration run will need to do.
Somehow, we need to "migrate" the default comment type out of thin air... :)
Comment #73
chx commentedThat's hardly a problem, just find a handy plugin that provides a single row (variable does that just make sure you provide a variable surely existing in D6) and then use the constants feature.
Comment #74
larowlanThanks chx, did so using site_name variable
Also thanks to @benjy for advising that I need to add the migration to the test too
Comment #76
larowlanWrong method, doh
Comment #78
larowlanSo the issue remains that sub-tests of MigrateDrupal6Test don't get their setUp methods run.
Not sure if that is by design.
If it is, then I'm not sure how the comment_body field is built in HEAD.
But wherever that code is, I suspect it uses the wrong bundle
Comment #79
larowlanFound it!
Comment #80
larowlanFingers crossed
Comment #81
larowlanComment #82
chx commentedI am unhappy with
this makes it impossible to migrate into another bundle if someone wants. Other destination plugins do not call row->setDestinationProperty at all. And they should not, that's not their role. So, is this really necessary? I saw you are setting comment_type to a constant comment anyways in d6_comment.yml . If it is necessary we need to talk about migrate architecture...
Edit: the source is the mine, the process is the factory, the destination is just the department store. It is hardly the role of the store to fix the broken wares even if it's like the good ole' soviet padlock which could be opened with a finger however it needed a key to close it. http://youtu.be/LGq2TUQ01zk?t=2m15s (dubbed in Hungarian but you can see it).
Comment #83
chx commented> So the issue remains that sub-tests of MigrateDrupal6Test don't get their setUp methods run.
> Not sure if that is by design.
It is, that's the point of the whole thing: single tests call D8 APIs in their setUp to make a test which tests a given migration (and allows easier debug). MigrateDrupal6Test is about the integration of it all.
I guess the site_name variable will always exist (cos it's on the installer form), good call.
Edit: menu_expanded, menu_masks, css_js_query_string and clean_url are other good choices. I would include a few of them just to be sure. Variable always returns a single row so it's not like adding more variables will break you.
Comment #84
larowlanThe set destination property is only called on the stub. Is that OK?
Comment #85
larowlanFixed #82 and #83
Some more reviews please? Lets get this in and knock off another beta-blocker, in the process unlocking some more comment module issues.
Comment #86
berdirThis shouldn't have a default, #2183231: Make ContentEntityDatabaseStorage generate static database schemas for content entities will do away with them, and while that will remove the schema, removing it now might catch possible troubles early.
You should be able to remove this completely now.
Use CommentType::loadMultiple()?
@var should no longer be needed.
This whole thing is useless, it was needed when we built entity objects from scratch on form submission, we no longer do that. We already removed it from nodes.
A bit hard to follow the context here, but why is this necessary now and wasn't before?
Nitpick: unecessary space?
I remember there was a problem with this, but what's the reason you do an entity type check here? This is only called for your class, the only difference would be if this class is used for multiple entity types.
CommentType::load() :)
FieldConfig::loadByName() and remove the @var...
I have no idea why we use camel case sometimes and sometimes not, but I do prefer not using camel case on config entities.
We've been discussing if this behavior is really correct and if we shouldn't do this in the UI only. For example, this makes it impossible to provide a default comment type that does not have this field (sync works, but not install). But we should probably keep it consistent and change it everywhere together.
can't we use an empty string or something that's not a valid config entity type ID for this, would be very easy to mess with this if you create a comment type named "new" ? ;)
storage controller => entity storage or something, we eventually want to avoid the term "controller", and until then, CommentType::loadMultiple() :)
Comment #87
larowlanFixes #86
With #86.5 made it consistent with node, which meant adding language selector field to get language tests to pass.
Comment #88
larowlanComment #89
gábor hojtsy@larowlan asked me to look at the last interdiff. The language selector looks sane :) I should do some manual testing when I have time to see it works as good as any other entity language selector.
Comment #90
xjmComment #91
gábor hojtsy87: comment-type-2228763-2.ebe82dd.patch queued for re-testing.
Comment #93
larowlanRe-roll for
field_info_instance()Comment #94
xjmRerolled for PSR-4.
Comment #95
jessebeach commentedCreating a new comment type on the field settings form results in an error.
Comment #96
jessebeach commentedComment #97
jessebeach commentedClicking the "enable language support" link on the field settings form results in an SQL error, but this is an unrelated error. I verified that a text field settings form will lead to the same error. I logged this separately.
#2275905: Clicking the enable language support link for a field settings form results in an SQL Insert error
Comment #98
jessebeach commentedaha, I think this is a Drupal States issue and something I'm quite suited to fix :)
Comment #99
jessebeach commentedAlright, fixed that. The select option was missing a value, so the States code was not firing against it.
Comment #100
larowlanI didn't update the states code, another one where we need front end testing.
The states code must still ref 'new', needs to be ''
I'm away till Monday so if someone else is able to reroll with that fix?
Comment #101
larowlanSee 86.12
Comment #103
jessebeach commentedGood point about the possible config entity name clash larowlan. I hadn't thought that an empty string would work so I didn't even bother trying, but it turns out it does work. So here's the reroll with the empty string.
Comment #104
larowlanThank you @jessebeach! I think we're close now...
Comment #105
gábor hojtsyI reviewed language + language selector + translation support on this one and it does work well. I found #2276387: Translate routes should properly inherit admin path use from edit route on the way (and some other bugs that I need to see if I can reproduce), but those are not related to the patch. The only actual issue I found with the patch is the default visible bundle name: "comment" is totally not in line with all the rest of the config entity labels which are capitalized. The lowercase option looks odd when selecting a comment type. Users are very likely naming their type uppercase and the "Add new comment type" is also uppercase. Should be an easy fix.
BTW I also found out that the right translation of the comment was not showing when switching language but that is *very* likely has nothing to do with this patch as comment translation is a previously available feature.
Comment #106
larowlanFixes case and merges against #2259243: Database schema of content entities is automatically generated based on entity type and field definitions
Not sure how successful that will be, fingers crossed.
Comment #108
xjmEdit: sorry, commented on the wrong comment beta blocker. ;)
Comment #109
larowlanHow about this
Comment #111
larowlan109: comment-type-2228763-2.57ac5bb.patch queued for re-testing.
Comment #113
larowlanfield name is no longer calculated
getting some uber-screwy fails locally, but I think they're from my drive, which is on its last legs
Comment #114
xjmExciting, this is getting close! Can we get:
Comment #115
larowlanUpdated #2100015: Comment settings are now a field. Comments allowed on any entity type. to reference this.
Added full list of API changes thus:
Comment #116
larowlanMore reviews please. This is one of the fifteen beta blockers, let's get it in.
Comment #117
pwolanin commentedSo, this is minor, but it would be nice if the naming was consistent. I see e.g.
So, the same thing is called the "comment type ID", "comment type", and "comment bundle"? I guess this kind of mismash is all over core though.
This line in CommentStatistics seems a little funny, since it's hard-coding the default field name only?
Comment #118
berdirDid some manual testing, looks like the "Create new" selector when creating a new field is still broken, doesn't display anything and then fails validation.
It does work when disabling javascript. Everything else worked fine when I tested it (didn't test advanced stuff like search and views integration, though), leaving the tag for the #states stuff for now, can be removed once that works IMHO. We already know that search integration only works for the default comment type, that was the case before, I'm OK with a follow-up there, see below.
Missed this before but field names are limited to 32 characters, which means that you can limit it here as well and further simplify the primary key below.
You should use FieldInstanceConfig::loadByName() here, because you're really looking for configurable fields explicitly, not any field definition. Should also be a bit easier.
As discussed before, this is not a problem of this patch as it was hardcoded before but we should create a follow-up issue for this.
I think we lost the improvements here that we made with the entity_type length and bundle length should now be correct automatically if it's defined as an entity reference to the config entity type.
Do we really want to make this a link? It points to the edit form, that we already explicitly hide below edit fields operations.
Node type labels are not linked either, I think it's common that if those are linked, they lead to a view page?
Ah, you're not doing this yet, I think this should be entity_reference, with a target_type setting, then the max_length will be correct automatically.
While it's technically the same value, I'm not sure if it's correct to use that constant here too.
id should be ID
#states to make the fields below required would be nice, not that important.
You can use CommentType::create() now for this.
This could also use the new ::create() and other new code too.
Could we add this to CommentTestBase, then other tests can use it too
this depends on itself? Not sure what it has to depend on, probably only the node and comment modules?
I'm not sure if "comment" makes sense as a default type, would "default" make more sense? Would be ugly to change now I guess, so don't do it just based on my opinion. It's different to before (node_comment) because then it was a combination of entity type and field name.
We still have some minor bugs if bundle == entity_type, for example the form ID is inconsistent.
Description says default comment field, field => type?
@pwolanin: Yeah, we're consistently inconsistent with bundle/type/type ID, but we should try to unify to type ID as much as possible if we talk about the ID.
Comment #119
yched commentedYup, 'max_length' setting on entity_ref fields is obsolete and has no effect.
See #2278051: Remove uses of non-existing 'max_length' setting on EntityRef fields - let's not add ne ones here :-)
Comment #120
larowlanSo the states issue is that we're using '' as the key for 'new'.
We need to use something that doesn't evaluate to FALSE but is also an invalid config entity key, so how about '-1'?
Not sure if I'll have time to re-roll this today, but if someone else does, essentially we want the fixes required from #118 and then using the interdiff from #88, reverse the change from 'new' => '' and instead make it '-1'
Comment #121
berdirJust a thought, I don't think it matters much what exactly we use, but what about something like ':new'? And preferably put that in a constant (CommentTypeInterface::NEW_PLACEHOLDER for example?).
Comment #122
jessebeach commentedI'm going to do this reroll at DrupalCon Austin
Comment #123
larowlanFixes #118
Comment #124
larowlanLeft the default bundle as 'comment'
Comment #125
xjmComment #126
Bojhan commentedSorry for reviewing this so late. Sadly in Drupal 8 its not uncommon that we don't review far reaching UX changes anymore. By doing it this late, it ends up as followup (and never gets fixed) or requires stripping out stuff people worked on.
The only thing that I found truly weird and shouldn't be in this patch is the inline adding of new comment types. I don't understand why we should be doing that for this UI, we don't do it for any of the other fields. From my point of view, that should be removed before RTBC.
Comment #127
dixon_In general the code looks solid. I've done om some manual testing and below is my feedback (most of which can be dealt with in follow-ups I believe).
This needs to use the new
CommentTypeInterface::NEW_PLACEHOLDERconstant. The #states doesn't work on the comment field settings page because of this...OR
...we completely skip the whole "Create new" workflow from this form and just rely on adding comment types from the main comment types screens.
Follow-up: We probably enable per comment type permissions, similar to how content type permissions work.
Follow-up: We need to be able to override the various comment templates (
comment.html.twig,comment-wrapper.html.twig, more?) per comment typeFollow-up: At the moment the comment form heading always says "Add new comment" on the form. If you have a specific comment type like "Greeting" you probably want it to say "Write greeting" instead. I see two ways this can be solved:
Comment #128
dixon_Edit: Let's try that again
Comment #129
larowlan126 I respectfully disagree. Having to create the comment type first is a far worse UX.
127.1 yep
127.2-4 we have issues for these, none of them are beta blockers.
Comment #130
dixon_Follow-ups created. They need more details, but at least they're there.
Edit: Sorry, cross-post. I missed we had those.
Comment #131
larowlanWe already have these as follow ups from when comment-field first went in.
Please remove the duplicates.
126 - what if we meet half way - a link to add a new comment-type that loads in a dialog, then you don't loose where you are if you need to create one?
Comment #132
larowlanThe existing follow ups are
#1903138: Move global comment permissions to comment-type level
#1920044: Move comment field settings that relate to rendering to formatter options
#1962846: Use field instance name for header of comment list, drop comment-wrapper template
#2031883: Markup for: comment.html.twig
These are tracked in our meta existing comment-module path to beta meta - #2191565: [META] Comment/Forum/History path to beta
Comment #133
larowlanClosed duplicates
Comment #134
larowlanAdded related
Comment #135
larowlanAdding tag as per @bojhan request.
Usability question to ask - can we remove the 'create new comment-type' inline form, and replace it with an 'add new comment type' link in the description of the select field, that loads the add new comment-type form in a modal, then refreshes the page with the new value.
Comment #136
larowlanComment #137
dixon_It's of course up to @Bojhan to make a call on this, but IMO considering...
... I'd say we should keep it simple and just put a link in the description text to the comment type administration screen as @Bojhan suggested.
Any further UX improvements (e.g. modal pop-up) can easily be introduced later without breaking any BC.
Comment #138
Bojhan commentedI dont think it makes much sense to expose this in a modal. I am not sure a compromise helps our end-users. If you look at the bigger picture you will see that this patch introduces a UI concept that is not used by any of the other fields (inline adding of "types"). This will mean an inconsistency, which makes it harder for users to have an expectation about what they can do in the Field UI and where with the Drupal UI. I understand that there is a disconnect between the two UI's, but it doesn't help to have two places to create comment types.
If you want to introduce a concept like this, I think its best done in a follow-up or separate issue not in the beta blocker. Because it might work for other fields, or it might not - we don't know. We don't typically do interactions like this in the Drupal UI. I hope this helps to put some background to why I am suggesting this. I am sadly going to be traveling for a bit, back in a few days.
Comment #139
Bojhan commentedComment #140
berdirI wanted to suggest that initially as well, but the problem is that you are in the middle of the create-a-field process and clicking on that link will abort that and leave your field in an incomplete and broken state, and you then either have to delete and re-create it or remember to go back to the field settings and then the instance settings.
Also, you probably tested this with a comment field on nodes with the standard profile, which have a default comment type, so it's not really a problem there, but if you for example try to add a comment field to terms, there is no default and you can not continue without creating one first.
I don't think just a link is enough, if you're strongly against the "Create new", then what about automatically creating a default comment type if there is none and you get to that settings form?
Comment #141
larowlanSimilar ux issue here #1433796: Link to images styles from image field display settings
Comment #142
larowlanPerhaps we could do some AB testing here, although berdir's comment about broken site state shouldn't be ignored
Comment #143
yched commentedVery true. Note that once #2277941: Allow injecting an arbitrary FieldConfig when building a FieldInstanceConfig is in, though, Field UI could be modified to *not* create a FieldConfig until the moment you actually save the "field settings" form (or even the "instance settings form").
Comment #144
gábor hojtsyThat the field config may be in an inconsistent state is an existing problem. If your network goes out or your browser crashes or your computer runs out of power, etc. A views-like solution where everything is temporary until actually saved sounds good, but I think this would solve an existing problem and therefore could be deferred. My 2 cents.
Comment #145
larowlanOK, so I think we've settled on just remove the inline stuff
Will do
Comment #146
larowlanRemoves the inline stuff
Comment #148
larowlanFixes the new comments-not-allowed-on-entities-with-string-ids test
Comment #149
larowlanFixes other UX issues at #126
Comment #151
larowlanMissed a use during re-roll
Comment #152
dixon_This looks really solid now. The only nit-pick I have before I believe this one is RTBC is:
We should point to that issue - #2053415: Allow typed data plugins to receive injected dependencies
Comment #153
martin107 commentedadded url suggested by 152
Comment #154
dixon_Thanks @martin107!
I believe this one is ready now.
Comment #155
catchGood to see this RTBC, a few minor things though:
This already implements ContainerInjectionInterface via EntityForm - doesn't need to specify that again.
Should use Drupal::logger() now instead of watchdog or inject the logger service.
Is this a copy and paste error?
Drupal 6 to Drupal 8.
Drupal 6 to Drupal 8.
Comment #156
martin107 commented#155.1 fixed
#155.2 fixed
I went the dependency injection route.
It strikes me that the logger should be optional in the constructors as this would be more flexible in the future, other can comment
BUT I erred on the side of caution and implemented the functionally equivalent form of what was there as this was RTBC
#155.3 I am leaving this for others to comment
#155.4 fixed
#155.5 fixed
Comment #157
gábor hojtsyLooks good to me.
(As a side note that logger freaked me out for translatability. Opened #2285063: Support for Drupal 8 logger API. Not related to this issue per say...)
Comment #158
alexpottNoticed that we never were testing pressing the button on the comment type delete form. Also noticed a few minor things to tidy up.
Comment #159
xjmExceptions shouldn't use t(). Not ever.
Grammar nitpick: The second sentence either needs a conjunction, or to become two sentences.
Comment #160
alexpottJust doing a deeper review.
Comment #161
xjmCommentManager was even already using String. :)
Comment #162
alexpottThis looks great - just some more tidy up of unused uses, spelling and using a constant rather than hard coding.
Assigning back to catch.
Comment #163
catchCommitted/pushed to 8.x, thanks!
Comment #165
larowlanyeah!
/me unpostpones other issues
Comment #166
larowlanChange notice is here https://drupal.org/node/2285633
Please review so we can publish.
Comment #167
nick_vhSearch API D8 Branch broke due to this. We're trying to dig where the problem could be but the change record wasn't as useful as I hoped it would be. We'll review it and make improvements as soon as we have it working again
Comment #168
xjmComment #169
xjmComment #170
xjmActually, there is a change record, and it is published. :) It's a little confusing, but it's also not a 7-to-8 BC break. So long as the main change record for the original comment change is up-to-date for this issue, I think we can mark this fixed and improve the change record as needed.
Comment #172
dom. commentedCreated a followed on this to unify URLs of "xx-type" handling (content-types and comment-types). See:
#2501691: Change content-types, comment-types, and block-types URLs
Comment #173
gábor hojtsyThe followup for @dixon in #127/4 was not opened if I see it right. Opened #2546116: Allow a sitebuilder to change the Comment form heading. Please close if duplicate of something.