"Translation loading for the fork domain was triggered too early" notice on every request (WordPress 6.7+)
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
Piste de recherche
Le problème se trouve dans inc/Block_Patterns.php : le constructeur appelle directement setup_properties(), et cette méthode appelle __( 'Fork Patterns', 'fork' ) avant init. Commencez là, et reproduisez avec WP_DEBUG_LOG activé et un wp-content/languages/themes/fork-en_US.mo vide. Terminé lorsque l'avertissement de domaine fork n'apparaît plus dans debug.log, que le constructeur branche run() sur init, et que les filtres fork_block_patterns_categories et fork_block_patterns se déclenchent toujours et enregistrent des patterns.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- PHP
- Étoiles
- 0
- Forks
- 0
- Merge moyen
- 1 h 2 min
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Codeinwp/fork
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
Toutes les issues de Codeinwp/fork
Issues similaires
-
Change: check an identifier filter the same way in every tool - the order of somcp_search_ordersOuverteconsistency enhancement Orders
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
novalo-dev/Prestashop-MCP-Server#343 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
claude
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
sprain/sprainocchio#45 ·
Les mainteneurs répondent en général sous 1 jour
-
sync-en
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
sync-en
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour