Easy to reproduce bug with Table with "border-collapse: collapse" and a TD colspan with packTableData = true

Đang mở
#1,855 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
css, php
Lĩnh vực
backend

Hướng nghiên cứu

The failure is the PHP 8 warning "Trying to access array offset on value of type int" at src/Mpdf.php around line 21537, and it only occurs when packTableData is on, border-collapse: collapse is set, and a cell has colspan. Start by reproducing with the HTML and PHP from the issue on PHP 8, then trace how the table packing code indexes cell data for spanned cells. Done means the snippet renders without the warning and the output matches the PHP 7.3 result. The issue has no comments and no maintainer response after about 1,286 days, so confirm the behaviour is still present on the current development branch first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Guidelines
Description of the bug

Hello, I was running this code with PHP 7.3 without problem.

I made a small upgrade to PHP 8.0.28 (and upgraded to mPDF 8.1.4) and now this code fails.
Error thrown: Trying to access array offset on value of type int
Happens at: mpdf\mpdf\src\Mpdf.php:21537
image

Important note:
If I remove: $mpdf->packTableData = true; (works)
If I remove border-collapse: collapse; in <style> tag (works)
If I remove colspan="2" (works)
If 3 are present: fails

mPDF version

8.1.4

PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)

Apache/2.4.54 (Win64) PHP/8.0.26 (also fails on PHP 8.0.28). GD: bundled (2.1.0 compatible), MBSTRING: libmbfl version 1.3.2/ Multibyte regex 6.9.7

Reproducible PHP+CSS+HTML snippet suffering by the error

PHP CODE

$mpdf = new mPDF();
$mpdf->packTableData = true;
$mpdf->WriteHTML($html);

HTML CODE:

<html>
<head>
    <style type="text/css">
        table {
            border-collapse: collapse;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <th>Thead1</th>
            <th>Thead2</th>
            <th>Thead3</th>
        </tr>
            <tr>
                <td colspan="2">Td1</td>
                <td>Td2 and Td3</td>
            </tr>
    </table>
</body>
</html>
Ngôn ngữ chính
PHP
Star
4.7k
Fork
1.1k
Merge trung bình
6 ngày 11 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mpdf/mpdf

Tất cả issue của mpdf/mpdf

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.