[2.x] Tags: one way for extensions to tell primary from secondary tags

Abierto
#5,455 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Saksham-chourasia ya está trabajando en esto.

Desde el 13/11/2026.

  • #5504 de @Saksham-chourasia — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, laravel, php
Área
api, backend, frontend

Línea de trabajo

Start with the backend and frontend Tag models, then trace the position checks named in the tags extension: GlobalPolicy, DiscussionResourceFields, Content\Tags, the admin and forum Tags pages, addTagList, addTagComposer, TagSelectionModal, and sortTags. Compare their existing checks with is_primary and the stated counting rules; the issue lists the required helpers, query scopes, compatibility behavior, and documentation updates. Done when these checks use the helpers, secondary tag positions remain null in 2.x, and the deprecation is documented.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

needs-discussion type/feature

Extensions, and the tags extension itself, decide whether a tag is primary by checking position: a secondary tag has none. That ties the tag's kind to its order, which stops secondary tags from ever being ordered (#5236), and the check is repeated in about ten places, with small differences.

Tags already store the kind in is_primary, exposed as isPrimary in the API and Tag.isPrimary() in JS. A child of a primary tag is a primary tag: is_primary is true for it, as it is for its parent.

Proposal

On the backend Tag model and the frontend Tag model:

  • isPrimary(): a primary tag or a child of one, read from is_primary.
  • isChild(): a child of a primary tag.
  • isPrimaryParent(): a primary tag without a parent (frontend already has it).
  • isSecondary(): !isPrimary().
  • Backend query scopes Tag::query()->primary() and ->secondary().

Then:

  • Move every check in the tags extension from position to these: GlobalPolicy, DiscussionResourceFields, Content\Tags, the admin and forum Tags pages, addTagList, addTagComposer, TagSelectionModal and sortTags.
  • Keep position null for secondary tags in 2.x, so extensions that check it keep working, and mark that check deprecated in the changelog and the extension docs.
  • The required tag counts keep their behaviour: top-level primary tags count as primary, every other tag (children included) towards the secondary limits. Name it that way in code and docs rather than calling children secondary.

This depends on repairing is_primary: the admin edit modal currently clears it when saving an existing tag. That repair is included in the work on #5236.

The permission mismatch and child-tag counting discussion already have #4065 and #3640; this proposal supplies consistent helpers without deciding a new counting policy.

Lenguaje dominante
PHP
Estrellas
6.8k
Forks
891
Merge medio
1 d 10 h
PR fusionados (30 d)
209

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de flarum/framework

Todos los issues de flarum/framework

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.