"Translation loading for the fork domain was triggered too early" notice on every request (WordPress 6.7+)
まだ誰も着手していません。
評価
調査の方向性
問題は inc/Block_Patterns.php にあります。コンストラクターが setup_properties() を直接呼び出し、そのメソッドが __( 'Fork Patterns', 'fork' ) を init より前に呼んでいます。そこから始め、WP_DEBUG_LOG を有効にし、空の wp-content/languages/themes/fork-en_US.mo で再現してください。fork ドメインの通知が debug.log に表示されなくなり、コンストラクターが run() を init にフックし、fork_block_patterns_categories と fork_block_patterns フィルターが引き続き発火してパターンを登録するようになれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What's wrong
On WordPress 6.7 and later, every page load (front end, admin, REST, WP-CLI) writes this notice to the debug log when WP_DEBUG is on:
PHP Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the fork domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later.
On a test site the log grew by about 500 lines per test session from this notice alone. On a translated site, WordPress also loads Fork's translations earlier than it allows.
Cause
inc/Block_Patterns.php: the constructor calls setup_properties() straight away, and setup_properties() calls __( 'Fork Patterns', 'fork' ). The constructor runs from Core::__construct() while functions.php loads, which is before init. The code has been like this since 1.0.0; WordPress started reporting it in 6.7.
Steps to reproduce
WordPress only shows this notice when a translation file exists for the domain in the site's language. An English site has none, so the notice never shows there.
- Use a site with
WP_DEBUGandWP_DEBUG_LOGon and Fork active. Either set the site language to one Fork has translations for, or (what our QA site does) create an emptywp-content/languages/themes/fork-en_US.mo. - Load any page.
- Open
wp-content/debug.log.
Expected: no notice for the fork domain.
Actual: one notice per request.
Seen on WordPress 6.7.12, 6.8, 7.1.5 and 7.2-RC2, with Fork 1.0.16.
Suggested fix
Call setup_properties() from the init callback instead of the constructor:
public function __construct() {
add_action( 'init', array( $this, 'run' ) );
}
public function run() {
$this->setup_properties();
$this->register_categories();
$this->register_patterns();
}
The fork_block_patterns_categories and fork_block_patterns filters then run at init, which is later than now. Check that nothing hooks them later than that.
- 主要言語
- PHP
- スター
- 0
- フォーク
- 0
- 平均マージ
- 1時間 2分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeinwp/fork のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
似ている issue
-
Change: check an identifier filter the same way in every tool - the order of somcp_search_ordersオープンconsistency enhancement Orders
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
novalo-dev/Prestashop-MCP-Server#343 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
claude
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
sprain/sprainocchio#45 ·
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信