[wp-trac] [WordPress Trac] #35442: Remove ambiguousness from return value of `is_textdomain_loaded()`
WordPress Trac
noreply at wordpress.org
Wed Jan 13 12:14:28 UTC 2016
#35442: Remove ambiguousness from return value of `is_textdomain_loaded()`
--------------------------+-----------------------------
Reporter: jrf | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The `is_textdomain_loaded()` function - as per the doc block - is supposed
to answer the question whether there are any translations loaded for a
textdomain.
It currently does not do so.
It only checks whether the `$i10n['domain']` key isset, not whether there
are any translations.
As the first time the `get_translations_for_domain()` function is called,
it will '''''also''''' set the text domain, this can lead to false
positives, i.e. `is_textdomain_loaded()` reporting `true` for a textdomain
which hasn't been loaded.
Simple example to reproduce the issue:
{{{#!php
<?php
var_dump( is_textdomain_loaded( 'does-not-exist' ) );
echo __( 'just some string', 'does-not-exist' );
var_dump( is_textdomain_loaded( 'does-not-exist' ) );
}}}
will currently result in:
{{{
false
just some string
true
}}}
With the patch the result will be:
{{{
false
just some string
false
}}}
This patch will improve the results for patch #35439 as well.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35442>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list