Patterns content-1 and features-2 request missing media 108–110 (404s in the editor)

オープン 初心者向け
#30 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, wordpress
領域
frontend

調査の方向性

inc/patterns/layout/content-1.php(62、74、120 行目の Cover ブロック)と inc/patterns/layout/features-2.php(56、70 行目の Image ブロック)を開き、残っている "id" 属性と、Image ブロック上の wp-image-<id> クラスがあればそれを削除し、Assets_Manager::get_image_url() の URL は保持します。#3 を先に読んで、URL がなぜ再配線されたのかを確認してください。完了とは、Site Editor の Front Page と inserter のプレビューが、Network タブで /wp-json/wp/v2/media/108–110 へのリクエストなしで読み込まれることです。

索引モデルが issue の本文から書いたものです。

説明

bug
Description

Two of the theme's patterns point at images by attachment ID from the site they were made on. On any other site those attachments don't exist, so whenever the editor shows these patterns it asks for them and gets 404 (Not Found) in the browser console. That happens in the Site Editor (the Front Page template uses content-1), in the block inserter's previews, and in the editor.

  • inc/patterns/layout/content-1.php: three Cover blocks with "id":108 (line 62), "id":109 (line 74) and "id":110 (line 120). Their url already comes from Assets_Manager::get_image_url(); only the IDs are left over.
  • inc/patterns/layout/features-2.php: two Image blocks with "id":108 (line 56) and "id":109 (line 70).

The images themselves display, because the URLs point at the theme's own assets/img/ files. But the IDs trigger the failed requests on every site, and on a site that does have attachments 108–110 they would point the blocks at unrelated media from that site's library.

Related: #3, where content-1's images were being wired to Assets_Manager::get_image_url.

Step-by-step reproduction instructions
  1. On any site with Eduacademy 1.0.1 active, open the browser's developer tools (Console and Network tabs).
  2. Go to Appearance → Editor → Templates → Front Page.
  3. Watch the Network tab.

Expected: no failed requests.
Actual: GET /wp-json/wp/v2/media/108, /109 and /110 answer 404, and the console shows three "Failed to load resource" errors. The same happens when inserting the patterns from Patterns → Eduacademy Patterns.

Screenshots, screen recording, code snippet or Help Scout ticket

Fix suggestion: drop the "id" attribute (and the matching wp-image-<id> class on Image blocks, if present) from these five blocks, so they keep only the theme-asset URL.

Found while adding Eduacademy to the WordPress compatibility checks (Codeinwp/qa-compatibility#168). The same happens on every WordPress version tried (7.0.9, 7.1-RC1, 7.1.5).

Environment info

Eduacademy 1.0.1 (built from the v1.0.1 tag), WordPress 7.0.9 / 7.1-RC1 / 7.1.5, PHP 8.3, Chromium.

Is the issue you are reporting a regression

No

主要言語
PHP
スター
0
フォーク
0
平均マージ
22時間 12分
マージ済み PR(30日)
6

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeinwp/eduacademy のほかの issue

Codeinwp/eduacademy の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。