Gettext domain was not properly restored after invoking hook provided by extension.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Tue, 3 Jan 2012 15:12:49 +0000 (16:12 +0100)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Tue, 3 Jan 2012 15:12:49 +0000 (16:12 +0100)
includes/hooks.inc
includes/lang/gettext.php

index fedbc4c22cf8d4b59eefd209c1d2ffe605aff432..90bf2071b231bd2f2b059ccd717e38f939624f0e 100644 (file)
@@ -261,8 +261,8 @@ function hook_invoke_all($method, &$data, $opts=null)
                        } else if (isset($result)) {
                                $return[] = $result;
                                }
+                       set_ext_domain();
                }
-       set_ext_domain();
        return $return;
 }
 /*
@@ -280,9 +280,9 @@ function hook_invoke_first($method, &$data, $opts=null)
                        $result = $hook->$method($data, $opts);
                        if (isset($result))
                                break;
+                       set_ext_domain();
                }
        }
-       set_ext_domain();
        return $result;
 }
 /*
@@ -302,9 +302,9 @@ function hook_invoke_last($method, &$data, $opts=null)
                        $result = $hook->$method($data, $opts);
                        if (isset($result))
                                break;
+                       set_ext_domain();
                }
        }
-       set_ext_domain();
        return $result;
 }
 //------------------------------------------------------------------------------------------
index 178ec3c8ab345783eac74eeacde901e7240699ee..a8ddcfc90ce9307121482dcb469600e91b7504dd 100644 (file)
@@ -550,6 +550,17 @@ class gettext_php_support_compiler
 */
 function set_ext_domain($path='') {
        global $path_to_root;
+       static $domain_stack = array('');
+
+       if ($path)      // save path on domain stack
+               array_unshift($domain_stack,  $path);
+       else
+       {
+               array_shift($domain_stack);
+               $path = $domain_stack[0];
+       }
+       $lang_path = $path_to_root . ($path ? '/' : '') .$path.'/lang';
+
 
        $lang_path = $path_to_root . ($path ? '/' : '') .$path.'/lang';
        // ignore change when extension does not provide translation structure