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

Đang mở
#5,455 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Saksham-chourasia đang làm issue này rồi.

Từ ngày 13/11/2026.

  • #5504 của @Saksham-chourasia — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, laravel, php
Lĩnh vực
api, backend, frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
6.8k
Fork
891
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
209

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flarum/framework

Tất cả issue của flarum/framework

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.