php-tcpdf installs outdated code which breaks with " Deprecated: The each() function is deprecated." on PHP version 7.2.7-0ubuntu0.18.04.2

Bug #1781000 reported by Carl B.
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tcpdf (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I just installed Ubuntu 18.04 LTS Release: 18.04 and the TCPDF packaged with it doesn't work properly with the PHP 7.2.7 which came with the same Ubuntu release:

# apt install php-tcpdf
php-tcpdf is already the newest version (6.2.13+dfsg-1ubuntu1).

# php -v
PHP 7.2.7-0ubuntu0.18.04.2 (cli) (built: Jul 4 2018 16:55:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.7-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies

gives me this when I try to download a PDF from a website hosted on Ubuntu 18.04 LTS:

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /usr/share/php/tcpdf/tcpdf.php on line 16542
TCPDF ERROR: Some data has already been output, can't send PDF file

TCPDF was generating a valid PDF for download before the "upgrade" from Ubuntu 16 to Ubuntu 18 replaced PHP with a newer version that deprecates a function which is needed. A forum post at http://www.chronoengine.com/forums/posts/t105654/tcpdf-broken-on-php-7-2 suggests that TCPDF version 6.2.17 contains a fix for this issue, but Ubuntu 18.04 LTS is deploying an older version php-tcpdf 6.2.13+dfsg-1ubuntu1, which simply refuses to play nice with the PHP 7.2.7-0ubuntu0.18.04.2 bundled into the same release of Ubuntu.

Tags: bionic
tags: added: bionic
Revision history for this message
Carl B. (carlb) wrote :

According to https://github.com/elibyy/tcpdf-laravel/issues/37 this might be as simple as editing /usr/share/php/tcpdf/tcpdf.pdf to replace every instance of:

   while (list($id, $name) = each($attr_array[1])) {

with:

   foreach($attr_array[1] as $id => $name) {

Nonetheless, it would be preferable that the distribution install up-to-date (or at least compatible) versions of all packages so that users don't need to make these sort of patches.

Changed in tcpdf (Ubuntu):
status: New → Fix Committed
Changed in tcpdf (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.