According to https://www.drupal.org/node/2100015: This means you can add commenting to any entity type by adding a comments field.

We're building a custom entity type, using a custom storage controller (in essence a REST backend), we can define the comment type and select our custom entity, but when trying to add the comment 'field' it does not show in the field.

Either the CR is wrong in stating that it can be added to any entity type while it isn't, or CR is right and there's something wrong with the code.

CommentFileSizeAuthor
#81 allow_comments_to_be-2496699-81.patch115.45 KBsylus
#79 allow_comments_to_be-2496699-79.patch115.43 KBsylus
#77 allow_comments_to_be-2496699-77.patch115.46 KBsylus
#75 allow_comments_to_be-2496699-75.patch115.46 KBsylus
#68 interdiff-66-68.txt6.03 KBjelle_s
#68 2496699-comment-entity-reference-68.patch112.35 KBjelle_s
#66 2496699-comment-entity-reference-66.patch107.35 KBjelle_s
#60 interdiff-2496699-49-60.txt14.92 KBdeepakaryan1988
#60 2496699-comment-entity-reference-60.patch106.54 KBdeepakaryan1988
#49 interdiff-47-49.txt491 bytesjelle_s
#49 2496699-comment-entity-reference-49.patch107.4 KBjelle_s
#47 interdiff-43-47.txt8.84 KBjelle_s
#47 2496699-comment-entity-reference-47.patch107.41 KBjelle_s
#43 interdiff.txt1.17 KBattiks
#43 2496699-comment-entity-reference-43.patch98.69 KBattiks
#38 interdiff-33-38.txt983 bytesjelle_s
#38 2496699-comment-entity-reference-38.patch98.69 KBjelle_s
#33 interdiff-30-33.txt622 bytesjelle_s
#33 2496699-comment-entity-reference-33.patch97.73 KBjelle_s
#30 interdiff-27-30.txt16.8 KBjelle_s
#30 2496699-comment-entity-reference-30.patch97.12 KBjelle_s
#27 interdiff-24-27.txt13.25 KBjelle_s
#27 2496699-comment-entity-reference-27.patch81.85 KBjelle_s
#24 2496699-comment-entity-reference-24.patch72.68 KBjelle_s
#23 2496699-comment-entity-reference-23.patch72.91 KBjelle_s
#21 2496699-comment-entity-reference-21.patch72.66 KBjelle_s
#19 2496699-comment-entity-reference-18-do-not-test.patch54.35 KBjelle_s
#8 i2496699-POC.patch8.8 KBattiks
Screenshot from 2015-05-28 22:07:11.png97.68 KBattiks
Screenshot from 2015-05-28 22:06:01.png27.95 KBattiks

Comments

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

95% sure that this is not a core problem.

Comment requires that the host entity has an integer ID. To figure that out, it loads the base field definitions and uses those to verify that.

You either have a non-integer field definition for your ID or you didn't specify base field definitions.

See comment_form_field_ui_field_storage_add_form_alter() and _comment_entity_uses_integer_id().

attiks’s picture

Title: Comment can not be attached to entities using a custom StorageController » Comment can not be attached to entities using a string as key
Priority: Critical » Major
Status: Postponed (maintainer needs more info) » Active

You're right, our entities do not have an integer key. Why is this a requirement?

Renamed the issue

berdir’s picture

Because comments have a reference to the commented entity with the entity_type/entity_id base fields, and that's string/integer. It's not possible to vary that by the reference and changing it to string would be a performance regression for all the ID entity types.

See #2205215: {comment} and {comment_entity_statistics} only support integer entity ids.

I'm sorry, but for 8.x, that's pretty much by design and won't change.

attiks’s picture

Related issue #2496913: Don't expose entity types with string ids as a target option when creating comment types

So there's going to be a contrib module, 99% similar to comment only to support string id's, sorry but this does not make any sense.

So can we reconsider this and allow comments to be attached to all entities, like the CR says?

attiks’s picture

changing it to string would be a performance regression for all the ID entity types

#3 I read the issue twice, but I'm missing the performance problem part, the decision seems to be made by #2205215-38: {comment} and {comment_entity_statistics} only support integer entity ids:

We discussed this issue with @larowlan, @dixon_, @alexpott, @effulgentsia, and myself, and decided that option 1 (simply not supporting string IDs for comment in core) is the best option at this point in the release cycle. If for some reason someone needs to support comments on an entity type with a string ID (@effulgentsia supplied the example of a remote entity), then they can swap out the service.

