• unfortunately this plugin uses an 11 year old library, which will result in a Call to undefined function get_magic_quotes_runtime() error.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shadi Manna

    (@shadim)

    Can you specify which library you are referring to?

    Thread Starter lilmofo

    (@lilmofo)

    I’d say this is not much of an issue since upgrading to PHP 8.0 is somewhat experimental right now – and I did expect some plugins to fail.

    Nevertheless, you’re using PDFMerger (from December 2009), and more specifically the FPDF class it brings, did fail with PHP8.

    I resolved this by switching from that library to Ghostscript (via command line).

    diff --git a/web/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-soap-label.php b/web/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-soap-label.php
    index 023e41d70..c034751e9 100644
    --- a/web/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-soap-label.php
    +++ b/web/wp-content/plugins/dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-soap-label.php
    @@ -219,23 +219,19 @@ protected function save_data_files( $order_id, $label_data, $export_data ) {
     
     		if ( ! empty( $export_data ) ) {
     			$export_info = $this->save_data_file( 'export', $order_id, $export_data );
    +            
    +			$docs = [];
    +			$docs[] = $label_info['data_path'];
    +			$docs[] = $export_info['data_path'];
     
    -			// Merge PDF files
    -			$loader = PR_DHL_Libraryloader::instance();
    -			$pdfMerger = $loader->get_pdf_merger();
    -
    -			if( $pdfMerger ){
    -
    -				$pdfMerger->addPDF( $label_info['data_path'], 'all' );
    -				$pdfMerger->addPDF( $export_info['data_path'], 'all' );
    -
    -				$filename = 'dhl-label-export-' . $order_id . '.pdf';
    -				$label_url = PR_DHL()->get_dhl_label_folder_url() . $filename;
    -				$label_path = PR_DHL()->get_dhl_label_folder_dir() . $filename;
    -				$pdfMerger->merge( 'file',  $label_path );
    -			} else {
    -				$label_url = $label_info['data_url'];
    -				$label_path = $label_info['data_path'];
    +			$filename = 'dhl-label-export-' . $order_id . '.pdf';
    +			$label_url = PR_DHL()->get_dhl_label_folder_url() . $filename;
    +			$label_path = PR_DHL()->get_dhl_label_folder_dir() . $filename;
    +			
    +			$cmd = '/usr/bin/gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile='.$label_path.' ' . implode(' ', $docs);
    +			exec($cmd . " 2>&1 &", $return, $code);
    +			if ($code != 0) {
    +			    throw new Exception('Could not merge PDFs into one.' . __METHOD__);
     			}
     
     		} else {
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Not compatible with PHP 8.x’ is closed to new replies.