Summary updated until comment #101.

(The following happens in D7. The comment module in D8 has no problems, according to #99 and #101.)

After changing the comment_body field of a content type, the following warnings appear:

1. after deleting the comment_body field: when opening admin/content/comment I get this error:
Notice: Undefined property: stdClass::$comment_body in comment_admin_overview() (line 108 of /modules/comment/comment.admin.inc).

2. after deleting the comment_body field: when commenting on a node of that type:
Notice: Undefined property: stdClass::$comment_body in comment_submit() (line 2183 of /modules/comment/comment.module).

3. after making the comment_body field not-required: when commenting on a node with an empty body field:
Notice: Undefined offset: 0 in comment_submit() (line 2197 of /modules/comment/comment.module)

4. after setting the filter of the comment body to plain text, and clicking on the preview button to show the preview of a comment:
Notice: Undefined index: format in comment_preview() (line 2071 of /modules/comment/comment.module) (from #2077901)

The comments get submitted without problems but i don't know what's the error about.

CommentFileSizeAuthor
#129 interdiff-1038652-120-128.txt2.22 KBjacob.embree
#128 1038652-128.patch5.47 KBdcam
#120 1038652-comment-body-field-120-test-and-fix-D7.patch5.52 KBxenophyle
#95 1038652-comment-body-field-95-test-and-fix-D7.patch5.33 KBjohnv
#95 1038652-comment-body-field-95-test_only-D7.patch3.04 KBjohnv
#89 1038652-comment-body-field-89-tests-only-D8.patch1.86 KBjohnv
#89 1038652-comment-body-field-89-tests-and-fix-D8.patch3.26 KBjohnv
#85 1038652-comment-body-field-85-tests-only-D8.patch1.8 KBjohnv
#85 1038652-comment-body-field-85-tests-and-fix-D8.patch3.19 KBjohnv
#84 1038652-comment-body-field-84-tests-only-D7.patch1.83 KBjohnv
#84 1038652-comment-body-field-84-tests-and-fix-D7.patch3.75 KBjohnv
#82 1038652-comment-body-field-82-fix-and-test-D7.patch3.01 KBjohnv
#10 comment.patch1.19 KBdroplet
#17 1038652-deleted-comment-body-test-with-10.patch2.11 KBNiklas Fiekas
#17 1038652-deleted-comment-body-test.patch939 bytesNiklas Fiekas
#19 comments.patch3.25 KBdroplet
#20 1038652-deleted-comment-body-test-2-with-19.patch4.12 KBNiklas Fiekas
#20 1038652-deleted-comment-body-test-2.patch894 bytesNiklas Fiekas
#22 1038652-deleted-comment-body-notices-with-test.patch4.87 KBNiklas Fiekas
#29 1038652-no-comment-body-field.patch4.04 KBdixon_
#32 1038652-no-comment-body-field-2.patch4.14 KBdixon_
#47 comment_body_everywhere.txt11.55 KBChi
#52 comment-1038652-52.patch4.8 KBdcam
#55 comment-1038652-55.patch5.1 KBdcam
#60 1038652-no-comment-body-field-60.patch5.1 KBNiklas Fiekas
#65 1038652-no-comment-body-field-65-tests-and-fix.patch3.89 KBBoobaa
#65 1038652-no-comment-body-field-65-tests-only.patch1.24 KBBoobaa
#68 1038652-no-comment-body-field-68-tests-and-fix-D7.patch2.87 KBBoobaa
#68 1038652-no-comment-body-field-68-tests-only-D7.patch1.09 KBBoobaa
#74 1038652-no-comment-body-field-74-tests-and-fix.patch3.8 KBBoobaa
#74 1038652-no-comment-body-field-74-tests-only.patch1.25 KBBoobaa
#78 1038652-no-comment-body-field-78-tests-and-fix.patch2.7 KBBoobaa
#78 1038652-no-comment-body-field-78-tests-only.patch1.25 KBBoobaa
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

droplet’s picture

rogical’s picture

not the same issue, I'm using 7.7, and also get the this issue after commet_body was deleted(the reason I deleted was it can't be retrieved by views, while fields can.):

Notice: Undefined property: stdClass::$comment_body 在 comment_submit() (行 2164 在 /opt/difang/prod/qlkaixin/modules/comment/comment.module).

Jānis Bebrītis’s picture

fix for rogical

  • disable comment module
  • uninstall it using uninstall tab at modules list.
  • open any sql browser and delete these tables:
    1. comment
    2. field_data_comment_body
    3. node_comment_statistics
    4. field_data_comment_body
    5. field_revision_comment_body
  • enable comment module, et voila!
    • I hope it helps ;)