damienmckenna’s picture

Title: Comment can not be attached to entities using a string as key » Allow comments to be attached to entities using a string primary key
Version: 8.0.x-dev » 8.1.x-dev
Category: Bug report » Feature request
Priority: Major » Normal

FYI Comment module is not the only thing with this limitation, much of core (and contrib) is built around integer-based primary keys.

Changing this to a feature request for 8.1.

attiks’s picture

Isn't it easier to fix this instead of postponing? Are we actually going to release a version that allows string as keys, but when you use it, you cannot use half of core anymore? Doesn't that sound a bit silly?

I thought the great plan was to use the API, so this shouldn't be a problem to implement, according to @Berdir it was done for performance reasons, but I don't seem to find the issue.

attiks’s picture

Version: 8.1.x-dev » 8.0.x-dev
Status: Active » Needs review
StatusFileSize
new8.8 KB

Proof of concept patch, tested with external entities using string ids, most of the problems were related to #2107249: Don't assume that content entities have numeric IDs in EntityReferenceItem, which is also a bug (at least to me).

I expect failures since the other issues has them as well.

Status: Needs review » Needs work

The last submitted patch, 8: i2496699-POC.patch, failed testing.

attiks’s picture

Assigned: Unassigned » dixon_

I have a question, if answered before, apologies

Why doesn't comment use a real entity_reference field, that gets attached similar how the boy field gets attached?

AFAIK this will allow us to attach it to any entity

Assigned to a comment maintainer

andypost’s picture

Assigned: dixon_ » Unassigned

@attiks Because 'comments' are not the ER but property (enable,disable,hidden), see the original conversion issue #731724: Convert comment settings into a field to make them work with CMI and non-node entities
The ER you keep in mind is from comment entity to parent entity does not fit in core now.

The only attempt to fix that was #1995944: Remove entity_id and entity_type from the comment table and replace with relationship tables but storing "entity_type+entity_id" to fetch comments bring a lot of overhead, I can't find the exact comment where it was measured but we spend a lot of time on that before.

attiks’s picture

#11 I was taking about the entity_id and entity_type in the comment_field_data table, the entity_id gets created as an entity_reference by Comment::baseFieldDefinitions, the only problem is that it gets created as an int, the patch above forces all entity_references to be created as strings (breaking other things) but that is the only change needed to make comments work with string keyed entities.

So if there is a way to make entity_id into a string this might work, the only problem I see is that if the comment is attached to a node the data types do not match (node.nid being an int, comment_field_data.entity_id being a string).

Without the patch above, I tried altering the storage using CommentStorageSchema::getSharedTableFieldSchema as follows

        case 'entity_id':
          $schema['fields'][$field_name]['type'] = 'varchar';
          $schema['fields'][$field_name]['length'] = '255';
          $schema['fields'][$field_name]['unsigned'] = FALSE;
          break;

which works, but the problem is that the value gets converted before being saved, probably because of the property definition, but I guess this is something similar as tried in #1995944: Remove entity_id and entity_type from the comment table and replace with relationship tables

larowlan’s picture

MySQL will forgive you for putting ints into a varchar column, Postgres won't be so understanding.

If we do this, we accept that ID lookups aren't going to be as efficient as they'd be on an integer.

attiks’s picture

#13 I know string indexes will be slower, but I think it is an acceptable trade off to make everything consistent and avoid having a comment module in contrib only to support strings as keys.

larowlan’s picture

Issue tags: +needs profiling

Million dollar question is how much slower

jelle_s’s picture

With #2107249: Don't assume that content entities have numeric IDs in EntityReferenceItem we could convert the entity_id base field to field instances, which would automatically have the right schema according to the entity type they're referencing.

I'm not sure what to do with the statistics: Convert the entity_id to a string (but what about Postgres), ... (any other suggestions?)?

I'll have a look in to this.

andypost’s picture

@Jelle_S this will bring to separate data tables for comments with int and string IDs, that means you move that primary ID into linked table - that's wrong.

Another trick here is a comment bundle (comment type) that defines fields and by that we need to keep this "commented entity id" in base table.

PS: conversion issue #2228763: Create a comment-type config entity and use that as comment bundles, require selection in field settings form

attiks’s picture

#17 You'll get separate tables for each comment type, isn't the primary key supposed to be cid?

If not, any other ideas on how this can be solved?

jelle_s’s picture

StatusFileSize
new54.35 KB

