Problem/Motivation

Spinning this out from #126197: Option to Disable IP Logging.

Drupal permanently logs IP addresses and has done so for at least ten years. This isn't used for anything by default, it's just stored away.

#126197: Option to Disable IP Logging adds a privacy module which would anonymise IP addresses - this is great for things like flood control and similar where the IP address is used for a specific reason (i.e. we need to store a unique identifier for the duration of a request). However comment module just doesn't need to store IP addresses at all - the fact it's linked directly and permanently with e-mail addresses/user accounts makes it different from log/flood etc. too

Proposed resolution

Add a configuration setting to control whether IP addresses are logged or not. Default this to off for new sites but add an update to leave it on for existing sites - we can add a change record to let existing sites know they can change it themselves.

This will be compatible with the privacy module - you could re-enable IP logging and have privacy module installed, in which case comments get associated with a unique identifier, just not the actual IP address - still useful for identifying sock puppet accounts on social sites and similar.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

catch created an issue. See original summary.

catch’s picture

StatusFileSize
new1.44 KB

Here's a patch.

catch’s picture

StatusFileSize
new1.44 KB

s/wth/with

mlncn’s picture

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

Lovely! Works as expected on a new site.

Since we're changing a default, we need a change record, yes? Oh yes, you noted that in the description. Tagging accordingly.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: comment-2828793.patch, failed testing.

catch’s picture

Status: Needs work » Needs review

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.

wim leers’s picture

Issue tags: +privacy
wturrell’s picture

I got:

Fatal error: Cannot redeclare comment_update_8301() (previously declared in core/modules/comment/comment.install:200)

so I changed it to 8401 (right?) and replicated the @addtogroup updates stuff (which I don't understand).

Also, any chance of an idiot's guide (in issue summary perhaps) for how to upgrade an existing site to use this? i.e. how do you get the new config setting in there without uninstalling and reinstalling the comment module (which you can't).

Thanks.

mac_weber’s picture

+++ b/core/modules/comment/comment.install
@@ -208,3 +208,23 @@ function comment_update_8301() {
+                ->save(TRUE);

Indentation is incorrect here.

Munavijayalakshmi’s picture

Assigned: Unassigned » Munavijayalakshmi
Status: Needs review » Needs work
Issue tags: +Needs reroll
Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1.49 KB

Re-rolled (and resolved the indentation issue highlighted in #10).

yoroy’s picture

Happy to see this become the better new default.

Add a configuration setting to control whether IP addresses are logged or not.

This does not provide a UI right? I couldn't find any in simplytest :-)

catch’s picture

Issue tags: +Needs tests

Yes there's no UI for it yet, I don't really know where that UI could live for comment module to be honest.

Also the setting isn't actually used in comment module yet, so needs work for that, and we need test coverage.

mac_weber’s picture

TBH, I hope the IP log option is default off and no UI to change it.

Keeping it only to be changed by who somehow really "needs" it would avoid for example a beginner developer that doesn't have a well configured server to set this option on - by obfuscation.

yoroy’s picture

Agreed. To be clear: I was checking, not promoting a UI for it :)

catch’s picture

Status: Needs review » Needs work

Yes I had no intention to provide a UI here. There's really no reason to collect and store real IP addresses permanently, and comment is the only core module that does so.

If we want to add cryptolog or similar functionality to core we could default to that eventually, also with no UI. Cryptolog is enough to identify issues such as hundreds of commenters coming from the same IP address, you can then collect actual IP addresses for a bit to see what they are. It would also improve the privacy case for flood control etc., but those are already temporary and cycled out, so much less of a concern for me. We have an issue open for that already separately.

Marking CNW because we need to add test coverage and actually implement the behaviour change still.

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.

catch’s picture

Category: Task » Bug report
Priority: Normal » Major
Issue tags: +GDPR
catch’s picture

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.26 KB
new2.16 KB

Patch to prevent logging

It needs changes in \Drupal\Tests\comment\Kernel\CommentHostnameTest::testGetDefaultHostname (should fail now)
And upgrade path changes

andypost’s picture

StatusFileSize
new948 bytes
new3.08 KB

Fixed test, now only upgrade path tests needed

andypost’s picture

no intention to provide a UI here

yes, UI should live in contrib a-la gdpr_comment and the URL /admin/structure/comment/settings

The last submitted patch, 23: 2828793-23.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 24: 2828793-24.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new838 bytes
new3.9 KB

Fix token test

andypost’s picture

Assigned: Unassigned » larowlan
Issue tags: -Needs tests
StatusFileSize
new1.09 KB
new4.99 KB

Added upgrade test

I guess it needs Lee to approve

andypost’s picture

The last submitted patch, 28: 2828793-28.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 29: 2828793-29.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new5.08 KB

Fix test for real

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.

larowlan credited jibran.

larowlan’s picture

+++ b/core/modules/comment/comment.install
@@ -207,3 +207,13 @@ function comment_update_8600() {
+function comment_update_8601() {

this needs to be a post update hook as it is changing config

Crediting jibran who I confirmed that with

catch’s picture

StatusFileSize
new1.25 KB
new5.48 KB

Re-rolled with a post-update.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/comment/comment.install
@@ -207,3 +207,4 @@ function comment_update_8600() {
+

nit: whitespace

looks good to me

catch’s picture

Issue tags: -Needs change record

Added a change record.

  • larowlan committed 36ecfc6 on 8.7.x
    Issue #2828793 by andypost, catch, wturrell, Jo Fitzgerald, jibran: Stop...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

fixed on commit

diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index a77686c40e..82b578b489 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -207,4 +207,3 @@ function comment_update_8600() {
   $field_storage_definition->setDefaultValueCallback(Comment::class . '::getDefaultHostname');
   $entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
 }
-

Committed 36ecfc6 and pushed to 8.7.x.

Updated and published change record

Status: Fixed » Closed (fixed)

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

isinadinos’s picture

Just came out at this post and sadly realised that ips are not stored in comment_field_data table any more. Is there a guide how to enable this feature (at least programmaticaly)? It is essential for my blog to store comments which are needed in the future.