sourceopt
sourceopt copied to clipboard
Fatal Error: in file /html/typo3/typo3conf/ext/sourceopt/Classes/Service/CleanHtmlService.php, line 331:
In only ONE project I get the following error in all pages. I do not know why. There must be something in the source-code that creates that error. See the screenshots I made:
and
please provide the output of var_dump($html) @ [326] & [328]
Hey @xerc ,
if the "return $html" do not result in an error, $html will be a valid string. But the return type of the preg_replace is null. That means there is an internal error in the replacement?!
@kurtkk Do you have more details or logs?
Regards, Tim
@kurtkk Please also add EXT:sourceopt version and TYPO3 version.
Sorry, I forgot that: TYPO3 13.4.15, PHP 8.3 FPM (8.3.22) Sourceopt: 5.2.8
I made a copy of the project "forgeinrichtenundwohnen.de" for further development. In this copy, with the identical DB, no error is coming up with Sourceopt: 5.2.8!?
please provide the output of
var_dump($html)@ [326] & [328]
I did it but the result is too large. the dump is within a loop!?
dont think /u is needed @ https://github.com/lochmueller/sourceopt/commit/40c930e267a4dd0f10c7cd0828e0dabc12b75ca9#diff-3cb2417b18f7a3a43576dddc2aeed52f0d925666c81014d687fa7a90aa88824eR345 || https://github.com/lochmueller/sourceopt/blame/main/Classes/Service/CleanHtmlService.php#L328
I looked into the source code of the life project (with the modified Sourceopt) and into the DEV-Copy of that project. A screenshot will show that the difference begins in line 270:
I made it this way:
/**
* Remove ALL line breaks and multiple white space.
*/
protected function killLineBreaks(string $html): string
{
$html = str_replace($this->newline, '', $html);
$qpx = preg_replace('/\s\s+/u', ' ', $html);
if (is_string($qpx)) {
return $qpx;
} else {
return $html;
}
// ? return preg_replace('/\n|\s+(\s)/u', '$1', $html);
}
@kurtkk ; might be defect utf8 char(s) @ $html ..
if (!mb_check_encoding($html, 'UTF-8')) {
+ mb_substitute_character(0xFFFD);
+ $html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');
+ return str_replace(mb_chr(0xFFFD, 'UTF-8'), '!!', $html);
}