TransWikia.com

Shipping Templates Zend PDF Generator Permissions Denied

Magento Asked by CSamp on December 5, 2020

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?

2 Answers

The problem was with my "TMPDIR" not being writeable on my local installation (I'm using MAMP). To solve this problem, I've created a info.php file with the phpinfo function:

<?php phpinfo();?>

I found the TMPDIR directory it was trying to access under the "Environment" section of the PHP Info. From there, I went into my filesystem and changed the permissions of "/var/folders" (on my local computer) to allow writing recursively and it worked.

Answered by CSamp on December 5, 2020

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.

Answered by TTech IT Solutions on December 5, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP