Document how conditions treat empty and null values
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- php
- Lĩnh vực
- documentation
Hướng nghiên cứu
The change belongs on the conditions page of the docs, under the 'Using a variable reference' section. To confirm the behaviour, read Statamic\Tags\Concerns\QueriesConditions::queryableConditionParams() in statamic/cms, which skips parameters whose value is an empty string but passes null through. Done means the note is in the docs, but PR #2001 is already open with this wording, so check that PR before writing anything new.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The conditions page doesn't say what a condition does when its value is empty or null. Two different things happen, depending on how the value is passed. Both are easy to hit when the value comes from something that can be blank, such as a query-string value, an optional field or an empty picker.
Measured on statamic/cms v6.26.0, with the collection tag on a collection of 75 published entries:
| Template | Value the tag receives | Result |
|---|---|---|
type:is="", or type:is="{{ get:type }}" when type is absent from the query string |
'' |
The condition is skipped: all 75 entries are returned |
:type:is="some_var" when some_var is null or not set |
null |
Filters to entries where type is null, so only entries without that field are returned |
:type:is="some_var" when some_var is '' |
'' |
The condition is skipped, as in the first row |
The skip comes from Statamic\Tags\Concerns\QueriesConditions::queryableConditionParams(), which rejects any parameter whose value is ''. A null is not rejected, so it reaches $query->where($field, null).
Both behaviors seem reasonable. What's missing is a note saying so, because the two forms look interchangeable and do opposite things when the value is blank. The first lists everything; the second can list nothing, for example on blueprint, which every entry has.
Suggested wording, under Using a variable reference:
If a condition's value is an empty string, the condition is skipped and the results are not filtered by it. If a variable reference (
:field:is="variable") resolves tonull, the condition filters for entries where that field is empty.
Docs PR with that wording: #2001.
- Ngôn ngữ chính
- PHP
- Star
- 133
- Fork
- 405
- Merge trung bình
- 21 giờ 45 phút
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của statamic/docs
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Chunked UploadsĐang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Installation / Deployment Guides
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 40/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Document the `query_scope` search index optionCó thể đã có người làm @joshdaugherty đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 18/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của statamic/docs
Issue tương tự
-
needs-triage Platform(Default)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Feature-Request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
RSS-Bridge/rss-bridge#5123 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Store] RstLoader detects headings inside indented code blocksCó thể đã có người làm @lazerg đã nhận hôm nay. Đang mởBug Status: Needs Review Store
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug repo:ckeditor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
No Code Attached Yet
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
joomla/joomla-cms#48611 ·
Maintainer thường phản hồi trong vòng 1 ngày