Issue with MediaWiki Installation: IntlException and Locale Problems in Apache
Date: Mon, 30 Sep 2024 18:39:25 UTC
Hi group,
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:
```
IntlException: Constructor failed
```
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.
I created a minimal PHP test case to see if I could reproduce the error
outside of MediaWiki. Here's the test script:
```
<?php
// Set the locale to test
$locale = 'en_US.UTF-8';
// Check if Intl extension is loaded
if (!extension_loaded('intl')) {
die("Intl extension is not loaded!\n");
}
// Display the current locale settings
echo "Current locale: " . setlocale(LC_ALL, 0) . "\n";
// Test the Intl NumberFormatter
try {
$formatter = new NumberFormatter($locale, NumberFormatter::DECIMAL);
echo "Number formatting test: " . $formatter->format(12345.67) . "\n";
} catch (Exception $e) {
echo "IntlException: " . $e->getMessage() . "\n";
}
?>
```
Results:
- Command Line PHP:
```
Current locale: C/C.UTF-8/C/C/C/C
Number formatting test: 12,345.67
```
- Apache (via browser):
```
Current locale: C/C.UTF-8/C/C/C/C
IntlException: Constructor failed
```
So the same script works on the same jail on cli but not in Apache with
mod_php.
What I've Tried
- I have set `LANG` and `LC_ALL` to `en_US.UTF-8` in both the Apache
environment and PHP’s `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.
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.
Note that I tried the same with PHP 8.2, same error.
Any suggestions on how to resolve this would be greatly appreciated.
thanks & regards
Adrian