Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html2Pdf@_drawRectangle throws "Trying to access array offset on value of type null error" on php7.4 #530

Open
eric-reichenbach opened this issue Jan 3, 2020 · 2 comments

Comments

@eric-reichenbach
Copy link

@eric-reichenbach eric-reichenbach commented Jan 3, 2020

Specs

  • Version: v5.2.1
  • PHP: 7.4.1

Bug

In php 7.4 you can't access array indexes on non array

https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.core.non-array-access

How to repro

if the radiuses in the Html2Pdf@_drawRectangle are not set, it will crash.

I've forked the project and I fixed the issue. I'll submit a pull request ASAP

@eric-reichenbach

This comment has been minimized.

Copy link
Author

@eric-reichenbach eric-reichenbach commented Jan 3, 2020

I've submitted a pull request for the bug #531

@hai05

This comment has been minimized.

Copy link

@hai05 hai05 commented Jan 3, 2020

To fix it, change line 1756 to 1767 in the file spipu\html2pdf\src\Html2Pdf.php

if ($inTL == NULL || $inTL[0]<=0 || $inTL[1]<=0) {
$inTL = NULL;
}
if ($inTR == NULL || $inTR[0]<=0 || $inTR[1]<=0) {
$inTR = null;
}
if ($inBR == NULL || $inBR[0]<=0 || $inBR[1]<=0) {
$inBR = null;
}
if ($inBL == NULL || $inBL[0]<=0 || $inBL[1]<=0) {
$inBL = null;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.