Translation loading for the riverbank domain is triggered too early (WordPress 6.7+)

Open Beginner friendly
#133 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php

Research direction

Start in the Block_Patterns class: its constructor and the run() method, plus the Core::get_instance() call in functions.php that triggers the early load. Reproduce on WordPress 6.7+ with WP_DEBUG_LOG on and check wp-content/debug.log for the _load_textdomain_just_in_time notice. Done when a request with a riverbank translation file logs no notice.

Written by the indexing model from the issue text.

Description

On WordPress 6.7 and later, every request on a site that has a Riverbank translation logs:

PHP Notice:  Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the riverbank 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. (This message was added in version 6.7.0.)

Cause: functions.php calls Core::get_instance() while the theme loads. The Core constructor creates Block_Patterns, whose constructor calls setup_properties(), which runs __( 'Riverbank Patterns', 'riverbank' ) before after_setup_theme.

Fix: the same as Jaxon 1.0.9 (Codeinwp/jaxon commit c7f8818) and Neve FSE (Codeinwp/neve-fse#170): move $this->setup_properties(); from Block_Patterns::__construct() into run(), which runs on init.

Reproduce:

  1. WordPress 6.7 or later with WP_DEBUG and WP_DEBUG_LOG on, Riverbank 1.0.18 active.
  2. Put any translation file for the theme at wp-content/languages/themes/riverbank-<locale>.mo and use that locale (an empty riverbank-en_US.mo on an English site is enough).
  3. Load any page.

Expect: no notice. Actual: the notice above in wp-content/debug.log on every request.

Found by the WordPress compatibility routine (Codeinwp/qa-compatibility): Riverbank 1.0.12 logs nothing on WordPress 6.6.12 and logs the notice on 6.7; 1.0.18 logs it on 7.0.8, 7.1.5 and 7.2-RC2.

Dominant language
PHP
Stars
2
Forks
0
Avg merge
4h 59m
Merged PRs (30d)
5

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Codeinwp/riverbank

All issues in Codeinwp/riverbank

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.