Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

generate-fixtures: write byte-identical assets once in the default assets/ output

Đã đóng
#469 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #470 của @silverbackdan — đã merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, symfony
Lĩnh vực
tooling

Hướng nghiên cứu

Start with StoredFileExporter, which writes the assets/ files that generate-fixtures emits, and check how it names files today. Read UploadableFileManager::persistFiles() to confirm it only reads the source through a stream. Run GenerateFixturesCommandTest and generate_fixtures_round_trip.feature to see the current output. Done means identical content is written once under a sha256-keyed name, name clashes with different content still get -2, -3, and the round trip regenerates byte for byte.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

generate-fixtures writes one file under assets/ per uploadable field, even when the stored files are byte-identical. On bcio (2.0.0-alpha.22), 76 exported assets (4.8 MB) hold only 20 distinct contents (1.0 MB). One SVG is written 20 times, as phppopacd.svg, phppopacd-2.svg and so on. The stored files really are separate uploads of the same image.

The content-hash store from #462 / #466 already writes each distinct content once, but it is opt-in. The default assets/ output should do the same:

  • StoredFileExporter keys what it has written by the content's sha256. Content it has already written returns the existing name, so every new File(__DIR__ . '/assets/…') for that content points at one file.
  • A name clash with different content still gets -2, -3…
  • The first file in site-map order names the shared asset, so a reload stores the later resources under that slug. Regenerating after the reload gives the same file, so it is still a fixed point.
  • Sharing is safe on load: UploadableFileManager::persistFiles() reads the source through a stream and never moves it.

Proposed tests:

  • GenerateFixturesCommandTest: two resources with identical bytes under different stored names give one asset and two new File() lines naming it. Different bytes under one name still give -2.
  • Round trip (generate_fixtures_round_trip.feature): a site with two identical uploads reloads with both files present and regenerates byte for byte.

Reported by the bcio session. This would save 79% of bcio's assets, and probably a good share of Cymru Kitchens' 275 MB.

Ngôn ngữ chính
PHP
Star
32
Fork
8
Merge trung bình
1 giờ
Pull request đã merge (30 ngày)
186

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của components-web-app/api-components-bundle

Tất cả issue của components-web-app/api-components-bundle

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.