yllen / pdf

GNU Affero General Public License v3.0
14 stars 14 forks source link

Deprecated error with php 8.2 and GLPI 10.0.10 #58

Closed Naosu1 closed 4 months ago

Naosu1 commented 9 months ago

Hello,

Since i updated to 10.0.10, the PDF plugin shows me a "Deprecated" error like

Deprecated: Creation of dynamic property PluginPdfTicket::$pdf is deprecated in D:\Programs\wamp64\www\glpi\plugins\pdf\inc\common.class.php on line 374 TCPDF ERROR: Some data has already been output, can't send PDF file

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in D:\Programs\wamp64\www\glpi\plugins\pdf\inc\preference.class.php on line 93

I did a clean reinstallation of the plugin and it's worse... plugin not even installed or activated and I have PHP errors everywhere. Once installed and activated, the dashboard is also filled with php errors. I carried out a 2nd installation by installing composer in the plugin folder, no more visible errors, but we return to the basic situation whenever i try to export ticket to pdf...

I opened a query on the GLPI community forum and it turns out that it's because my GLPI is running on PHP 8.2 which was pointed out as the cause. In 7.4 everything works, but unfortunately our system admin does not want us to downgrade to 7.4

Is it possible to modify any file(s) to make the plugin compatible with php 8.2?

Thanks in advance

Best regards

rginus commented 8 months ago

I solved this by adding #[AllowDynamicProperties] just before the line abstract class PluginPdfCommon extends CommonGLPI { in the file .\marketplace\pdf\inc\common.class.php

Naosu1 commented 8 months ago

I made the change and now I do not have longer the deprecated errors, however I still have the error

TCPDF ERROR: Some data has already been output, can't send PDF file

Naosu1 commented 8 months ago

i solved this from add solution from https://github.com/yllen/pdf/issues/41#issuecomment-1856268929

rginus commented 8 months ago

Hi, I got your second Deprecated message when I want to create a PDF of a ticket. Your solution doesn't work for me. I changed line 93 of plugins\pdf\inc\preference.class.php as follows to solve this:

From: $formid="plugin_pdf_${type}_".mt_rand(); To: $formid="plugin_pdf_{$type}_".mt_rand();

Naosu1 commented 8 months ago

Actually I didn't see this above the page. image

with online patch 93 I no longer have the problem either, thank you

yllen commented 4 months ago

Already corrected in November: https://github.com/yllen/pdf/commit/bddedfb7e576a5ce8959706179f1b051cf9e6711 Duplicate https://github.com/yllen/pdf/issues/54