Skip to main content

After updating Magento v2.4.6-p6 to Magento v2.4.7-p1, clients reported issues printing order invoices.

The exception log showed an issue creating temporary files.

[2024-07-19T08:24:02.201490+00:00] main.CRITICAL: Error: Call to undefined function Magento\Framework\File\Pdf\ImageResource\tmpfile() in ../vendor/magento/framework/File/Pdf/ImageResource/ImageFactory.php:69
Stack trace:

/vendor/magento/framework/File/Pdf/ImageResource/ImageFactory.php(49): Magento\Framework\File\Pdf\ImageResource\ImageFactory->createTemporaryFileAndPutContent()

/vendor/magento/framework/File/Pdf/Image.php(37): Magento\Framework\File\Pdf\ImageResource\ImageFactory->factory()

Magento 2 tmpfile() issue

The Magento v2.4.7-p1 upgrade had disabled the tmpfile function.

Magento 2 tmpfile() fix

Find your web applications php.ini file or PHP FPM Settings in your host’s control panel.

Look for the text tmpfile.

For me it was in a long list after;

php_admin_value[disable_functions]=

Leave the other entries but remove tmpfile and save the php.ini file.

Print order error after Magento upgrade to 2.4.7

You should now be able to print off PDF invoices. It would be helpful if an up-to-date gotcha list with recommended solutions was released by Adobe with every Magento 2 update, as these minor bugs are fairly common and can be difficult to debug if there’s little discussion online at the time.

Magento 2 putenv issue – putenv has been disabled for security reasons

{“exception”:”[object] (Error(code: 0): Call to undefined function Magento\Framework\Composer\putenv() at /public_html/vendor/magento/framework/Composer/ComposerFactory.php:43)”}

[main.CRITICAL: Error: Call to undefined function Magento\Framework\Composer\putenv()

There’s a similar error when putenv has been disabled. The fix is the same as for tmpfile(), the entry just needs to be removed from the php_admin_value[disable_functions]= list.

putenv has been disabled
Andrew Taylor

A senior UI designer with over 25 years of web design and web development experience working for some of the largest companies in the UK. An expert in all things Magento and WordPress.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.