alleyinteractive / alleyinteractive/wp-asset-manager
`wp_kses_hair()` in WordPress 7.0 causes PHP Unit failures
- Lenguaje dominante
- PHP
- Estrellas
- 30
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
WordPress 7.0 changed how the `wp_kses_hair()` function parses HTML. It now does so using the HTML API, `WP_HTML_Tag_Processor` class. This has resulted in two unexpected changes in HTML that are causing PHP Unit failures. This is also blocking PRs from merging see #75
Trac Ticket for `wp_kses_hair()`: https://core.trac.wordpress.org/ticket/63724
https://github.com/WordPress/wordpress-develop/pull/9248 ("HTML API: Refactor wp_kses_hair() for spec-compliance")
Regressions:
- HTML tag attributes being changed to be all lowercase and in the case of SVG tags, those attributes are case-sensitive like `viewBox` or `attributeName` for example. This is the cause of most PHP Unit test failures. NOTE: SVGs appear to still work in browsers despite these attributes being case sensitive.
- quote characters are being entity-encoded.
### Example Test Failures when running PHP Unit on WP 7.0
```
1) Alley\WP\Asset_Manager\Tests\SpriteTest::test_add_assets
Should properly escape the sprite sheet.
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'...viewBox="0 0 0 0" width="0">...'
+'...viewbox="0 0 0 0" width="0">...'
```
Snippet above shows the loss of camel-cased tag attributes.
```
2) Alley\WP\Asset_Manager\Tests\StylesTest::test_print_asset
Should load CSS via tag that, on load, will switch to the media attribute from `print` to `all`
Failed asserting that two strings are equal.
-'...this.media='all'" />
Guía de contribución
Línea de trabajo
Run the PHP Unit suite with WordPress 7.0 and compare the failures with WordPress 6.8. Start in src/class-svg-sprite.php and src/class-styles.php, then inspect the other listed wp_kses() and wp_kses_post() call sites. Done means the affected tests pass without losing SVG attribute casing or entity-encoding quote characters.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- php
- Área
- frontend, testing
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100