Skip to content

Commit e3cac6f

Browse files
authored
Merge pull request #4659 from oleibman/dompdf311
Update to Php8.5-compatible Dompdf
2 parents 3c64527 + 93e715f commit e3cac6f

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PhpSpreadsheet/Writer/Pdf/Dompdf.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,43 +44,15 @@ public function save($filename, int $flags = 0): void
4444
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
4545

4646
// Create PDF
47-
$restoreHandler = false;
48-
if (PHP_VERSION_ID >= self::$temporaryVersionCheck) {
49-
// @codeCoverageIgnoreStart
50-
set_error_handler(self::specialErrorHandler(...));
51-
$restoreHandler = true;
52-
// @codeCoverageIgnoreEnd
53-
}
5447
$pdf = $this->createExternalWriterInstance();
5548
$pdf->setPaper($paperSize, $orientation);
5649

5750
$pdf->loadHtml($this->generateHTMLAll());
5851
$pdf->render();
5952

6053
// Write to file
61-
fwrite($fileHandle, $pdf->output() ?? '');
54+
fwrite($fileHandle, $pdf->output());
6255

63-
if ($restoreHandler) {
64-
restore_error_handler(); // @codeCoverageIgnore
65-
}
6656
parent::restoreStateAfterSave();
6757
}
68-
69-
protected static int $temporaryVersionCheck = 80500;
70-
71-
/**
72-
* Temporary handler for Php8.5 waiting for Dompdf release.
73-
*
74-
* @codeCoverageIgnore
75-
*/
76-
public function specialErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
77-
{
78-
if ($errno === E_DEPRECATED) {
79-
if (preg_match('/canonical|imagedestroy|http_get_last_response_headers|Using null as an array offset/', $errstr) === 1) {
80-
return true;
81-
}
82-
}
83-
84-
return false; // continue error handling
85-
}
8658
}

0 commit comments

Comments
 (0)