From 4527df602fcc7efdf400ab1fecbcad78fa54a870 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 26 Nov 2024 07:55:01 +0000 Subject: [PATCH] Add checks for CLD2Detector ans CLD2Encoding classes --- cld/cld.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cld/cld.php b/cld/cld.php index 5ca4c932..83361e2b 100644 --- a/cld/cld.php +++ b/cld/cld.php @@ -22,6 +22,16 @@ function cld_detect_languages(array &$data) return; } + if (!class_exists('CLD2Detector')) { + Logger::warning('CLD2Detector class does not exist.'); + return; + } + + if (!class_exists('CLD2Encoding')) { + Logger::warning('CLD2Encoding class does not exist.'); + return; + } + $cld2 = new \CLD2Detector(); $cld2->setEncodingHint(CLD2Encoding::UTF8); // optional, hints about text encoding