Error log full of "Invalid/unsupported locale"-notices

Describe the issue or problem

The error log is flooded with notices “InvalidArgumentException: Invalid/unsupported locale “en”, default locale restored in /data/ojs/lib/pkp/classes/i18n/Locale.php:155”. This makes it difficult to monitor important error messages.

Steps I took leading up to the issue
Install at least two languages, make sure the cookie “currentLocale” is set. Switch to frontend/backend that does not support this locale.

What application are you using?
OJS 3.5.0-4

This notice should only be written to the error log if the locale is not installed and/or it should not depend on cookie settings.

Regards,

Carola

I also found it hard to find the actual errors when debugging other issues on the website, because these errors filled up the logs.

For now, I just manually commented out the error_log() call in lib/pkp/classes/i18n/Locale.php:

/\*\*
\* @copy \\Illuminate\\Contracts\\Translation\\Translator::setLocale()
\*/
public function setLocale($locale): void
{
    if (!$this->isLocaleValid($locale) || !$this->isSupported($locale)) {
        if ($locale) {
            //error_log((string) new InvalidArgumentException("Invalid/unsupported locale "{$locale}", default locale restored"));
        }
        $locale = $this->getPrimaryLocale();
}