Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR (LocalDateFormat.php:27) #11

Closed
Yoda-BZH opened this issue Nov 20, 2023 · 3 comments

Comments

@Yoda-BZH
Copy link

When using v0.20.0 with locale C, in director -> Deployments and director -> Activity Log, I have the error:

Oops, an error occurred!
datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR (LocalDateFormat.php:26)
#0 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/format/src/LocalDateFormat.php(26): IntlDateFormatter->__construct()
#1 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/format/src/LocalDateFormat.php(20): gipfl\Format\LocalDateFormat->formatter()
#2 /usr/share/icingaweb2/modules/director/library/Director/Web/Table/ActivityLogTable.php(111): gipfl\Format\LocalDateFormat->getFullDay()
#3 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(135): Icinga\Module\Director\Web\Table\ActivityLogTable->renderDayIfNew()
#4 /usr/share/icingaweb2/modules/director/library/Director/Web/Table/ActivityLogTable.php(86): gipfl\IcingaWeb2\Table\QueryBasedTable->splitByDay()
#5 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(180): Icinga\Module\Director\Web\Table\ActivityLogTable->renderRow()
#6 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(115): gipfl\IcingaWeb2\Table\QueryBasedTable->fetchRows()
#7 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): gipfl\IcingaWeb2\Table\QueryBasedTable->renderContent()
#8 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#9 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#10 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#11 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#12 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#13 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(420): ipl\Html\HtmlDocument->render()
#14 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Zf1/SimpleViewRenderer.php(65): ipl\Html\HtmlDocument->__toString()
#15 /usr/share/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Zf1/SimpleViewRenderer.php(104): gipfl\IcingaWeb2\Zf1\SimpleViewRenderer->render()
#16 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/HelperBroker.php(277): gipfl\IcingaWeb2\Zf1\SimpleViewRenderer->postDispatch()
#17 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#18 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch()
#19 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch()
#20 /usr/share/php/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch()
#21 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#22 /usr/share/icingaweb2/public/index.php(4): require_once('...')
#23 {main}

The C is my system default. The locale is not forced in PHP (8.2).

The following (temporary dirty) fix works for me:

diff --git a/vendor/gipfl/format/src/LocalDateFormat.php b/vendor/gipfl/format/src/LocalDateFormat.php
index 60a29e4..81959c4 100644
--- a/vendor/gipfl/format/src/LocalDateFormat.php
+++ b/vendor/gipfl/format/src/LocalDateFormat.php
@@ -23,6 +23,7 @@ class LocalDateFormat
     protected function formatter()
     {
         if ($this->formatter === null) {
+               setlocale(LC_ALL, 'en_US.utf8');
             $this->formatter = new IntlDateFormatter(
                 $this->getLocale(),
                 IntlDateFormatter::FULL,

Versions:
PHP: 8.2.12 (debian / sury)
icingaweb2: 2.12.1-1+debian12 (debian package from packages.icinga.com)
director: v1.11.0 (git)
incubator: v0.20.0 (git)

@Yoda-BZH
Copy link
Author

@axelhahn
Copy link

axelhahn commented Dec 6, 2023

@Yoda-BZH Yep this is less dirty than my hack. And the better right placement for this issue.

@nilmerg
Copy link
Member

nilmerg commented Feb 8, 2024

Fixed in Icinga Director v1.11.1, v1.10.3, 1.9.2 and 1.8.2

@nilmerg nilmerg closed this as completed Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants