Document how conditions treat empty and null values
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Dokumentation
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- php
- Bereich
- documentation
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- PHP
- Sterne
- 133
- Forks
- 405
- Ø Merge
- 21 Std. 45 Min.
- Gemergte PRs (30 T.)
- 12
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus statamic/docs
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
Chunked UploadsOffen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
Installation / Deployment Guides
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 40/100
Maintainer antworten meist innerhalb von 1 Tag
-
Document the `query_scope` search index optionEvtl. vergeben @joshdaugherty hat das vor 11 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 18/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
sync-en
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
sync-en
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 4 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
ProfessionalWiki/NeoWiki#1637 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Перевод устарел
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
bug
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 76/100
m3ue/m3u-editor#1604 ·
Maintainer antworten meist innerhalb von 1 Tag