Here's what I got so far. Tests aren't green yet but I'm just uploading my progress thus far.

For some reason, in following code in the CommentManager, the field settings do not get updated after save, they just get overridden again and the entity reference points to a user in stead of an entity_test... I'm still baffled how this happens... Couldn't find an explanation so far:

/**
   * {@inheritdoc}
   */
  public function addEntityField($comment_type_id) {
    if (!FieldConfig::loadByName('comment', $comment_type_id, 'comment_entity')) {
      $comment_type = CommentType::load($comment_type_id);
      // Attaches the body field by default.
      $field = $this->entityManager->getStorage('field_config')->create(array(
        'label' => 'Commented entity',
        'bundle' => $comment_type_id,
        'required' => TRUE,
        'field_storage' => FieldStorageConfig::loadByName('comment', 'comment_entity'),
        'settings' => array(
          'target_type' => $comment_type->getTargetEntityTypeId(),
          'handler_settings' => array(),
          'handler' => 'default:' . $comment_type->getTargetEntityTypeId(),
        ),
      ));
      $field->save();

// If I dump the settings here, the target type is 'user' and the handler is 'default:user' in stead of 'entity_test' and 'default:entity_test'.

      // Assign widget settings for the 'default' form mode.
      entity_get_form_display('comment', $comment_type_id, 'default')
        ->removeComponent('comment_entity')
        ->save();

      // Assign display settings for the 'default' view mode.
      entity_get_display('comment', $comment_type_id, 'default')
        ->removeComponent('comment_entity')
        ->save();
    }
  }
andypost’s picture

