Bug #2844
Missing translation labels break web interface
Status: | CLOSED | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 100% | |
Category: | nethserver-httpd-admin | |||
Target version: | v6.5 | |||
Security class: | Resolution: | |||
Affected version: | v6.5-final | NEEDINFO: | No |
Description
When a translation label is missing, NethGUI framework raises an exception.
If the exception is not handled, the whole web interface is blocked.
This can happen when the value of labels is calculated at run time.
The framework should handle the exception and report a warning in the log.
Extract from log:
Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #0 /usr/share/nethesis/Nethgui/View/View.php(190): Nethgui\View\Translator->translate(Object(NethServer\Module\D ashboard\SystemStatus\Backup), NULL, Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #1 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(99): Nethgui\View\View->translate(NULL, Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #2 /usr/share/nethesis/NethServer/Template/Dashboard/SystemStatus/Backup.php(14): Nethgui\Renderer\{closure}(NUL L) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #3 /usr/share/nethesis/Nethgui/Utility/PhpWrapper.php(125): include('/usr/share/neth...') Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #4 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(129): Nethgui\Utility\PhpWrapper->phpInclude('/usr/ share/neth...', Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #5 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(92): Nethgui\Renderer\TemplateRenderer->renderView( 'NethServer\Temp...', Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #6 /usr/share/nethesis/Nethgui/Widget/Xhtml/Inset.php(54): Nethgui\Renderer\TemplateRenderer->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #7 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(133): Nethgui\Widget\Xhtml\Inset->renderContent() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #8 /usr/share/nethesis/Nethgui/Widget/XhtmlWidget.php(322): Nethgui\Widget\AbstractWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #9 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(124): Nethgui\Widget\XhtmlWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #10 /usr/share/nethesis/NethServer/Template/Dashboard/SystemStatus.php(44): Nethgui\Widget\AbstractWidget->__toS tring() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #11 /usr/share/nethesis/Nethgui/Utility/PhpWrapper.php(125): include('/usr/share/neth...') Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #12 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(129): Nethgui\Utility\PhpWrapper->phpInclude('/usr /share/neth...', Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #13 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(92): Nethgui\Renderer\TemplateRenderer->renderView ('NethServer\Temp...', Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #14 /usr/share/nethesis/Nethgui/Widget/Xhtml/Inset.php(54): Nethgui\Renderer\TemplateRenderer->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #15 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(133): Nethgui\Widget\Xhtml\Inset->renderContent() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #16 /usr/share/nethesis/Nethgui/Widget/XhtmlWidget.php(322): Nethgui\Widget\AbstractWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #17 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(101): Nethgui\Widget\XhtmlWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #18 /usr/share/nethesis/Nethgui/Widget/Xhtml/Tabs.php(63): Nethgui\Widget\AbstractWidget->renderChildren() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #19 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(133): Nethgui\Widget\Xhtml\Tabs->renderContent() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #20 /usr/share/nethesis/Nethgui/Widget/XhtmlWidget.php(322): Nethgui\Widget\AbstractWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #21 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(124): Nethgui\Widget\XhtmlWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #22 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(118): Nethgui\Widget\AbstractWidget->__toString() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #23 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(92): Nethgui\Renderer\TemplateRenderer->renderView (Array, Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #24 /usr/share/nethesis/Nethgui/Widget/Xhtml/Inset.php(54): Nethgui\Renderer\TemplateRenderer->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #25 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(133): Nethgui\Widget\Xhtml\Inset->renderContent() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #26 /usr/share/nethesis/Nethgui/Widget/XhtmlWidget.php(322): Nethgui\Widget\AbstractWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #27 /usr/share/nethesis/Nethgui/Widget/AbstractWidget.php(124): Nethgui\Widget\XhtmlWidget->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #28 /usr/share/nethesis/Nethgui/Framework.php(228): Nethgui\Widget\AbstractWidget->__toString() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #29 [internal function]: Nethgui\{closure}(Object(Nethgui\Renderer\Xhtml), Object(Closure), Object(Nethgui\Utility\HttpResponse)) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #30 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(118): call_user_func_array(Object(Closure), Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #31 /usr/share/nethesis/Nethgui/Renderer/TemplateRenderer.php(92): Nethgui\Renderer\TemplateRenderer->renderView(Object(Closure), Array) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #32 /usr/share/nethesis/Nethgui/Framework.php(578): Nethgui\Renderer\TemplateRenderer->render() Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #33 /usr/share/nethesis/Nethgui/Framework.php(494): Nethgui\Framework->handle(Object(Nethgui\Controller\Request)) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #34 /usr/share/nethesis/nethserver-manager/index.php(87): Nethgui\Framework->dispatch(Object(Nethgui\Controller\Request)) Sep 1 14:25:15 mail httpd-admin: [EXCEPTION] #35 {main}
Related issues
Associated revisions
Translator (translate): always cast given $key argument to String. Refs #2844
Translator (translate). Fixed docblock. Refs #2844
Applied upstream patch
Translator (translate): always cast given $key argument to String. Refs #2844
Fixed TranslatorTest. Refs #2844
- key argument casted to string
- placeholders are always in the form ${...}
History
#1 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from NEW to TRIAGED
- Target version set to v6.5
- % Done changed from 0 to 20
A simple patch which does the job:
--- /usr/share/nethesis/Nethgui/View/Translator.php.ori 2014-09-01 14:52:13.377536227 +0200 +++ /usr/share/nethesis/Nethgui/View/Translator.php 2014-09-01 14:58:27.993170472 +0200 @@ -87,7 +87,8 @@ public function translate(\Nethgui\Module\ModuleInterface $module, $string, $args = array(), $languageCode = NULL) { if ( ! is_string($string)) { - throw new \InvalidArgumentException(sprintf("%s: in translate(); unexpected `%s` type!", get_class($this), gettype($string)), 1322150166); + $this->getLog()->warning(sprintf("%s: in translate(); unexpected `%s` type!", get_class($this), gettype($string))); + return ''; } if ( ! isset($languageCode)) {
If possible, the system should also log the call stack trace.
#2 Updated by Davide Principi almost 7 years ago
- Status changed from TRIAGED to ON_DEV
- Assignee set to Davide Principi
- % Done changed from 20 to 30
#3 Updated by Davide Principi almost 7 years ago
- Status changed from ON_DEV to MODIFIED
- Assignee deleted (
Davide Principi) - % Done changed from 30 to 60
MODIFIED
- Any value is casted to type String.
- No exception is thrown
- Missing translation warnings are sent as before
Test case
- Passing NULL must return the '' empty string
#4 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from MODIFIED to ON_QA
- % Done changed from 60 to 70
- Affected version changed from v6.5 to v6.5-final
nethserver-httpd-admin-1.3.0-3.3git387949c.ns6.noarch.rpm
nethserver-httpd-admin-1.3.0-3.6gitdc45262.ns6.noarch.rpm
See previous comment for test case.
#5 Updated by Giacomo Sanchietti almost 7 years ago
- Assignee set to Giacomo Sanchietti
#6 Updated by Giacomo Sanchietti almost 7 years ago
- Related to Bug #2867: Process::getOutput() is incompatible with previous version added
#7 Updated by Giacomo Sanchietti almost 7 years ago
- Related to Enhancement #2868: Implement ProgressBar widget based on TextLabel added
#8 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from ON_QA to VERIFIED
- Assignee deleted (
Giacomo Sanchietti) - % Done changed from 70 to 90
Both bugs have been fixed.
#9 Updated by Davide Principi almost 7 years ago
- Status changed from VERIFIED to CLOSED
- % Done changed from 90 to 100
In nethserver-updates:
nethserver-httpd-admin-1.3.1-1.ns6.noarch.rpm