openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit ff3a12f4b3ffd0ba8bee7cb15842102bb9df1cc1
parent dcdb22a2e7a114c0ad5bb4e32720176eabfa777e
Author: Jan Dankert <develop@jandankert.de>
Date:   Tue,  9 Nov 2021 01:21:55 +0100

Fix: iconv is broken on alpine 3.

Diffstat:
Mmodules/cms/model/BaseObject.class.php | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/cms/model/BaseObject.class.php b/modules/cms/model/BaseObject.class.php @@ -509,9 +509,13 @@ SQL $slug = str_replace(array_keys($replacements), array_values($replacements), $slug); // 2nd try is to use iconv with the current locale. - Language::setLocale( Configuration::subset('language')->get('language_code','en' ) ); - $slug = iconv('utf-8', 'ascii//TRANSLIT', $slug); - + if ( function_exists('iconv') ) { + Language::setLocale(Configuration::subset('language')->get('language_code', 'en')); + // iconv is buggy on alpine 3 and does not support TRANSLIT. So we have to catch the error here. + $converted = @iconv('utf-8', 'ascii//TRANSLIT', $slug); + if ( $converted !== false ) + $slug = $converted; + } // now replace every unpleasant char with a hyphen. $slug = preg_replace('/[^A-Za-z0-9-]+/', '-', $slug);