Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento PHP 5.4 PDF invoice Zend error

Magento is throwing a PHP error when I'm trying to create PDF invoices (because my client is running PHP 5.4.19).

Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct() in /var/www/vhosts/website/httpdocs/includes/src/Zend_Pdf_FileParserDataSource_File.php on line 41

Normally it's easy to fix this by editing the FileParserDataSource.php and commenting out two lines, the problem is that they run a Zend_Pdf_FileParserDataSource_File.php that extends this script (http://pastebin.com/J64VNsRP).

Is there any solution available so that's possible to create PDF invoices with Magento on a server running PHP 5.4?

like image 414
Hidde Avatar asked Oct 22 '13 11:10

Hidde


3 Answers

This an incompatibility issue between PHP Version 5.4.4 and zend Framwork .

Fixed it by change in this function lib/Zend/Pdf/FileParserDataSource.php.

change

abstract public function __construct();

to

abstract public function __construct($filePath);
like image 162
Mufaddal Avatar answered Nov 10 '22 01:11

Mufaddal


This is zend core issue http://framework.zend.com/issues/browse/ZF-12093. fix it by commenting out __construct and __destruct methods in lib/Zend/Pdf/FileParserDataSource.php

//    abstract public function __construct();

    /**
     * Object destructor. Closes the data source.
     *
     * May also perform cleanup tasks such as deleting temporary files.
     */
//    abstract public function __destruct();`
like image 42
Rajiv Ranjan Avatar answered Nov 10 '22 02:11

Rajiv Ranjan


Sometimes it may be solve by recompile compiler or disable compiler.
Go to System > Tools > Compilation page and click on Run Compilation Process button or Disable button.
Now check print invoice.
http://kb.magenting.com/content/24/81/en/disable-magento-compiler.html

like image 2
himansu Avatar answered Nov 10 '22 00:11

himansu