WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#37113 closed defect (bug) (fixed)

unload_textdomain() not working for text domains that are loaded just in time

Reported by: swissspidy Owned by: ocean90
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.6
Component: General Keywords: has-unit-tests has-patch
Focuses: Cc:
PR Number:

Description (last modified by swissspidy)

#34114 removed the requirement to call load_plugin_textdomain() or load_theme_textdomain() by checking the languages directory for available translation files.

However, as pointed out by @opajaap in the support forums, unload_textdomain() does not work anymore because of that. _load_textdomain_just_in_time() would simply load the text domain again and again.

We need some sorts of global array to keep track of unloaded text domains, which _load_textdomain_just_in_time() would ignore. Unloaded text domains would need to be loaded explicitly if one wants to use it again — like before.

Will whip up a patch shortly.

Attachments (4)

37113.diff (3.0 KB) - added by swissspidy 3 years ago.
37113.2.diff (5.2 KB) - added by swissspidy 3 years ago.
Allow manual reloading of text domains
37113.3.diff (5.1 KB) - added by ocean90 3 years ago.
37113.4.diff (5.8 KB) - added by swissspidy 3 years ago.
Reset $l10n_unloaded in tests set up

Download all attachments as: .zip

Change History (10)

#1 @swissspidy
3 years ago

  • Owner set to swissspidy
  • Status changed from new to assigned

#2 @swissspidy
3 years ago

  • Description modified (diff)

@swissspidy
3 years ago

#3 @swissspidy
3 years ago

  • Keywords has-unit-tests has-patch added; needs-patch needs-unit-tests removed

#4 @swissspidy
3 years ago

  • Owner changed from swissspidy to ocean90
  • Status changed from assigned to reviewing

@swissspidy
3 years ago

Allow manual reloading of text domains

#5 @swissspidy
3 years ago

37113.2.diff extends load_textdomain() to clear unloaded domains from the $l10n_unloaded array so they can be manually loaded again.

@ocean90
3 years ago

@swissspidy
3 years ago

Reset $l10n_unloaded in tests set up

#6 @swissspidy
3 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37855:

I18N: Enable unloading of text domains that have been loaded just in time.

[37415] removed the requirement to call load_plugin_textdomain() / load_theme_textdomain(). This caused unload_textdomain() to not work properly anymore in these cases.

With this change, unloaded text domains need to be explicitly loaded manually if you want to use them again.

Props swissspidy, ocean90.
Fixes #37113. See #34114.

Note: See TracTickets for help on using tickets.