3

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?

0

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.

  • My installation of Magento (1.9.0.1) did not have that line of code in that file. Perhaps they removed it? I downgraded my server to PHP 5.3 and face the same error. This looks like it's a permissions issue? – CSamp Oct 10 '14 at 21:38
  • Go to System > Tools > Compilation page and click on Run Compilation Process button or Disable button. sometimes recompiling your magento installation will fix missing file issues – TTech IT Solutions Oct 10 '14 at 22:02
  • I've tried running the compilation process and disabling it and still get the same error. This must be an issue with my localized server (I'm running MAMP) as it works when I host it live. I'm trying to see if there's any other info I can find. – CSamp Oct 13 '14 at 19:29
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.