Document how conditions treat empty and null values
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- php
- Área
- documentation
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PHP
- Estrellas
- 133
- Forks
- 405
- Merge medio
- 21 h 45 min
- PR fusionados (30 d)
- 12
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de statamic/docs
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Chunked UploadsAbierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Installation / Deployment Guides
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 40/100
Los mantenedores suelen responder en 1 día
-
Document the `query_scope` search index optionPosiblemente ocupada @joshdaugherty la tomó hace 12 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 18/100
Los mantenedores suelen responder en 1 día
Todos los issues de statamic/docs
Issues similares
-
FrameworkBundle SecurityBundle
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
symfony/symfony-docs#23277 ·
Los mantenedores suelen responder en 3 días
-
[Sync EN] hard link does not need special permissionsPosiblemente ocupada @lacatoire la tomó hoy. Abiertosync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
sync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 4 días
-
bug mod:appointments
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
3pontos-tech/gil-benefits#303 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día