Problem statement

ForumController::addForum() method includes a typo in the machine name for the "Container" field. It should be forum_container instead of forum_controller.

  public function addForum() {
    $vid = $this->config('forum.settings')->get('vocabulary');
    $taxonomy_term = $this->termStorage->create([
      'vid' => $vid,
      'forum_controller' => 0,
    ]);
    return $this->entityFormBuilder()->getForm($taxonomy_term, 'forum');
  }

However, the default value is 0, so this line is not need at all.

Proposed resolution

Remove the redundant line.

Remaining tasks

Commit

Comments

Elin Yordanov created an issue. See original summary.

larowlan’s picture

Priority: Minor » Normal
Issue tags: +Bug Smash Initiative, +Needs tests

This would actually impact functionality

larowlan’s picture

Issue tags: +Novice
shashwat purav’s picture

Status: Active » Needs review
StatusFileSize
new616 bytes

Patch added

gauravvvv’s picture

StatusFileSize
new17.44 KB

Patch applied cleanly and fixed the typo. Moving to RTBC

gauravvvv’s picture

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

Status: Reviewed & tested by the community » Needs work

We still need a test here

gauravvvv’s picture

shashwat purav’s picture

Hello @larowlan, please suggest the test that need to perform.

larowlan’s picture

Visit the add page, and make sure the field value is set correctly

guilhermevp’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new21.26 KB

Forum creation and containers seems to be working fine after patch.

RTBC +1

ey’s picture

Status: Reviewed & tested by the community » Needs work

It still needs automated tests, see comment #7.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned

I tried to write something like:

public function testAddForum() {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('/admin/structure/forum/add/forum');
    $this->submitForm(['name[0][value]' => 'foo'],'Save');
    $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load(1);
    $forum_container_value = $term->forum_container->value;
    $this->assertEquals('0', $forum_container_value, 'The key forum_container exists.');
  }

But even if the key is forum_controller, the test passes. So not sure how to do it.
And not sure how to verify it directly on the add page as the field is not rendered.

larowlan’s picture

Category: Bug report » Task

I think the issue is that the default value is zero, so the change here makes no difference

I think if the tests add additional coverage, we should add them.

But I think we should remove the line altogether, it doesn't matter that it says 'forum_controller', because the default of zero is still applied for 'forum_container'.

It could say 'forum_potato' and still work :)

So yeah, if the tests add new coverage, let's add them.

And let's remove the line altogether.

And that also means this is a task, for cleanup, rather than a user-facing bug.

Thanks everyone for their work so far.

larowlan’s picture

shashwat purav’s picture

Status: Needs work » Needs review
StatusFileSize
new584 bytes
new585 bytes

Added interdiff and patch for the changes suggested in #15

larowlan’s picture

Thanks, so we just need to confirm that we have existing coverage that addForum creates a forum (not a container).

If we do, then this is RTBC

ilgnerfagundes’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new25.13 KB

I applied the patch and can normally create the forum and the container

catch’s picture

Status: Reviewed & tested by the community » Needs review

Still need an answer for #18 I think.

paulocs’s picture

So if we add the test that I wrote in comment #14 in the patch, we can confirm that the addForum is creating a Forum.

Or do we need to add anything more?

volkswagenchick’s picture

Issue tags: +FLDC2021

Tagging for Florida DrupalCamp which is happening today, Feb 10, 12-4pm ET

Thanks

le72’s picture

I confirm addForum creates a forum after patching with #17 .

le72’s picture

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

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Issue tags: -Bug Smash Initiative, -Needs tests, -Novice +Bug Smash Initiative Novice

Thanks folks, we still need to confirm that we have existing test coverage that addForum creates a forum (not a container).

I'll update the issue summary with that step so that this doesn't get marked RTBC again without it.

quietone’s picture

Issue tags: -Bug Smash Initiative Novice +Bug Smash Initiative, +Novice

Updating tags

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

bebalachandra’s picture

StatusFileSize
new510.12 KB
new271.16 KB

Patch #17 implemented as per #15 guidelines. Patch seems like solution for the existing issue. Leaving as needs review for further verifications

larowlan’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

We have existing test coverage for this form and that the forum_container field is set correctly in \Drupal\Tests\forum\Functional\ForumTest::createForum

So, the patch in #17 is indeed RTBC

Updated issue summary.

alexpott’s picture

Version: 9.4.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Not created any screenshots as these didn't answer the question whether we have existing automated test coverage of forum creation. That was answered in #31.

Committed and pushed 3cb6f37cc1 to 10.1.x and 2301594474 to 10.0.x and 1163080ceb to 9.5.x. Thanks!

Not backporting to 9.4.x as this is a task and changes runtime code.

  • alexpott committed 3cb6f37 on 10.1.x
    Issue #3196619 by Shashwat Purav, larowlan, paulocs, Elin Yordanov: Typo...

  • alexpott committed 2301594 on 10.0.x
    Issue #3196619 by Shashwat Purav, larowlan, paulocs, Elin Yordanov: Typo...

  • alexpott committed 1163080 on 9.5.x
    Issue #3196619 by Shashwat Purav, larowlan, paulocs, Elin Yordanov: Typo...

Status: Fixed » Closed (fixed)

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