Suitecrm: Move TCPDF to Composer

Created on 20 Nov 2018  路  7Comments  路  Source: salesagility/SuiteCRM

[Original issue was called "create_function deprecated in PHP 7.2", now it's renamed]

Issue

For SuiteCRM 7.10.x, we should support PHP 7.2., but there are a few deprecated functions left in our code, namely create_function, see PHP docs.

Instances of deprecated function in code

./modules/SugarFeed/Dashlets/SugarFeedDashlet/SugarFeedDashlet.php.save:342:   
usort($resortQueue,create_function('$a,$b','return $a["sort_key"]<$b["sort_key"];'));

./modules/SugarFeed/Dashlets/SugarFeedDashlet/SugarFeedDashlet.php.save:486:      
$listview = preg_replace_callback('/\{([^\^ }]+)\.([^\}]+)\}/', create_function(

./include/tcpdf/tcpdf.php:11910:                                                
create_function('$matches', 'global $spacew;

Possible Fix in our code

Turning it into a lambda, something like this random example.

Possible fix in external code

Include a newer version of TCPDF? I assume they fixed it already, but I didn't check.

Steps to Reproduce

I'm afraid I don't know exactly which behaviors this might affect, which isn't helpful in order to test the necessary changes...

Environment

  • SuiteCRM Version used: 7.10.x
  • Environment name and version: PHP 7.2
Important Bug

Most helpful comment

Only places that now have create_function are third party libraries like TCPDF. The create_function was updated in the 7.10.5 & 7.8.11 release within core so that shouldn't cause any PHP 72 issues around that deprecated function.

Though this will remain open due to the third party libraries (not just tcpdf - though that looks fairly easy to resolve as they have in their library).

All 7 comments

Only places that now have create_function are third party libraries like TCPDF. The create_function was updated in the 7.10.5 & 7.8.11 release within core so that shouldn't cause any PHP 72 issues around that deprecated function.

Though this will remain open due to the third party libraries (not just tcpdf - though that looks fairly easy to resolve as they have in their library).

tcpdf should probably be moved to being included via composer, though SuiteCRM is on 4.6.013 released in 2009 while the earliest version available on packagist is 6.0.013: https://packagist.org/packages/tecnickcom/tcpdf

I'm not sure how much it's used in SuiteCRM, or if any of the breaking changes will matter for SuiteCRM, but it's probably worth trying?

You can see the changelog here: https://github.com/tecnickcom/TCPDF/blob/master/CHANGELOG.TXT

Also it looks like an update to the latest 6.0.x may be needed anyway for PHP 7.3 support? https://github.com/tecnickcom/TCPDF/pull/91

@connorshea any chance you could try making a PR for that TCPDF update via composer? At least if you can explore that direction and get a sense of how complex it will be to adapt to the new version.... I'm basically hoping it will turn out to be easy :-)

I finally got around to trying to remove TCPDF from include/ and it doesn't look like it'll be very easy :/

There are quite a few places where it's included.

Can we rename this issue to "Move TCPDF to Composer"?

I was curious so I got the diff of the current version we're on (4.6.013) and the earliest version available on Composer (6.0.013), and this is the difference: https://github.com/tecnickcom/TCPDF/compare/9d1aafa9d47a0929b149b34f087e4e09197ed4b5...6.0.013

442 commits, 397 changed files with 52,332 additions and 152,060 deletions.

And that's without the 200 more commits that have been made to the project since 6.0.013.

馃檲

Thankfully, most of the changed files seem to be in the docs, examples, and fonts. That said, tcpdf.php alone still has 23,507 additions, 15,095 deletions.

Also, we have some customizations in our version of tcpdf.php. We'll have to compare it with the upstream version at 4.6.013.

Do we have any tests for sugarpdf?

Can anybody tell me where exactly we use TCPDF?

I see we have wrapper classes that use it, Sugarpdf, ViewSugarpdf, but where are these instantiated and used? I also see a sugarpdf controller action, how do we call that from the UI?

I'm searching usages in PHPStorm but I get a feeling I must be doing something dumb because I'm not finding it...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArturoBurela picture ArturoBurela  路  3Comments

ajprouty87 picture ajprouty87  路  3Comments

tech-ch1 picture tech-ch1  路  3Comments

sasha2002 picture sasha2002  路  3Comments

pgorod picture pgorod  路  3Comments