Magento – Shipping Templates Zend PDF Generator Permissions Denied

ce-1.9.0.1magento-1.9permissions

When I try to create a shipping label in Magento Commmunity Edition 1.9, I'm facing a permissions error in system.log:

Warning: imagepng(/var/folders/f3/pd3xtxvd0y390_qjv7pryv6m0000gn/T/shipping_labels_11721274915437009a686f81412890778.png): failed to open stream: Permission denied in /Applications/MAMP/htdocs/my_site/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php on line 732

I am also faced with the following error in exceptions.log:

exception 'Zend_Pdf_Exception' with message 'Cannot create image resource. File not found.' in /Applications/MAMP/htdocs/my_site/lib/Zend/Pdf/Resource/ImageFactory.php:38

Stack trace: #0 /Applications/MAMP/htdocs/fswings/lib/Zend/Pdf/Image.php(124): Zend_Pdf_Resource_ImageFactory::factory('/var/folders/f3…')

As well as the less informative error on the front-end:

An error occurred while creating shipping label.

I've set my permissions site-wide (while developing) to 755 for folders and 644 for files. I tried several things to see if this is indeed a permissions issue:

  • I've temporarily set permissions on ShipmentController.php to 777
  • I've temporarily set permissions recursively on the var folder to 777
  • When that didn't work, I tried setting permissions recursively on the whole project file to 777
  • I've tried to disable and enable the cache, as well as flushing it

My theory is the pdf generator Zend uses is unable to write to var, as I do not see a var/folders directory.

Anyone else have this issue?

Best Answer

If my memory serves correct Zend pdf has issues when working with magento 1.9 on php 5.4 or 5.5.

Go to

/lib/Zend/Pdf/FileParserDataSource.php

and remove

abstract public function __construct(); 

this should resolve your issue.

Related Topic