Skip to content

Fix PHP Notice: Function _load_textdomain_just_in_time was called incorrectly.#203

Merged
dkotter merged 1 commit into10up:developfrom
stormrockwell:feature/fix-textdomain
Jul 10, 2025
Merged

Fix PHP Notice: Function _load_textdomain_just_in_time was called incorrectly.#203
dkotter merged 1 commit into10up:developfrom
stormrockwell:feature/fix-textdomain

Conversation

@stormrockwell
Copy link
Copy Markdown
Contributor

@stormrockwell stormrockwell commented Jun 12, 2025

Description of the Change

There is a PHP Notices due to i18n functions being called early.

I've noticed that most of these labels aren't in use, and others are being translated again later (which doesn't seem ideal). Since they aren't being reused, I've deleted all label config defines and translated them when they are being used.

How to test the Change

Open wp-admin on the latest version of WordPress with WP_DEBUG set to true and your preferred method to look at PHP errors/notices. The notices will be removed with the changes.

Changelog Entry

Fixed - i18n functions being called too early, causing PHP Notices.

Credits

Props @stormrockwell

Checklist:

@jeffpaul jeffpaul added this to the 1.4.0 milestone Jun 12, 2025
@jeffpaul jeffpaul requested review from a team and removed request for jeffpaul June 12, 2025 17:03
@jeffpaul jeffpaul moved this to Code Review in Open Source Practice Jun 12, 2025
Copy link
Copy Markdown
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, though interesting that we had so many labels defined that don't appear to be used anywhere.

One thing worth discussing here is that with this change, these labels can't easily be modified. Right now we use convert_to_blocks_define, which checks to see if a constant already exists and if so, it will use that value. This allows others to define these constants themselves (likely in wp-config.php) to easily modify these labels.

I'd be surprised if anyone is doing that but there may be some that are and that will no longer work after this change. Wondering if we need to try and maintain backwards compatibility on that? cc/ @dsawardekar

@dsawardekar
Copy link
Copy Markdown
Collaborator

@dkotter It's been a while, iirc, This plugin was originally embedded within an existing code base, and all these labels were overridden there. Cleaning them up and removing the unused ones makes sense now. PR looks good to me as well.

@github-project-automation github-project-automation bot moved this from Code Review to QA Testing in Open Source Practice Jul 8, 2025
@dkotter dkotter merged commit e984f72 into 10up:develop Jul 10, 2025
7 of 8 checks passed
@github-project-automation github-project-automation bot moved this from QA Testing to Done in Open Source Practice Jul 10, 2025
@dkotter dkotter modified the milestones: 1.4.0, 1.3.3 Jul 10, 2025
@dkotter dkotter linked an issue Jul 10, 2025 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants