Ticket #2329: fix for use of _m() translation functions from outside of plugin directories

This commit is contained in:
Brion Vibber 2010-05-27 14:18:08 -07:00
parent 3e9b356777
commit 697a9948df

View File

@ -205,12 +205,20 @@ function _mdomain($backtrace)
if (DIRECTORY_SEPARATOR !== '/') { if (DIRECTORY_SEPARATOR !== '/') {
$path = strtr($path, DIRECTORY_SEPARATOR, '/'); $path = strtr($path, DIRECTORY_SEPARATOR, '/');
} }
$cut = strpos($path, '/plugins/') + 9; $plug = strpos($path, '/plugins/');
$cut2 = strpos($path, '/', $cut); if ($plug === false) {
if ($cut && $cut2) { // We're not in a plugin; return null for the default domain.
$cached[$path] = substr($path, $cut, $cut2 - $cut);
} else {
return null; return null;
} else {
$cut = $plug + 9;
$cut2 = strpos($path, '/', $cut);
if ($cut2) {
$cached[$path] = substr($path, $cut, $cut2 - $cut);
} else {
// We might be running directly from the plugins dir?
// If so, there's no place to store locale info.
return null;
}
} }
} }
return $cached[$path]; return $cached[$path];