Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Document how conditions treat empty and null values

未关闭
#2,000 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@joshdaugherty 已经在做这个了。

开始于 2026年9月30日。

  • #2001 来自 @joshdaugherty —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
25/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
documentation

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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 to null, the condition filters for entries where that field is empty.

Docs PR with that wording: #2001.

主要语言
PHP
星标
133
派生
405
平均合并
21 小时 45 分钟
30 天内合并 PR
12

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

statamic/docs 的其他 Issue

查看 statamic/docs 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。