rogical’s picture

thanks, but it deleted all comment contents and more or less effect the core I think.

I mean my site is already on production.

catch’s picture

Title: errors when deleting the comment_body field » comment_submit() and comment_admin_overview() assume body field exists, throw notices if not
Version: 7.x-dev » 8.x-dev
Priority: Normal » Major
Issue tags: +Novice, +Needs backport to D7

Fixing issue metadata, it's wrong for these functions to assume the comment body exists. Should be an easy fix so tagging as 'novice'.

catch’s picture

Priority: Major » Normal

Back to normal, this is annoying but requires comments with no body which is relatively unusual.

rogical’s picture

would be usual when D7 users begin to be familar with comment entity.

and unfortunately views can't retrieve the default comment body, another body filed is needed.

servantleader’s picture

+1
Working on a Drupal distribution that will have body field removed by default.

rogical’s picture

One more, the comment title would auto retrieve data from default comment body if the title is not filled.

This should be fixed if comment body is deleted. And as the comment body is designed to be deleteable, so this should be fixed.

droplet’s picture

Status: Active » Needs review
FileSize
1.19 KB

not tested yet but make sense to me.

rogical’s picture

Status: Needs review » Needs work

your patch is not for this issue, comment_body should not be hardcoded anymore as comment body may be removed.

droplet’s picture

@rogical

oh. do you meant we should use another field instead ? so if there have 2 fields, how to handle it ? Node hasn't this implement too.

rogical’s picture

there are 2 points:

1. the comment_body filed is deleteable, so there should no other errors if user delete it.

2. views can't retrieve comment_body, but OK to other fields(long text, text etc.), so if user want to use views to retrieve comment body, how to do that? The only solution is delete the default comment_body and create a long text field.

droplet’s picture

Status: Needs work » Needs review

1. solved in patch
2. views problem, not a core issue.

back to review.

Niklas Fiekas’s picture

Subscribe.

@droplet: Please explain. If you are using $comment->comment_body without a check, how would that fix the issue?

+    $comment_body = $comment->comment_body[LANGUAGE_NONE][0]['value'];

Edit: As for the Views thing, I think you can display the comment body now.

rogical’s picture

Status: Needs review » Needs work

same question, as $comment->comment_body should be have deleted.

Niklas Fiekas’s picture

Status: Needs work » Needs review
FileSize
2.11 KB
939 bytes

I created a testcase to verify this bug; consider reviewing it and including it into your patches.
The secound patch is the test case + #10, though the patch is probably not the right one - just in case I missed something.

Setting to needs review to let the testbots have a go at it.

This won't be easy to fix properly, however. The point in #12 is right. We can't determine a good automatic title in all cases. Maybe we can in some?

Status: Needs review » Needs work

The last submitted patch, 1038652-deleted-comment-body-test-with-10.patch, failed testing.

droplet’s picture

Issue tags: -Novice
FileSize
3.25 KB

Oh. my patch should not copy the $var again & the other errors show on #17 is easy to get rid of it.

Instead fix it, it can be totally remove comment body, not sure if committer like it.

If removed, we cannot backport to D7? Contri Modules are think it always exist there.

Patch attached gives someone who want to get rid of the error. I stay the issue status as need work for more discuss :)

Niklas Fiekas’s picture

Status: Needs work » Needs review
FileSize
4.12 KB
894 bytes

My patch in #17 contained a random */, so the results didn't say a thing. However FAIL / FAIL was expected.

Corrected that. Now lets see how the testcase does on it's own. Hopefully it fails because of Notice: Undefined property: stdClass::$comment_body in comment_submit() (line 2183 of /home/user/public_html/drupal7/modules/comment/comment.module)..

And lets see how it does with your fix. So setting to needs review.

