Problem/Motivation

From the wise mind of @Berdir at #2570593-165: Allow entities to be subclassed using "bundle classes":

One thought I had in to another issue would be to use this in forum.module for its special vocabulary and node type. That could be a big step to transform that module from a forgotten and ignored thing to a decent example and a real-word demonstration of this feature. Might also allow us to fix #2010132: Canonical taxonomy term link for forum vocabulary is broken although I'm still unsure about that feature, should probably use aliases instead
...
An early proof of concept might help to convince anyone who still doubts that this is useful though :)

To which @larowlan replied:

Great idea, forum is the ideal use case

Steps to reproduce

N/A

Proposed resolution

  • Add a ForumNode bundle class.
  • Put stuff in there.

Remaining tasks

  1. Land #2570593: Allow entities to be subclassed using "bundle classes"
  2. Define a ForumNode class.
  3. Register it with the entity system.
  4. Decide what to put in there.
  5. ...

User interface changes

Hopefully none.

API changes

TBD.

Data model changes

Nope.

Release notes snippet

TBD.

Comments

dww created an issue. See original summary.

dww credited Berdir.

dww credited larowlan.

dww’s picture

longwave’s picture

Great idea! book.module also seems like an ideal candidate for this.

larowlan’s picture

Title: [PP-1] Add a bundle subclass for forum.module's business logic » Add a bundle subclass for forum.module's business logic

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.

AaronMcHale’s picture

Back when I maintained a site that used Forum, one of things we wanted was the ability for multiple content types to be able to be used for forum posts. The idea was that then some forums/containers could have posts with a different set of fields to other forums/containers. The way to achieve this ultimately was with one content type but using conditional fields module, it was a bit of a mess but it worked.

This issue got me thinking about that, and a Forum bundle class seems like a way forward for potentially supporting that scenario.

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.

quietone’s picture

Status: Active » Postponed

Forum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

It will be moved to the contributed extension once the Drupal 11 branch is open.

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.

quietone’s picture

Project: Drupal core » Forum
Version: 11.x-dev » 1.0.1
Component: forum.module » Code
Status: Postponed » Active
Berdir’s picture

FWIW, one thing to consider is backwards compatibility. If a custom site also defined a bundle class for the forum node type, then either this won't be used as it's overwritten, resulting in fatal errors/non-executed blocks of code if they check for an interface or so. Or the custom class is replaced, equally resulting in either fatal errors or code not being executed.

BC would be quite challenging to handle.

#8: Bundle classes are just a neat way to organize code, they don't allow to do something that can't be done otherwise as well. In this case, a setting to configure which node types could be used in forum. The only difference is where that setting is checked exactly, in node hook or so, or in the bundle info alter hook. In other words, not really related.