xperseguers / t3ext-extractor

TYPO3 Extension extractor
https://extensions.typo3.org/extension/extractor
GNU General Public License v2.0
14 stars 23 forks source link

Exception in scheduler task !File Abstraction Layer: Extract metadata in storage (scheduler)": mb_convert_encoding(): Argument #3 ($from_encoding) must specify at least one encoding #72

Closed sypets closed 7 months ago

sypets commented 7 months ago
503
Oops, an error occurred!
mb_convert_encoding(): Argument #3 ($from_encoding) must specify at least one encoding

Log:

Core: Exception handler (WEB: BE): ValueError, code #0, file 
/var/www/mysite/public/typo3conf/ext/extractor/Classes/Service/Php/PhpService.php, 
line 629: 
mb_convert_encoding(): 
Argument #3 ($from_encoding) must specify at least one encoding

Source

626 if (function_exists('mb_detect_encoding')) {
627            $sourceEncoding = mb_detect_encoding($text ?? '', mb_detect_order(), true);
628 if ($sourceEncoding !== 'UTF-8') {
629                 $text = mb_convert_encoding($text ?? '', 'UTF-8', $sourceEncoding);

https://github.com/xperseguers/t3ext-extractor/blob/dc84b29d77c4a5eb8e82c19c10b4f154b3cbbdd4/Classes/Service/Php/PhpService.php#L629

mb_detect_encoding might return false

Stack trace

Stack trace:
#0 /var/www/www.uni-oldenburg.de/releases/155/htdocs/typo3conf/ext/extractor/Classes/Service/Php/PhpService.php(629): mb_convert_encoding()
#1 /var/www/www.uni-oldenburg.de/releases/155/htdocs/typo3conf/ext/extractor/Classes/Service/Php/PhpService.php(604): Causal\\Extractor\\Service\\Php\\PhpService::safeUtf8Encode()
#2 /var/www/www.uni-oldenburg.de/releases/155/htdocs/typo3conf/ext/extractor/Classes/Service/Php/PhpService.php(487): Causal\\Extractor\\Service\\Php\\PhpService->getMetadata()
#3 /var/www/www.uni-oldenburg.de/releases/155/htdocs/typo3conf/ext/extractor/Classes/Service/Php/PhpService.php(119): Causal\\Extractor\\Service\\Php\\PhpService->extractMetadataFromImage()
#4 /var/www/www.uni-oldenburg.de/releases/155/htdocs/typo3conf/ext/extractor/Classes/Service/AbstractService.php(82): Causal\\Extractor\\Service\\Php\\PhpService->extractMetadataFromLocalFile()
#5 /var/www/www.uni-oldenburg.de/releases/155/htdocs/typo3conf/ext/extractor/Classes/Service/Extraction/PhpMetadataExtraction.php(74): Causal\\Extractor\\Service\\AbstractService->extractMetadata()

versions

xperseguers commented 7 months ago

Would be interesting to know more on how this can happen… Are you uploading a picture containing exotic encoding in metadata? Are you on a system (PHP/Linux) with very limited capabilities?

I wonder under which circumstance this bug may occur…