Restore Mpdf Workaround for Php8.6

Misread dates - fix not available yet.
This commit is contained in:
oleibman
2026-08-14 14:20:07 -07:00
parent 6276cd2c4b
commit e07a620870
+28
View File
@@ -40,6 +40,13 @@ class Mpdf extends Pdf
// Create PDF
$config = ['tempDir' => $this->tempDir . '/mpdf'];
$restoreHandler = false;
if (PHP_VERSION_ID >= self::$temporaryVersionCheck) {
// @codeCoverageIgnoreStart
set_error_handler(self::specialErrorHandler(...));
$restoreHandler = true;
// @codeCoverageIgnoreEnd
}
$pdf = $this->createExternalWriterInstance($config);
$ortmp = $orientation;
$pdf->_setPageSize($paperSize, $ortmp);
@@ -83,9 +90,30 @@ class Mpdf extends Pdf
$str = $pdf->Output('', 'S');
fwrite($fileHandle, $str);
if ($restoreHandler) {
restore_error_handler(); // @codeCoverageIgnore
}
parent::restoreStateAfterSave();
}
protected static int $temporaryVersionCheck = 80600;
/**
* Temporary handler for Php8.6 mb_regex_encoding deprecation.
*
* @codeCoverageIgnore
*/
public function specialErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
{
if ($errno === E_DEPRECATED) {
if (preg_match('/Function mb_\w+[(][)] is deprecated since 8[.]6/', $errstr) === 1) {
return true;
}
}
return false; // continue error handling
}
/**
* Convert inches to mm.
*/