Dinamiko / dk-pdf

WordPress to PDF made easy
https://wordpress.org/plugins/dk-pdf
26 stars 23 forks source link

Returns fatal error with PHP 8.0, user provided fix #93

Open djw0510 opened 2 years ago

djw0510 commented 2 years ago

Fatal error: Array and string offset access syntax with curly braces is no longer supported in /wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 2209

User @lusant has provided a fix at https://wordpress.org/support/topic/breaks-with-php-8-0/

Is there any way we can get this incorporated into a new version? I think there's a lot of people who depend on this plugin via dependency management tools who would benefit from the update.

KZeni commented 2 years ago

Here's a link to @lusant's patched version just in case they delete the post from the WP.org support forum topic (they don't like it when people link to files in the forum as a security precaution): https://drive.google.com/file/d/1YZA2hipCa11S7uZfhoZu8IlbfKL1cZKA/view?usp=sharing (mirror: https://f.kzeni.com/dk-pdf-1.9.6-patched.zip) *I can confirm the fatal error goes away with this.

Looks like there's also https://github.com/wwwxkz/dk-pdf which forked this to patch things to add PHP 8.x support as well.

So it seems there are 2 options now, and we just need the official plugin to adopt one & get the WP.org plugin listing to offer it.

wwwxkz commented 2 years ago

I was going to send a PR but I made changes in the vendor mpdf (not dk-pdf itself), and it does not exist here in github. I could open an PR adding all vendors or maybe try to make it work with the latest mpdf version, but as it is working in my live and serves my purpose I do not think I will have time to do so.

wwwxkz commented 2 years ago

I made the PR https://github.com/Dinamiko/dk-pdf/pull/94 and I kept my old solution updating the mpdf 7.0 https://github.com/wwwxkz/dk-pdf as I created another repo for this PR in https://github.com/wwwxkz/dk-pdf-fork. As said in the PR, although updating mpdf to 8.10 in composer.json works, it requires different PHP versions from dk-pdf, using 7.4 > worked fine for me, but I did not test for all of them.

Coss0475 commented 9 months ago

I have WP 6.3.2 and PHP 8.2.11. I get this error in debug: Fatal error: Uncaught Mpdf\MpdfException: Data has already been sent to output, unable to output PDF file in /opt/bitnami/wordpress/wp-content/plugins/dk-pdf-main-with-fork/vendor/mpdf/mpdf/src/Mpdf.php:9323 Stack trace: #0 /opt/bitnami/wordpress/wp-content/plugins/dk-pdf-main-with-fork/includes/dkpdf-functions.php(216): Mpdf\Mpdf->Output() #1 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(310): dkpdf_output_pdf() #2 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters() #3 /opt/bitnami/wordpress/wp-includes/plugin.php(565): WP_Hook->do_action() #4 /opt/bitnami/wordpress/wp-includes/class-wp.php(796): do_action_ref_array() #5 /opt/bitnami/wordpress/wp-includes/functions.php(1335): WP->main() #6 /opt/bitnami/wordpress/wp-blog-header.php(16): wp() #7 /opt/bitnami/wordpress/index.php(17): require('...') #8 {main} thrown in /opt/bitnami/wordpress/wp-content/plugins/dk-pdf-main-with-fork/vendor/mpdf/mpdf/src/Mpdf.php on line 9323 Is this related ? How to get the fixed version for PHP 8? Thank you