#18 makes sense but breaks BC in many places, at least history and comment statistics should use the same table split.
Suppose that should be done in contrib and then migrate to core

  1. +++ b/core/modules/comment/comment.install
    @@ -39,10 +39,10 @@ function comment_schema() {
    +        'type' => 'varchar_ascii',
    ...
    +        'length' => 255,
    

    wonders if we have limits on entity_id as string

  2. +++ b/core/modules/comment/src/CommentAccessControlHandler.php
    @@ -41,6 +41,8 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A
    +        debug($entity->getCommentedEntity()->access($operation, $account, TRUE));
    +        debug($entity->getCommentedEntity());
    

    --

  3. +++ b/core/modules/comment/src/CommentAccessControlHandler.php
    @@ -85,7 +87,7 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_
    -        'entity_id',
    +        'comment_entity',
    

    we use "commented_entity" all over module

  4. +++ b/core/modules/comment/src/CommentManagerInterface.php
    @@ -52,6 +52,14 @@ public function getFields($entity_type_id);
    +   * Creates a comment_entity field.
    ...
    +  public function addEntityField($comment_type);
    
    +++ b/core/modules/comment/src/CommentTypeForm.php
    @@ -169,6 +169,7 @@ public function save(array $form, FormStateInterface $form_state) {
    +      $this->commentManager->addEntityField($comment_type->id());
    
    +++ b/core/modules/comment/src/Tests/CommentTestTrait.php
    @@ -58,6 +58,8 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com
    +    // Add an entity field to the comment type.
    +    \Drupal::service('comment.manager')->addEntityField($comment_type_id);
    
    +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityCommentType.php
    @@ -22,6 +22,7 @@ class EntityCommentType extends EntityConfigBase {
    +    \Drupal::service('comment.manager')->addEntityField(reset($entity_ids));
    
    +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php
    @@ -43,6 +43,7 @@ protected function setUp() {
    +    \Drupal::service('comment.manager')->addEntityField('comment_no_subject');
    

    is there a reason to keep that in manager?
    otoh that looks like a trick...
    Like having comment interface getCommentedEntity() method that accesses a field module provided field...

jelle_s’s picture

Status: Needs work » Needs review
StatusFileSize
new72.66 KB

I tested this patch in combination with #2107249: Don't assume that content entities have numeric IDs in EntityReferenceItem. Not sure if this patch needs it, but with it the relevant tests were green on my machine.

Status: Needs review » Needs work

The last submitted patch, 21: 2496699-comment-entity-reference-21.patch, failed testing.

jelle_s’s picture

Status: Needs work » Needs review
StatusFileSize
new72.91 KB

I was working on an older D8 checkout. Rerolled patch.

jelle_s’s picture

StatusFileSize
new72.68 KB

Small error in reroll. New patch.

Status: Needs review » Needs work

The last submitted patch, 24: 2496699-comment-entity-reference-24.patch, failed testing.

The last submitted patch, 23: 2496699-comment-entity-reference-23.patch, failed testing.

jelle_s’s picture

Status: Needs work » Needs review
StatusFileSize
new81.85 KB
new13.25 KB

Still won't be green, but should be a lot closer to it.

jelle_s’s picture

+++ b/core/modules/comment/src/CommentViewBuilder.php
@@ -67,6 +67,9 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
+    if (!$entity->getCommentedEntity()) {
+      debug(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
+    }

still some debug code

Status: Needs review » Needs work

The last submitted patch, 27: 2496699-comment-entity-reference-27.patch, failed testing.

jelle_s’s picture

StatusFileSize
new97.12 KB
new16.8 KB

New patch. I think this should be green... Go testbot!

Side note:
This patch in itself does not allow comments to be attached to entities using a string primary key. But it changes the link between the entity and the comment to an entity_reference field. So when #2107249: Don't assume that content entities have numeric IDs in EntityReferenceItem lands (which is RTBC right now) it will be possible to do so.

jelle_s’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 30: 2496699-comment-entity-reference-30.patch, failed testing.

jelle_s’s picture

Status: Needs work » Needs review
StatusFileSize
new97.73 KB
new622 bytes

I fixed the exception, but there is still one fail in Drupal\views\Tests\Entity\ViewEntityDependenciesTest: it expects comment, node and user as module dependencies for a view, but gets only comment and user. I'm not quite sure if it's actually a bug, or normal behavior, since the new views relation is provided by entity_reference, which already is a dependency for comment. I don't know enough about the way configuration management or views deals with this, so I could really use someone who knows a lot about those modules to have a look and see if it's normal behavior or a bug. If it's normal behavior, all that's left is to change that test...

Status: Needs review » Needs work

The last submitted patch, 33: 2496699-comment-entity-reference-33.patch, failed testing.

The last submitted patch, 30: 2496699-comment-entity-reference-30.patch, failed testing.

The last submitted patch, 33: 2496699-comment-entity-reference-33.patch, failed testing.

jelle_s’s picture

Even weirder:

When I import the view on a D8 install with the patch and I execute following code in devel/php I do get the correct dependencies:

dpm(\Drupal\views\Views::getView('test_field_get_entity')->calculateDependencies());

Result:

Array
(
    [module] => Array
        (
            [0] => comment
            [1] => node
            [2] => user
        )

)
jelle_s’s picture

Status: Needs work » Needs review
StatusFileSize
new98.69 KB
new983 bytes

Never mind. Turns out I was looking at the wrong view (sigh). The test_relationship_dependency view was still using the old "node" relationship (which doesn't exist anymore because it's been replaced by entity_reference). This patch should be green.

attiks’s picture

#20

Regarding the history table, this is not for this patch since it only works with nodes. Even before this patch you were able to add comments to users, but the history was never used.

To solve the comment statistics, I think it is ok to move the cast into the SQL statement since the comment module assumes an SQL compatible backend anyway. Unless somebody knows a better way to solve this?

attiks’s picture

+++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
@@ -131,7 +132,13 @@ public function preRender(&$values) {
+        INNDER JOIN {" . $comment_entity_table . "} ce ON c.cid = ce.entity_id AND ce.deleted = 0

INNDER should be INNER

I guess this is untested code

dawehner’s picture

Issue tags: +Needs tests

I'd not expected it to be tested in the first place :)

jelle_s’s picture

Issue tags: -Needs tests

The existing tests still test all the functionality. This piece of code was untested, even before this patch. Everything about comment that was tested, is still tested with this patch. So to me, covering that bit of code with tests, seems out of scope for this issue. It was just discovered that it wasn't tested because of this patch, but it isn't the cause of it. Tentatively removing the Needs tests tag.

attiks’s picture

StatusFileSize
new98.69 KB
new1.17 KB

INNDER fixed

andypost’s picture

+++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
@@ -137,7 +137,7 @@ public function preRender(&$values) {
-        INNDER JOIN {" . $comment_entity_table . "} ce ON c.cid = ce.entity_id AND ce.deleted = 0
+        INNER JOIN {" . $comment_entity_table . "} ce ON c.cid = ce.entity_id AND ce.deleted = 0

better to file separate issue to add test for that

+++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
@@ -131,7 +132,13 @@ public function preRender(&$values) {
-      $result = $this->database->query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment_field_data} c ON n.nid = c.entity_id AND c.entity_type = 'node' AND c.default_langcode = 1
+      $field_storage = FieldStorageConfig::loadByName('comment', 'commented_node');
+      $table_mapping = \Drupal::entityManager()->getStorage('comment')->getTableMapping();
+      $comment_entity_table = $table_mapping->getDedicatedDataTableName($field_storage);
+      $target_id_column = $table_mapping->getFieldColumnName($field_storage, 'target_id');
+      $result = $this->database->query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n
+        INNER JOIN {" . $comment_entity_table . "} ce ON c.cid = ce.entity_id AND ce.deleted = 0
+        INNER JOIN {comment_field_data} c ON n.nid = c.$target_id_column AND c.entity_type = 'node' AND c.default_langcode = 1

looks we have no tests for this handler at all

jelle_s’s picture

Am I correct in saying that both should be separate issues since they didn't have any tests before this patch either? (Or should it be one separate issue for both tests?)

attiks’s picture

Regarding the statistics in #39 I think the best will be the cast the entity id to a varchar, so the index of comment_statistics can be used for the join

jelle_s’s picture

StatusFileSize
new107.41 KB
new8.84 KB

New patch with the entity_id cast, as described in #46.

Status: Needs review » Needs work

The last submitted patch, 47: 2496699-comment-entity-reference-47.patch, failed testing.

jelle_s’s picture

StatusFileSize
new107.4 KB
new491 bytes

Ugh, wrong classname...

jelle_s’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 49: 2496699-comment-entity-reference-49.patch, failed testing.

attiks’s picture

I considering marking this as a bug since Drupal core isn't using his own API, does anybody has any objections?

larowlan’s picture

Needs profiling
Isn't a bug, see comments above - by design
Also why didn't we profile changing the column in HEAD to a string and casting numeric ids?

attiks’s picture

Any tips on how to profile?

attiks’s picture

Issue tags: -needs profiling

I did some profiling using https://www.drupal.org/project/webprofiler but there is no difference in any of the numbers, which was to be expected. Numbers are not really accurate since the site has been reinstalled between tests.

Tested on homepage with 10 nodes and 50 comments in total, logged in as admin and cleared cache
Without patch
First run: 1216ms, 31MB, 388 queries in 359 ms
Second run: 687ms, 29MB, 314 queries in 192 ms
Third run: 120ms, 16MB, 83 queries in 16 ms

With patch
First run: 1060ms, 38MB, 393 queries in 315 ms
Second run: 427ms, 21MB, 88 queries in 68 ms
Third run: 234ms, 21MB, 69 queries in 19 ms

Tested on node page with 21 comments
Without patch
First run: 1468ms, 35MB, 580 queries in 425 ms
Second run: 456ms, 25MB, 135 queries in 48 ms
Third run: 226ms, 25MB, 95 queries in 25 ms

With patch
First run: 1520ms, 40MB, 596 queries in 520 ms
Second run: 413ms, 35MB, 139 queries in 64 ms
Third run: 600ms, 35MB, 99 queries in 77 ms

I anybody knows a better way to test this, let me know
If profiling using xhprof is needed let me know and I give it a try.

andypost’s picture

Issue tags: +needs profiling

@attiks I suggest to use one of scripts from https://www.drupal.org/contributor-tasks/profiling that will allow you to get more precised numbers

attiks’s picture

Issue tags: +Needs reroll

I ended up using xhprof directly and looked at Drupal\comment\CommentManager::getCountNewComments, both with and without the patch the walltime is the same, I'll try creating a full report once my dockers start behaving.

ps: The major difference is in sql queries: an extra join and a cast to a varchar, so I don't expect to see any difference

deepakaryan1988’s picture

Assigned: Unassigned » deepakaryan1988
deepakaryan1988’s picture

Assigned: deepakaryan1988 » Unassigned
StatusFileSize
new106.54 KB
new14.92 KB

Rerolled patch #49

deepakaryan1988’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 60: 2496699-comment-entity-reference-60.patch, failed testing.

attiks’s picture

deepakaryan1988 thanks for reroll, i think you missed some parts, can you check?

deepakaryan1988’s picture

@attiks yeah sure!
I will check it tomorrow!!

jelle_s’s picture

Assigned: Unassigned » jelle_s

Since there's been no reaction from deepakaryan1988, I'll take a stab at a reroll.

jelle_s’s picture

Status: Needs work » Needs review
StatusFileSize
new107.35 KB

Should be just a straight reroll.

Leaving it assigned to me. I'll have a look at writing updates.

Status: Needs review » Needs work

The last submitted patch, 66: 2496699-comment-entity-reference-66.patch, failed testing.

jelle_s’s picture

Assigned: jelle_s » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new112.35 KB
new6.03 KB

Fixed the test and added an update function.

deepakaryan1988’s picture

@Jelle_S Thanks for patch.
I was quite buzy.

attiks’s picture

I finally found to time to push our external entities project for d8 (https://www.drupal.org/project/external_entities), it would be nice to be able to use core comment module. It works with the above patch.

andypost’s picture

This is a feature so 8.1 and later
And because there's serious data model change this could go to 9.x

Anyway we need to solve the issue with attaching comments to entities that have non-integer PKs

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sylus’s picture

StatusFileSize
new115.46 KB

Here is my first go at trying to get this re-rolled. I tested it with my existing comment types and they all got switched to use entity reference.

The following updates are pending:

comment module : 
  8302 -   Update existing comments to use the new entity reference fields. 

Do you wish to run all pending updates? (y/n): y
Performing comment_update_8302                                              [ok]
Performing comment_update_8302                                              [ok]
Performing comment_update_8302                                              [ok]
Performing comment_update_8302                                              [ok]
Performing comment_update_8302                                              [ok]
Performing comment_update_8302                                              [ok]
Performing comment_update_8302                                              [ok]
Cache rebuild complete.                                                     [ok]
Finished performing updates.                                                [ok]

There were unfortunately a few adjustments that had to be made to the earlier patch:

1) For some reason updateEntityType was never called so when calling comment_update_8302 it would always say "base table or view not found" as the commented_update_8302 tabe was never created. Not sure if this was a change in 8.3.x. To solve this I looked at other hook_update_n invocations and did the following:

+/**
+ * Update existing comments to use the new entity reference fields.
+ */
+function comment_update_8302(&$sandbox) {
+  if (!isset($sandbox['total'])) {
+    $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
+    $entity_type = $definition_update_manager->getEntityType('comment');
+    $definition_update_manager->updateEntityType($entity_type);

2) I converted all array()'s to short array syntax.

3) There were a few psr4 namespaces removed since last patch that were needed so I added them back mostly just:

use Drupal\field\Entity\FieldStorageConfig;

4) Slightly updated rdf module patch lines

5) I couldn't the relevant hal + migrate_drupal files to patch

6) I think there are going to be quite a few test failures as were on my local but wanted to post progress.

Status: Needs review » Needs work

The last submitted patch, 75: allow_comments_to_be-2496699-75.patch, failed testing.

sylus’s picture

Status: Needs work » Needs review
StatusFileSize
new115.46 KB

One minor correction to views/filter/UserUid.php. Retriggering.

Status: Needs review » Needs work

The last submitted patch, 77: allow_comments_to_be-2496699-77.patch, failed testing.

sylus’s picture

Status: Needs work » Needs review
StatusFileSize
new115.43 KB

This patch should fix the views.comment_recent schema issues and ForumIndexStorage missing $nid which was my error. ^_^

Status: Needs review » Needs work

The last submitted patch, 79: allow_comments_to_be-2496699-79.patch, failed testing.

sylus’s picture

Status: Needs work » Needs review
StatusFileSize
new115.45 KB

Fix for the "Undefined variable: entity_test" for CommentCacheTagsTest.php is now called:

'commented_entity_test' => $this->entityTestCamelid->id(),

I can handle the remaining code quality issues in next patch but unsure about bulk of rest of issues.

I do know there are some changes to be made in both HAL + Rest module to switch entity_id to commented_entity_test.

Any guidance on what else I missed would be appreciated ^_^

Status: Needs review » Needs work

The last submitted patch, 81: allow_comments_to_be-2496699-81.patch, failed testing.

sylus’s picture

Okay I thought I would post status here and get any opinions. I was talking about this issue with a few drupal developers on and offline and the general consensus was I should be moving the comments + this patch functionality to a new contrib module likely called "external_comments".

Unfortunately I need this workflow to provide comments / ratings to external entities via CKAN / SOLR and expose them restfully as a required case. The worry with this patch would be the potential need to update for every core release and general maintenance issues.

I'll still be working on updating this patch but thought I would mention intentions to create a new contrib with this extended functionality and obviously pointing to the modules existence to only provide primary key as string storage.

Thoughts? :)

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.