`render_block_query` overwrites the `core/query` namespace, breaking context for enhanced pagination
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, php, wordpress
- Área
- frontend
Línea de trabajo
Empieza en inc/namespace.php en render_block_query() y compara los atributos que establece con la salida del propio wrapper de consulta de core. Reproduce con un Query Loop usando enhancedPagination y abre la consola, luego confirma que el wrapper conserva el namespace de data-wp-interactive que core ya estableció mientras data-wp-router-region sigue aplicándose. Hecho significa que no hay TypeErrors de prefetch/navigate y que el filtro, la búsqueda y la paginación mejorada siguen funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Plugin version: humanmade/query-filter v0.5.0
Tested on: WordPress 7.1.3, PHP 8.4
Relevant code: inc/namespace.php, render_block_query()
Summary
render_block_query() sets data-wp-interactive="query-filter" on every core/query wrapper. When the query has enhancedPagination: true, core has already marked that same element with data-wp-interactive="core/query" and data-wp-context="{}". Overwriting the namespace shifts the unprefixed data-wp-context under query-filter, so no element provides a core/query context any more and Core's pagination links that still carry core/query:: directives now get undefined back when they look for context.
Console on page load, whenever a previous/next pagination link renders:
view.min.js?ver=7a4ec5bfb61a7137cf4b:1 Uncaught (in promise) TypeError: Cannot destructure property 'url' of 'c(...)' as it is undefined.
at prefetch (view.min.js?ver=7a4ec5bfb61a7137cf4b:1:795)
Steps to reproduce
-
Activate query-filter with no other query-related customisations.
-
Add a Query Loop with enhanced pagination and more than one page of results:
<!-- wp:query {"enhancedPagination":true,"queryId":1,"query":{"perPage":1,"postType":"post","inherit":false}} --> <div class="wp-block-query"> <!-- wp:post-template --> <!-- wp:post-title /--> <!-- /wp:post-template --> <!-- wp:query-pagination --> <!-- wp:query-pagination-previous /--> <!-- wp:query-pagination-numbers /--> <!-- wp:query-pagination-next /--> <!-- /wp:query-pagination --> </div> <!-- /wp:query --> -
Load the page on the front end with the console open.
Expected
No console error. The core/query data-wp-watch prefetch callback reads { url } from its own namespace's context.
Actual
The error above. Rendered wrapper:
<div data-wp-context="{}" data-wp-interactive="query-filter" data-wp-key="1" data-wp-router-region="query-1" class="wp-block-query ...">
...
<a data-wp-key="query-pagination-next"
data-wp-on--click="core/query::actions.navigate"
data-wp-on--mouseenter="core/query::actions.prefetch"
data-wp-watch="core/query::callbacks.prefetch"
href="/?query-1-page=2" class="wp-block-query-pagination-next">
Core's callbacks.prefetch (wp-includes/js/dist/script-modules/block-library/query/view.js):
*prefetch() {
const { url } = getContext(); // undefined: no `core/query` context provider
const { ref } = getElement();
...
}
actions.navigate also assigns ctx.url = ref.href after routing, so clicking Next/Previous throws a second TypeError once navigation completes. Navigation itself still works, which is why this reads as benign.
Cause
render_block_query():
$block_content->set_attribute( 'data-wp-interactive', 'query-filter' );
$block_content->set_attribute( 'data-wp-router-region', 'query-' . ( $block['attrs']['queryId'] ?? 0 ) );
data-wp-context without a namespace prefix is scoped to the element's data-wp-interactive namespace. Replacing core/query with query-filter on the wrapper moves core's empty context into the wrong namespace.
Nothing in query-filter's view scripts depends on the wrapper being in the query-filter namespace. The query-filter store's toggleAllTerms, toggleChildren and search actions all read context from the filter/search blocks' own elements, which set data-wp-interactive="query-filter" and their own data-wp-context themselves.
Suggested fix
Only set data-wp-interactive on the wrapper when core has not already set one, and keep setting data-wp-router-region unconditionally:
if ( null === $block_content->get_attribute( 'data-wp-interactive' ) ) {
$block_content->set_attribute( 'data-wp-interactive', 'query-filter' );
}
AI use disclaimer
I encountered this issue on a project and manually traced it to this plugin, but I have not specifically validated in a clean environment outside of my current project. The description and test steps above were claude-generated following our initial identification and tracing of the error to something about this plugin. Filter, search and enhanced pagination navigation should be re-checked after the change, since all three share the same router region.
- Lenguaje dominante
- PHP
- Estrellas
- 124
- Forks
- 33
- Merge medio
- 20 h 58 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
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 humanmade/query-filter
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
humanmade/query-filter#67 ·
-
Selected Filters BlockAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
humanmade/query-filter#66 ·
-
Reset blockAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
humanmade/query-filter#65 ·
-
Order blockAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
humanmade/query-filter#64 ·
-
bug
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
humanmade/query-filter#62 ·
Todos los issues de humanmade/query-filter
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
0. Needs triage bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nextcloud/fulltextsearch#1061 ·
Los mantenedores suelen responder en 1 día
-
[Resource]: Claude KitAbiertoresource-submission validation-passed
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
hesreallyhim/awesome-claude-code#3375 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Settings → Proxy: an empty Port field saves as 0 and then shows "0" instead of the placeholderAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Codeinwp/feedzy-rss-feeds#1363 ·
Los mantenedores suelen responder en 1 día
-
C-CDA export: allergy concern act code, policy activity translation and empty id/@extension fail conformancePosiblemente ocupada @doctorman la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día