Numeric product slugs abort artifact composition (hash() given int)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 79/100
Hướng nghiên cứu
Bắt đầu tại ArtifactCompiler::runtimeDeclarationsFromFallbacks() quanh dòng 1533 và lần theo cách slug sản phẩm trở thành khóa trong $products. Kiểm tra các map khác trong hàm này được khóa theo slug hoặc route xem có cùng hiện tượng ép kiểu khóa thành số nguyên hay không, sau đó thêm fixture hồi quy với slug sản phẩm dạng số như 249. Công việc được xem là hoàn tất khi quá trình composition thành công và ID thực thể sản phẩm băm chuỗi slug.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Artifact composition aborts with TypeError: hash(): Argument #2 ($data) must be of type string, int given when a captured product has a numeric slug.
ArtifactCompiler::runtimeDeclarationsFromFallbacks() keys $products by product slug. PHP stores a numeric-string key such as "199" as an int, so the later loop
foreach ($products as $productSlug => &$product) {
$product['id'] = 'product:' . hash('sha256', $productSlug);
passes an int to hash() under strict_types=1 and the whole import fails in the compose phase (static_site_importer_direct_artifact_phase_failed). Same class as #3098.
Evidence
Square Online store whose product URLs end in numeric IDs (/product/<name>/249, /263, /264). Every one of 46 pages compiled; compose failed:
ArtifactCompiler.php:1533
#0 ArtifactCompiler.php(1533): hash('sha256', 199)
#1 ArtifactCompiler.php(478): ArtifactCompiler->runtimeDeclarationsFromFallbacks(Array, Array, 'website/index.h...', ...)
#2 StagedTransport.php(522): ArtifactCompiler->finalizeArtifact(...)
#3 StagedTransport.php(423): ArtifactCompiler->composeWithCssRuleTrees(...)
Reproduced with Static Site Importer 1.33.392 / php-transformer 0.45.264; the same lines are on trunk (v0.45.270). This matches a production import that failed during building on the same source.
Expected
A product whose slug is all digits composes like any other product; its entity id is product: + sha256 of the slug string.
Suggested fix
Treat slug keys as strings where they are read back (e.g. hash('sha256', (string) $productSlug)), and audit the other slug/route-keyed maps in the same function for the same int-key coercion. Regression fixture: a product grid fallback with one product whose slug is numeric (e.g. 249); compose succeeds and the product entity id is the hash of "249".
Filed by Claude (Anthropic) via Claude Code during the Data Liberation import loop; the stack trace was captured from a local reproduction.
- Ngôn ngữ chính
- PHP
- Star
- 25
- Fork
- 3
- Merge trung bình
- 2 giờ 20 phút
- Pull request đã merge (30 ngày)
- 934
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Automattic/blocks-engine
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/blocks-engine#4943 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/blocks-engine#4942 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Automattic/blocks-engine#4921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Automattic/blocks-engine#775 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
Automattic/blocks-engine#5170 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Automattic/blocks-engine
Issue tương tự
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Перевод устарел
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Plugin directory: block icon SVG loses elements other than <path> in the Blocks sectionCó thể đã có người làm @obenland đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
WordPress/wordpress.org#1209 ·
Maintainer thường phản hồi trong vòng 1 ngày