Updated: Comment #0
Problem/Motivation
Follow-up from #2028025: Expand CommentInterface to provide methods. That issue is close and not to be derailed with tidying up. This is the follow-up to discuss and take care of $comment->is_anonymous and $comment->is_preview variable
in 2028025 #35 by @ceng
This leaves the $comment->is_anonymous and $comment->is_preview variables still to tidy up. I think this patch is good to go if these are moved out to follow up issues, the patch is getting quite big with a number of changes.
grepping core with the patch from 2028025 applied for is_anonymous and is_preview,
yields no result for is_preview at all,
and is_anonymous in:
core/modules/comment/lib/Drupal/comment/CommentFormController.php
213: $form['is_anonymous'] = array(
280: if ($form_state['values']['name'] && !$form_state['values']['is_anonymous'] && !$account) {
284: elseif ($form_state['values']['is_anonymous']) {
322: if (!$comment->is_anonymous && !empty($author_name) && ($account = user_load_by_name($author_name))) {
327: if ($comment->is_anonymous && (!isset($author_name) || $author_name === '')) {
which look like reads but not writes.
These were also discussed in #26, #27, and @Berdir says in #28
If that's the case, then I doubt that's set. The NG (now ContentEntity) form controller only sets explicitly defined fields, everything else is ignored. You have to override and extend buildEntity() to set more stuff, see NodeFormController.
2028025 patch has no instances of is_anonymous and is_preview, so it wasn't that patch that took it out. Maybe it was another issue.
Proposed resolution
remove or convert is_anonymous and is_preview to explicit properties with getters and setter methods.
Remaining tasks
- figure out if there is some form magic that sets them
- evaluate if we might have missing test coverage (in the case that those values are never set, why are we testing them in the ifs)
User interface changes
No
API changes
Maybe
Comments
Comment #1
rosinegrean CreditAttribution: rosinegrean commentedHello,
I can try to work on this.
Comment #2
andypostSeems only "is_anonymous" left to fix.
The following should get own issue
The actual state
Comment #5
pjohans CreditAttribution: pjohans commentedi have been looking at this issue and where it comes from https://www.drupal.org/node/2028025
the core/modules/comment/lib folder doesn't exist anymore.
the commentFormController file doesn't exist
methods is_preview and is_anonymous are only used in some tests
all in all i would say this issue is deprecated - it should be removed from the issue queue
Comment #15
smustgrave CreditAttribution: smustgrave at Mobomo commentedAgree with #5 https://www.drupal.org/node/2028025 made this ticket obsolete
Comment #16
BerdirThis issue is a follow-up of the one that's referenced. And the code was just moved around, it still exists, for example \Drupal\comment\CommentViewBuilder::alterBuild.