Problem/Motivation

Follow-up to #1498662: Refactor comment entity properties to multilingual
Currently subject field is not configurable via field_ui module and uses custom code to operate.
Node entity already does this and contact module goes too #1856562: Convert "Subject" and "Message" into Message base fields - nice example

Proposed resolution

Use "string" widget for comment.subject field
Remove comment field instance setting to show comment subject in comment form

Remaining tasks

fix tests

User interface changes

Comment subject field widget could be configured for via field_ui interface.

API changes

Comment field instance settings is removed in favor of entity display setting for widget

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Status: Active » Needs review
FileSize
1.08 KB

is there any tests for that?

Status: Needs review » Needs work

The last submitted patch, 1: 2292821-1.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review

Proper patch!
ps; previous was for #2292815: Remove join comments on users table

andypost’s picture

FileSize
2.17 KB
andypost’s picture

Issue tags: +Entity Field API, +D8MI

Status: Needs review » Needs work

The last submitted patch, 4: 2292821-comment-swf-3.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
5.73 KB
7.9 KB

Should fix most failures.

Still need to fix comment subject visibility, that stored in field settings... probably better to move it to comment type entity.

andypost’s picture

FileSize
18.08 KB
24.6 KB

a bit more fixed tests...

Now I think that better to remove subject setting from instance and use field_ui to hide that field

The last submitted patch, 7: 2292821-comment-swf-7.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 8: 2292821-comment-swf-8.patch, failed testing.

andypost’s picture

Title: Use comment subject field via widget and formatter » Use widget for comment subject field
Assigned: Unassigned » larowlan
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Novice
FileSize
4.97 KB
28.4 KB

Finally polished the patch.

Now Allow comment title setting removed in favor of comment type form display

Status: Needs review » Needs work

The last submitted patch, 11: 2292821-comment-swf-11.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
1.02 KB
28.95 KB

Fix broken test (none-node)

andypost’s picture

seems migrate tests are wrong or does not properly check "subject"

andypost’s picture

FileSize
1.45 KB
30.39 KB

Stub on migrate - no field instance subject setting migrated.
I found no entity form display migration for comments ;(

andypost’s picture

FileSize
16.42 KB
45.36 KB

So here is a migrate implementation!

Depending on subject field visibility migrated 1 or 2 comment types: comment and comment_no_subject
Accordingly created 1 or 2 comment fields with instances

Also I found a bug in ComponentEntityDisplayBase.php after component is removed no save operation called.
So I added a test and fixed existing.

@larowlan if you agree on that approach I will fix comment migration by separating comments within 2 fields

benjy’s picture

Looks ok to me, lets just add the new migration to MigrateDrupal6Test.

Also a few nitpicks I noticed on the way through.

  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/CommentVariable.php
    @@ -59,6 +59,8 @@ protected function getCommentVariables() {
    +      $return[$node_type]['comment_type'] = empty($data['comment_subject_field']) ?
    +        'comment_no_subject' : 'comment';
    

    this could be on one line.

  2. +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableField.php
    @@ -36,6 +36,20 @@ public function setUp() {
    +        ->save();
    

    bad indent.

Status: Needs review » Needs work

The last submitted patch, 16: 2292821-comment-swf-16.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
10.34 KB
54.64 KB

Fix for migrate

andypost’s picture

Probably it makes sense to split the issue in #15 and migrate to separate issue

Status: Needs review » Needs work

The last submitted patch, 19: 2292821-comment-swf-19.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
1.79 KB
56.43 KB

Fix broken tests, now migration needs node table

Gábor Hojtsy’s picture

Issue tags: +language-content

Add D8MI topic tag.

yched’s picture

Unable to speak about the migrate part, which is above my head atm, but the rest looks fine :-)

Only nitpick :

+++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php
@@ -102,18 +102,20 @@ function postComment(EntityInterface $entity, $comment, $subject = '', $contact
+    if (entity_get_form_display('comment', 'comment', 'default')
+      ->getComponent('subject')) {

+++ b/core/modules/comment/src/Tests/CommentTestBase.php
@@ -113,18 +113,20 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
+    if (entity_get_form_display('comment', 'comment', 'default')
+      ->getComponent('subject')) {

Shoould be one line ?

andypost’s picture

re-roll and fix #24

andypost’s picture

Another approach here is to use different entity form displays in migration

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
39.72 KB
42.56 KB
51.98 KB
870 bytes
56.82 KB

Wow, so little code to make the change, so much test and migrate code.
Great work.

Re-rolled for #2293773: Field allowed values use dots in key names - not allowed in config

RTBC if re-roll comes back green.

Screenshots from manual testing

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 27: comment-subject-2292821.27.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
56.5 KB

Proper merge

andypost’s picture

Status: Needs review » Reviewed & tested by the community

back to rtbc

larowlan’s picture

+1 rtbc

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
git ac https://www.drupal.org/files/issues/2292821-comment-subj-widget-29.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 57857  100 57857    0     0   349k      0 --:--:-- --:--:-- --:--:--  376k
error: patch failed: core/modules/comment/src/Entity/Comment.php:224
error: core/modules/comment/src/Entity/Comment.php: patch does not apply
andypost’s picture

re-roll, the comment subject is translatable now

andypost’s picture

Issue tags: -Needs reroll
andypost’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

We're changing the UI and the API in this patch :)

andypost’s picture

andypost’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

Patch still applies, filed change record https://www.drupal.org/node/2302379

PS: the issue should be linked to https://www.drupal.org/node/2186583

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed b7959a1 and pushed to 8.x. Thanks!

  • alexpott committed b7959a1 on 8.x
    Issue #2292821 by andypost, larowlan: Use widget for comment subject...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.