Reviewing your patch: It looks good.

One thing: Maybe leave

+      if ($comment->subject == '') {
+        $comment->subject = t('(No subject)');
+      }

out of the isset block?

 

Edit:
As for the Drupal 7 backport, I think we should do it. If the user deletes the body field, there should be no core errors. And of course no errors in Contrib as well, but we're not making it worse by fixing it in core.

droplet’s picture

@#20,
"out of the isset block?"

Your right, thanks.

Niklas Fiekas’s picture

Did that, another round of testing.

Niklas Fiekas’s picture

Status: Needs review » Reviewed & tested by the community

Great. RTBC.

Full disclosure: I wrote the testcase that verifies this bug and is part of the patch.

klausi’s picture

Status: Reviewed & tested by the community » Needs review

don't RTBC your own patches ;-)

Niklas Fiekas’s picture

Ok, thanks klausi. Wasn't sure since it wasn't my fix.

dixon_’s picture

Status: Needs review » Needs work

To me, the tests on this

+++ b/modules/comment/comment.admin.inc
@@ -98,13 +98,14 @@ function comment_admin_overview($form, &$form_state, $arg) {
+    $comment_attr_title = !empty($comment->comment_body[LANGUAGE_NONE][0]['value']) ? truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 128) : $comment->subject;

We don't usually use abbreviations in variable names ($comment_attr_title).

+++ b/modules/comment/comment.test
@@ -1977,4 +1977,21 @@ class CommentFieldsTest extends CommentHelperCase {
+  function testDeletedCommentBody() {
+    // Delete the comment body.
+    $this->drupalLogin($this->admin_user);
+    $this->drupalPost('admin/structure/types/manage/article/comment/fields/comment_body/delete', array(), t('Delete'));
+
+    // Preview an empty comment.
+    $this->drupalLogin($this->web_user);
+    $this->drupalPost('node/' . $this->node->nid, array(), t('Preview'));
+
+    // Post an empty comment.
+    $this->drupalPost('node/' . $this->node->nid, array(), t('Save'));
+  }

We don't assert anything here. Shouldn't we at least look for the new comment on the page?

26 days to next Drupal core point release.

dixon_’s picture

+++ b/modules/comment/comment.module
@@ -2161,17 +2161,20 @@ function comment_submit($comment) {
     // Edge cases where the comment body is populated only by HTML tags will
     // require a default subject.
-    if ($comment->subject == '') {
+    if (trim($comment->subject) == '') {
       $comment->subject = t('(No subject)');
     }

Also, I'm not sure how this related to this bug report? Can you explain? I looks like a reasonable thing to do, but I think that should go in another issue.

26 days to next Drupal core point release.

Niklas Fiekas’s picture

Thank you for reviewing. I'll reroll the patch soon.
As for #27: Have a look at the hunk before that. A trim is removed there.

dixon_’s picture

Status: Needs work » Needs review
FileSize
4.04 KB

Here is a re-roll that also improves the tests by checking the administration overview page too.

I can confirm that the tests fail without the fix (due to the generated warnings), and the tests pass locally with the fix implemented. So all looks good to me.

dixon_’s picture

I'll post a separate issue about the trim() in #27, since that's not related to what we are trying to fix here. We should keep fixes separate.

Niklas Fiekas’s picture

Thank you for rerolling.

I am a bit confused.

This line
$comment->subject = truncate_utf8(trim(decode_entities(strip_tags($comment_text))), 29, TRUE);
is moved into an if block. So isn't the missing trim a regression introduced by this fix?

dixon_’s picture

I see! *stupid me*

Here is a new patch that correctly includes the trim we need if no comment_body exists (no new issue opened).

Patricia_W’s picture

Where is the comment_body defined. I just tried to enter a new comment for a page and I got this error. I accidentally deleted the body on the page but restored it. Did that also delete the comment_body and if so how do I restore it?

Niklas Fiekas’s picture

Currently there is no way to restore the comment_body field in the UI in case it got deleted, as all custom fields are prefixed with field_ (except creating a new content type).

The patch here solves the warnings, but comment_body is still the hardcoded fieldname. I am not sure what we could do about that.

Patricia_W’s picture

Actually there is a way to restore it ... add an EXISTING field ... not add a new field.

rogical’s picture

comment_body is not an existing field, as it's designed to be deleteable, so it should be able to be deleted!

I just the one want to delete the comment_body in my site, and use specified fields instead.

Niklas Fiekas’s picture

Oh, I wasn't aware of that. Apperently it works only if you have got at least one other content type where it exists - at least "on my machine". Maybe special fields like this one should always be in the "add existing fields" selectbox?

Then for now the workaround would be:
- Create a random content type
- Restore the comment_body field, because it's existing now
- Delete the random content type

Edit:
@rogical: Yes, but there is hardcoded behaviour that makes the field special. And one more thing is special: The name. That means (unless you use the crazy workaround) you can not restore that field, which again is special, because you can "restore" any other field. I'd love to make the comment_body field not special in any way - but that isn't a trivial problem.
If that problem isn't solved, there should at least be a way, to undo the deletion, if you need that special field for special behaviour.

Edit 2:
Maybe we could actually render the comment to get a few characters for the subject?

Edit 3:
Weren't there attempts to make the title field a normal field, too?

Patricia_W’s picture

I was able to add the comment body field back to the comment fields and it is working without any error messages. Since the comment_body is a special field it is part of the core and can't be deleted (AFAIK) so adding it back is not a problem.

Niklas Fiekas’s picture

@Patricia_W: Please try this:
- Make sure you have only one content type.
- Delete the comment_body field.
- Try adding it back - that shouldn't be possible.

Patricia_W’s picture

I hope you aren't serious about having only one content type. Do you mean I should remove all my content types? I do not intend to destroy my site.

Niklas Fiekas’s picture

Assuming you were on a testing/development site I was indeed serious ;) Luckily you didn't do that on production. Otherwise I would have felt guilty for not warning you.

So: It's good that this problem doesn't exists if you have content types where the comment_body field is still attached, but there is this edge case, where you can't add it back like that.

Patricia_W’s picture

As I said ... I did add it back like that. I had also deleted the body field from the same content type while I was migrating to D7 and didn't know better, and I may have deleted the comment body at the same time. I had restored the body field by adding an existing field but had not noticed that that the comment_body was also missing until I tried to add a comment.

What do you mean by "edge case"?

What would cause the comment_body field not to be attached? Isn't it just part of the core fields?

Niklas Fiekas’s picture

That edge case is, again: There is no other content type that has a comment_body field. To reproduce that you would have to delete the content types or comment_body fields of your existing content types (Please don't do that on your production site). It is added by core code, but you can delete it field instances just like instances of any other field.

Patricia_W’s picture

Thanks for the clarification. I did not read the fine print.

dixon_’s picture

Issue tags: -Needs backport to D7

Status: Needs review » Needs work
Issue tags: +Needs backport to D7

The last submitted patch, 1038652-no-comment-body-field-2.patch, failed testing.

Chi’s picture

FileSize
11.55 KB

This error message also apears on comment preview page. It seems not so easy to fix, because it has a lot of hard coding.

Here seach results for "comment_body".

wayne57’s picture

This is quite a confusing thread.
is there a way to fix the problem of getting:
Notice: Undefined property: stdClass::$comment_body in comment_submit() (line 2180 ...
in both the node when adding a comment and also in the admin comment page??

Niklas Fiekas’s picture

@wayne57: Yes, applying the patch in #29 should be a quick fix until this is polished enough to get in.

Admittedly I had forgotten about this issue. It shouldn't be too hard to get this fixed.

wayne57’s picture

Version: 8.x-dev » 7.x-dev

I am getting this in D7, will this work in D7 as well?

Niklas Fiekas’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Novice

Yes. For this issue, however, we will have to do D8 first. Tagging novice to reroll the patch with LANGUAGE_NOT_SPECIFIED instead of LANGUAGE_NONE.

dcam’s picture

FileSize
4.8 KB

This reroll was a little complex due to all the changes that have occurred since last September. Hopefully I got it worked out correctly. We'll see what Testbot thinks.

The changes from LANGUAGE_NONE to LANGUAGE_NOT_SPECIFIED had already been made. I just had to roll them into the patch.

dcam’s picture

Status: Needs work » Needs review

Oops, setting status.

Status: Needs review » Needs work

The last submitted patch, comment-1038652-52.patch, failed testing.

dcam’s picture

Status: Needs work » Needs review
FileSize
5.1 KB

#52 failed because CommentFormController::actions() tries to set the action elements' #weight based on #form['comment_body']['#weight'] without checking to see if it is set first.

I added the check and set the action elements' #weight = 100 by default if the body element doesn't exist. This doesn't seem like the best approach to me. I'm interested to know if anyone has a better suggestion.

ryan.gibson’s picture

I tested the functionality of the patch from #55. Verified that the error existed before the patch and that after cleanly applying the patch the error no longer appeared. Code review looks okay as well.

I guess this could use some more input on dcam's comments about setting a default #weight so I'm not going to change status atm.

dcam’s picture

#55: comment-1038652-55.patch queued for re-testing.

Devin Carlson’s picture

dagmar’s picture

Status: Needs review » Needs work
+++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php
@@ -294,17 +294,19 @@ class CommentFormController extends EntityFormController {
+      if (trim($comment->subject == '')) {

I'm pretty sure that this is not correct.

Niklas Fiekas’s picture

Status: Needs work » Needs review
FileSize
5.1 KB

@dagmar: Yeah ... here's a reroll.

tds2012’s picture

Hi

I'm kind of new, but I have the same issue here, instead of body_comment I use an image and I get the same error. Now, that patch sounds interesting but where do I apply it and how?

Thanks!
Tommy

dcam’s picture

Status: Needs review » Needs work
Issue tags: +Novice, +Needs backport to D7

The last submitted patch, 1038652-no-comment-body-field-60.patch, failed testing.

rootwork’s picture

Issue tags: -Novice

I tried to reroll the patch, but it's clear a bunch of stuff has changed in the functions this patch affects. So I've removed the novice tag.

Boobaa’s picture

Rerolled the patch found in #60 against latest drupal-8.x in git; attaching both with and without actual fix to have a red and a green response from testbot. (However, it looks like the asserts mentioned in #26 have not been addressed yet; though the test result does show yellow exceptions. Hope that's enough for testbot to fail, too.)

Status: Needs review » Needs work
Issue tags: -Needs backport to D7

The last submitted patch, 1038652-no-comment-body-field-65-tests-and-fix.patch, failed testing.

Boobaa’s picture

Status: Needs work » Needs review
Issue tags: +Needs backport to D7
Boobaa’s picture

Here is the fix for D7; tests are clean backport from D8 patch, fixes are mine (as I found no usable fix from the previous comments).

Status: Needs review » Needs work
Issue tags: -Needs backport to D7

The last submitted patch, 1038652-no-comment-body-field-68-tests-and-fix-D7.patch, failed testing.

Boobaa’s picture

Status: Needs work » Needs review
Issue tags: +Needs backport to D7
Boobaa’s picture

Oh, forgot to remove the tag.

dcam’s picture

Version: 7.x-dev » 8.x-dev

Setting the issue back to 8.x. The status is still Needs Review for the 8.x patch in #65.

errev’s picture

I got this error trying to patch on D7.

$ git apply -v 1038652-no-comment-body-field-68-tests-and-fix-D7.patch
Checking patch modules/comment/comment.module...
error: modules/comment/comment.module: No such file or directory
Checking patch modules/comment/comment.test...
error: modules/comment/comment.test: No such file or directory

Boobaa’s picture

dimaro’s picture

The last submitted patch, 74: 1038652-no-comment-body-field-74-tests-and-fix.patch, failed testing.

Berdir’s picture

Instead of using isset()/empty, you could use $comment->hasField('comment_body').

Note that this will return TRUE for an empty field (I don't think that's actually allowed), unlike !empty().

The last submitted patch, 78: 1038652-no-comment-body-field-78-tests-only.patch, failed testing.

johnv’s picture

Title: comment_submit() and comment_admin_overview() assume body field exists, throw notices if not » Notices in comment_submit() and comment_admin_overview() when body field does not exist or is not required
Issue summary: View changes

This issue/patch also resolves the problem of #2045409: Notice: Undefined offset: 0 in comment_submit() (line 2197 of comment/comment.module) :

I get the following notice when comment Body field is not required and not filled "Notice: Undefined offset: 0 in comment_submit() (line 2197 of mysite.com/modules/comment/comment.module)

I made it a duplicate of this issue.

But it then needs an extra testNotRequiredCommentBody()..

johnv’s picture

I applied #68 on 7.x successfully.
@errev (#74) : you could not apply the patch. It seems you started from the wrong directory.

johnv’s picture

Version: 8.x-dev » 7.x-dev
FileSize
3.01 KB

Attached is a new D7-version of #68. It still lacks the extra testNotRequiredCommentBody() test.

dcam’s picture

Version: 7.x-dev » 8.x-dev

Sending this back to 8.x.

johnv’s picture

Version: 8.x-dev » 7.x-dev
FileSize
3.75 KB
1.83 KB

Sorry to bother, attached D7-patches with tests.

johnv’s picture

The D8-patches from #78 are not valid anymore. Attached a new try.
- The fix contents did not need changing for 'not required comment_body'
- The test now contains an extra test for the new use case.

johnv’s picture

Version: 7.x-dev » 8.x-dev

Not sure how to trigger the testbot for D8-patch.
[EDIT] Oh, seems something is happening...

Status: Needs review » Needs work

The last submitted patch, 85: 1038652-comment-body-field-85-tests-only-D8.patch, failed testing.

The last submitted patch, 85: 1038652-comment-body-field-85-tests-and-fix-D8.patch, failed testing.

johnv’s picture

johnv’s picture

Status: Needs work » Needs review

The last submitted patch, 84: 1038652-comment-body-field-84-tests-and-fix-D7.patch, failed testing.

The last submitted patch, 84: 1038652-comment-body-field-84-tests-only-D7.patch, failed testing.

The last submitted patch, 89: 1038652-comment-body-field-89-tests-and-fix-D8.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 89: 1038652-comment-body-field-89-tests-only-D8.patch, failed testing.

johnv’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Needs work » Needs review
FileSize
3.04 KB
5.33 KB

OK, I learned how to run tests on my local machine, and how to write proper tests.
Attached D7-patches have better tests.
next stop: a fresh attack on D8.

The last submitted patch, 95: 1038652-comment-body-field-95-test_only-D7.patch, failed testing.

johnv’s picture

Version: 7.x-dev » 8.0.x-dev
uwe_a’s picture

Greetings, So do we wait for backport or do we keep tracking d7 issue (https://www.drupal.org/node/2077901 for example) ?

larowlan’s picture

Version: 8.0.x-dev » 7.x-dev

Not a problem in D8

wOOge’s picture

Until there is a working patch for D7 and it's committed, I did the following to "solve" the problem:

  • Restored the the original comment_body by using the "Add existing field" option
  • Made the comment_body field required
  • Added some placeholder text in the comment_body settings so that even if required, the user would not have to enter data into it
  • Hid the comment_body field using Filed Permissions (https://www.drupal.org/project/field_permissions) Module
johnv’s picture

Issue summary: View changes

Indeed, the D8-version is very different, and has no problems.
I Added the symptoms of #2077901: Comment Preview Error for Plain Text (Undefined index: format in comment_preview()) to the summary.

@uwe_a, @wOOge, the best way to get this issue committed is to test the latest patch, confirm it works and set it to RTBC after 2 positive confirmations.

The last submitted patch, 95: 1038652-comment-body-field-95-test_only-D7.patch, failed testing.

rodrigoaguilera’s picture

Status: Needs review » Reviewed & tested by the community

Manual testing on 7.x:

without the patch there is notices and with the patch the notices are gone

Reviewed also the code and looks ok.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 95: 1038652-comment-body-field-95-test-and-fix-D7.patch, failed testing.

sun-fire’s picture

#100 solve problem for me. Thanks!

Status: Needs work » Needs review
David_Rothstein’s picture

Status: Needs review » Reviewed & tested by the community

Looks like a testbot fluke.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 95: 1038652-comment-body-field-95-test-and-fix-D7.patch, failed testing.

Status: Needs work » Needs review
David_Rothstein’s picture

Status: Needs review » Reviewed & tested by the community

Testbot fluke.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 95: 1038652-comment-body-field-95-test-and-fix-D7.patch, failed testing.

Status: Needs work » Needs review
David_Rothstein’s picture

Status: Needs review » Reviewed & tested by the community

Testbot fluke.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 95: 1038652-comment-body-field-95-test-and-fix-D7.patch, failed testing.

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs work

I would like to get this in but there are a few issues here, mostly small things but not entirely.

  1. +      if(isset($comment_text)){
    +        $comment->subject = truncate_utf8(trim(decode_entities(strip_tags($comment_text))), 29, TRUE);
    +      }
         }
    -    $comment->subject = truncate_utf8(trim(decode_entities(strip_tags($comment_text))), 29, TRUE);
    -    // Edge cases where the comment body is populated only by HTML tags will
    -    // require a default subject.
    +    // Edge cases where the comment body is populated only by HTML tags or does
    +    // not exist will require a default subject.
         if ($comment->subject == '') {
           $comment->subject = t('(No subject)');
         }
    

    Since we're no longer guaranteeing that $comment->subject will be trimmed, don't we have to do if (trim($comment->subject) == '') { at the bottom instead?

    Otherwise I think we're introducing a bug where the comment subject could wind up empty in the end, rather than saying "No subject".

  2. +  /**
    +   * Test that saving an empty, required body generates a warning, and cannot be saved.
    +   */
    +  function testCommentEmptyRequiredBody($required = TRUE) {
    
    ....
    
    +  /**
    +   * Test that saving an empty, NON-required body generates a warning, and cannot be saved.
    +   */
    +  function testCommentEmptyNonRequiredBody($required = FALSE) {
    

    Why do these test functions take a parameter? There is no code that will ever pass it in...

  3. +  /**
    +   * Test that a comment can be previewed and saved without the comment_body field,
    +   * and without generating warnings.
    +   */
    +  function testCommentDeletedBody() {
    

    The function summary should fit on one line, 80 characters or less.

  4. +      elseif(isset($comment_body['value'])){
    +        $comment_text = check_plain($comment_body['value']);
    +      }
    

    Here and elsewhere, there are a lot of spacing issues (for example there should be spaces after "elseif" and before the "{" (see https://www.drupal.org/coding-standards#controlstruct).

xenophyle’s picture

geekygnr’s picture

I patched with #120 and the notices went away.

johnv’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 120: 1038652-comment-body-field-120-test-and-fix-D7.patch, failed testing.

David_Rothstein’s picture

Status: Needs work » Needs review
nickonom’s picture

I do confirm the patch in #120 is applied cleanly on PHP 7.0.8 and addresses the issue.

jacob.embree’s picture

Status: Needs review » Needs work

+ } // Attach the user and time information.
The comment should be on its own line, separate from the closing brace.

There are a bunch of trailing spaces.

nickonom’s picture

With PHP 7.1.7 the last patch is giving:

git apply 1038652-comment-body-field-120-test-and-fix-D7.patch
1038652-comment-body-field-120-test-and-fix-D7.patch:61: trailing whitespace.
   * 
1038652-comment-body-field-120-test-and-fix-D7.patch:78: trailing whitespace.
  
1038652-comment-body-field-120-test-and-fix-D7.patch:81: trailing whitespace.
   * 
1038652-comment-body-field-120-test-and-fix-D7.patch:101: trailing whitespace.
   * Tests that the comment_body field is not required. 
1038652-comment-body-field-120-test-and-fix-D7.patch:102: trailing whitespace.
   * 
warning: squelched 2 whitespace errors
warning: 7 lines add whitespace errors.
jacob.embree’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.22 KB

#120 fixes the issues mentioned by David_Rothstein in #119. #128 is the same but without the whitespace errors.

silverham’s picture

#128 fixes the notice error for me too. Patch applies cleanly.

mandreato’s picture

#128 does work for me too.

nickonom’s picture

I wonder will this ever be applied?

yuraosn’s picture

The problem is urgent for v: 7.59

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 128: 1038652-128.patch, failed testing. View results

poker10’s picture

Unfortunatelly the patch #128 fails the core tests now. This needs work.