Date: Mon, 30 Sep 2024 14:26:52 -0500 From: Marius Schamschula <lists@schamschula.com> To: freebsd-questions@freebsd.org Cc: Adrian Gschwend <ml-ktk@netlabs.org> Subject: Re: Issue with MediaWiki Installation: IntlException and Locale Problems in Apache Message-ID: <E6E4D750-B4AD-4448-8A31-ADDD2D89353E@schamschula.com> In-Reply-To: <db002b72-0efa-4f4d-bb53-a28ddde77ad2@netlabs.org> References: <db002b72-0efa-4f4d-bb53-a28ddde77ad2@netlabs.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_D957159D-2CBA-48B3-BCB9-F1A380717B69 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 30, 2024, at 1:39=E2=80=AFPM, Adrian Gschwend = <ml-ktk@netlabs.org> wrote: >=20 > Hi group, >=20 > I'm trying to install MediaWiki on FreeBSD with Apache and PHP 8.1 via = mod_php, but I keep running into an issue related to the `Intl` = extension and locale settings. During the MediaWiki installation = process, I get the following error: >=20 > ``` > IntlException: Constructor failed > ``` >=20 > There are no errors in the Apache log, and I have doublechecked that = the `Intl` extension is enabled and working in CLI PHP. When I run the = same code via Apache, it throws an exception. >=20 > I created a minimal PHP test case to see if I could reproduce the = error outside of MediaWiki. Here's the test script: >=20 > ``` > <?php >=20 > // Set the locale to test > $locale =3D 'en_US.UTF-8'; >=20 > // Check if Intl extension is loaded > if (!extension_loaded('intl')) { > die("Intl extension is not loaded!\n"); > } >=20 > // Display the current locale settings > echo "Current locale: " . setlocale(LC_ALL, 0) . "\n"; >=20 > // Test the Intl NumberFormatter > try { > $formatter =3D new NumberFormatter($locale, = NumberFormatter::DECIMAL); > echo "Number formatting test: " . $formatter->format(12345.67) . = "\n"; > } catch (Exception $e) { > echo "IntlException: " . $e->getMessage() . "\n"; > } > ?> >=20 > ``` >=20 > Results: >=20 > - Command Line PHP: >=20 > ``` > Current locale: C/C.UTF-8/C/C/C/C > Number formatting test: 12,345.67 > ``` >=20 > - Apache (via browser): >=20 > ``` > Current locale: C/C.UTF-8/C/C/C/C > IntlException: Constructor failed > ``` >=20 > So the same script works on the same jail on cli but not in Apache = with mod_php. >=20 > What I've Tried >=20 > - I have set `LANG` and `LC_ALL` to `en_US.UTF-8` in both the Apache = environment and PHP=E2=80=99s `php.ini`. > - I verified that the `Intl` extension is loaded in both CLI and = Apache environments. > - `phpinfo()` reports the correct locale in Apache (`en_US.UTF-8`), = but the error persists. >=20 > I'm really running out of ideas here, I run MediaWiki for years and = while it's a new jail to upgrade my env, this is not something I've seen = before. >=20 > Note that I tried the same with PHP 8.2, same error. >=20 > Any suggestions on how to resolve this would be greatly appreciated. >=20 > thanks & regards >=20 > Adrian >=20 I have been running Mediawiki on FreeBSD for about ten years. I=E2=80=99ve= never seen this issue. How did you install apache, php and Mediawiki? Which version of = Mediawiki? Did you use pkg for all of them? If so, all needed parts of php should = be there and working. Have you done anything unusual to php.ini? I used to use apache and php from ports but have always installed = Mediwiki from source. Hence, I=E2=80=99ve had to insure that all the = needed php extensions are installed. I=E2=80=99ve since switched from apache to nginx, as there was an issue = with apache that took a long time to resolve. Marius -- Marius Schamschula --Apple-Mail=_D957159D-2CBA-48B3-BCB9-F1A380717B69 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: = after-white-space;"><div><div><blockquote type=3D"cite"><div>On Sep 30, = 2024, at 1:39=E2=80=AFPM, Adrian Gschwend <ml-ktk@netlabs.org> = wrote:</div><br class=3D"Apple-interchange-newline"><div><div>Hi = group,<br><br>I'm trying to install MediaWiki on FreeBSD with Apache and = PHP 8.1 via mod_php, but I keep running into an issue related to the = `Intl` extension and locale settings. During the MediaWiki installation = process, I get the following error:<br><br>```<br>IntlException: = Constructor failed<br>```<br><br>There are no errors in the Apache log, = and I have doublechecked that the `Intl` extension is enabled and = working in CLI PHP. When I run the same code via Apache, it throws an = exception.<br><br>I created a minimal PHP test case to see if I could = reproduce the error outside of MediaWiki. Here's the test = script:<br><br>```<br><?php<br><br>// Set the locale to = test<br>$locale =3D 'en_US.UTF-8';<br><br>// Check if Intl extension is = loaded<br>if (!extension_loaded('intl')) {<br> = die("Intl extension is not loaded!\n");<br>}<br><br>// = Display the current locale settings<br>echo "Current locale: " . = setlocale(LC_ALL, 0) . "\n";<br><br>// Test the Intl = NumberFormatter<br>try {<br> $formatter =3D new = NumberFormatter($locale, NumberFormatter::DECIMAL);<br> = echo "Number formatting test: " . = $formatter->format(12345.67) . "\n";<br>} catch (Exception $e) {<br> = echo "IntlException: " . $e->getMessage() . = "\n";<br>}<br>?><br><br>```<br><br>Results:<br><br>- Command Line = PHP:<br><br> ```<br> Current locale: C/C.UTF-8/C/C/C/C<br> = Number formatting test: 12,345.67<br> ```<br><br>- Apache = (via browser):<br><br> ```<br> Current locale: = C/C.UTF-8/C/C/C/C<br> IntlException: Constructor failed<br> = ```<br><br>So the same script works on the same jail on cli but = not in Apache with mod_php.<br><br>What I've Tried<br><br>- I have set = `LANG` and `LC_ALL` to `en_US.UTF-8` in both the Apache environment and = PHP=E2=80=99s `php.ini`.<br>- I verified that the `Intl` extension is = loaded in both CLI and Apache environments.<br>- `phpinfo()` reports the = correct locale in Apache (`en_US.UTF-8`), but the error = persists.<br><br>I'm really running out of ideas here, I run MediaWiki = for years and while it's a new jail to upgrade my env, this is not = something I've seen before.<br><br>Note that I tried the same with PHP = 8.2, same error.<br><br>Any suggestions on how to resolve this would be = greatly appreciated.<br><br>thanks & = regards<br><br>Adrian<br><br></div></div></blockquote></div><br></div><div= >I have been running Mediawiki on FreeBSD for about ten years. I=E2=80=99v= e never seen this issue.</div><div><br></div><div><span = style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">How did you = install apache, php and Mediawiki? Which version of = Mediawiki?</span><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, = 0, 0);"><br></div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, = 0, 0);">Did you use pkg for all of them? If so, all needed parts of php = should be there and working. Have you done anything unusual to = php.ini?</div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, = 0);"><br></div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, = 0);">I used to use apache and php from ports but have always installed = Mediwiki from source. Hence, I=E2=80=99ve had to insure that all the = needed php extensions are installed.</div><div style=3D"caret-color: = rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></div><div style=3D"caret-color: = rgb(0, 0, 0); color: rgb(0, 0, 0);">I=E2=80=99ve since switched from = apache to nginx, as there was an issue with apache that took a long time = to resolve.</div></div><br><div> <div style=3D"color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 12px; font-style: normal; font-variant-caps: normal; font-weight: = normal; letter-spacing: normal; orphans: auto; text-align: start; = text-indent: 0px; text-transform: none; white-space: normal; widows: = auto; word-spacing: 0px; -webkit-text-size-adjust: auto; = -webkit-text-stroke-width: 0px;">Marius</div><div style=3D"color: rgb(0, = 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; = font-variant-caps: normal; font-weight: normal; letter-spacing: normal; = orphans: auto; text-align: start; text-indent: 0px; text-transform: = none; white-space: normal; widows: auto; word-spacing: 0px; = -webkit-text-size-adjust: auto; -webkit-text-stroke-width: = 0px;">--</div><div style=3D"color: rgb(0, 0, 0); font-family: Helvetica; = font-size: 12px; font-style: normal; font-variant-caps: normal; = font-weight: normal; letter-spacing: normal; orphans: auto; text-align: = start; text-indent: 0px; text-transform: none; white-space: normal; = widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; = -webkit-text-stroke-width: 0px;">Marius Schamschula</div><div = style=3D"color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; = font-style: normal; font-variant-caps: normal; font-weight: normal; = letter-spacing: normal; orphans: auto; text-align: start; text-indent: = 0px; text-transform: none; white-space: normal; widows: auto; = word-spacing: 0px; -webkit-text-size-adjust: auto; = -webkit-text-stroke-width: 0px;"><br></div><br = class=3D"Apple-interchange-newline"> </div> <br></body></html>= --Apple-Mail=_D957159D-2CBA-48B3-BCB9-F1A380717B69--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E6E4D750-B4AD-4448-8A31-ADDD2D89353E>