bymayo / craft-pdf-transform

Transform a PDF page to an image (JPEG, PNG)
MIT License
12 stars 8 forks source link

Works locally but not on my staging server #18

Open LoriWJ opened 1 year ago

LoriWJ commented 1 year ago

The plugin works great on my local site but I get messages saying "Server error" when I upload a PDF on the stagings site and no PDF image is created.

The site is using Craft 4 with PHP 8.0 and imagick is enabled.

The log has this info but I can't work out what's wrong and the hosting provider has passed the buck:

2022-10-21 11:25:19 [web.ERROR] [Error] Call to a member function getFs() on null {"trace":["#0 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(76): bymayo\\pdftransform\\services\\PdfTransformService->getImageFs()","#1 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php(90): bymayo\\pdftransform\\services\\PdfTransformService->getImagePath()","#2 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/variables/PdfTransformVariable.php(31): bymayo\\pdftransform\\services\\PdfTransformService->url()","#3 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Extension/CoreExtension.php(1607): bymayo\\pdftransform\\variables\\PdfTransformVariable->url()","#4 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/helpers/Template.php(101): twig_get_attribute()","#5 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/c4/c4ac190651f9d17a6a43b632147b0259.php(39): craft\\helpers\\Template::attribute()","#6 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_c25395822ed239b688190dbfc4ed3ed8->doDisplay()","#7 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#8 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/29/296f0a121c9e78448826b9bc9d9a480c.php(109): Twig\\Template->display()","#9 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_2765f3d79697d75dc0b7947e20bff4aa->doDisplay()","#10 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#11 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/55/555cb5e54de9ff68ab15d5b71022ec0c.php(518): Twig\\Template->display()","#12 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(171): __TwigTemplate_52ca98011db850df96f99a6e81a476ef->block_body()","#13 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/5d/5dcaa8bd50cdf38b694fdc0605ea58ac.php(77): Twig\\Template->displayBlock()","#14 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(171): __TwigTemplate_4eb728540a4f60db495bce06b137c3bd->block_content()","#15 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/50/50806b3e6add389722d58fb5d86b20b8.php(113): Twig\\Template->displayBlock()","#16 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_6bc90a4b84db3ada443c1f0b49474a17->doDisplay()","#17 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#18 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/5d/5dcaa8bd50cdf38b694fdc0605ea58ac.php(50): Twig\\Template->display()","#19 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_4eb728540a4f60db495bce06b137c3bd->doDisplay()","#20 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#21 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/55/555cb5e54de9ff68ab15d5b71022ec0c.php(124): Twig\\Template->display()","#22 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_52ca98011db850df96f99a6e81a476ef->doDisplay()","#23 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#24 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/TemplateWrapper.php(47): Twig\\Template->display()","#25 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/storage/runtime/compiled_templates/f6/f61df7fc18351a7dda5bd2fca283748a.php(38): Twig\\TemplateWrapper->display()","#26 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(394): __TwigTemplate_b560aeecd2b2e702870bf71cd9bc7e79->doDisplay()","#27 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#28 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","#29 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\\Template->render()","#30 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/twig/twig/src/Environment.php(277): Twig\\TemplateWrapper->render()","#31 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/View.php(428): Twig\\Environment->render()","#32 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/View.php(481): craft\\web\\View->renderTemplate()","#33 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(56): craft\\web\\View->renderPageTemplate()","#34 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/yiisoft/yii2/web/Response.php(1095): craft\\web\\TemplateResponseFormatter->format()","#35 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/craftcms/cms/src/web/Response.php(286): yii\\web\\Response->prepare()","#36 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/yiisoft/yii2/web/Response.php(339): craft\\web\\Response->prepare()","#37 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/yiisoft/yii2/base/Application.php(390): yii\\web\\Response->send()","#38 /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/web/index.php(26): yii\\base\\Application->run()","#39 {main}"],"memory":7324112,"exception":"[object] (Error(code: 0): Call to a member function getFs() on null at /home/dffafcde/prod/releases/7fc9ee068092b0d35c81c2e8152fec5ac9d02a9f/vendor/bymayo/pdf-transform/src/services/PdfTransformService.php:69)"} 
bymayo commented 1 year ago

@LoriWJ Hmm thats an odd one!

It looks like it's throwing an error when getting your File System. Are you using the same one locally as on production?

E.g. On production your not using Amazon S3, but locally using Local file system for example?

LoriWJ commented 1 year ago

I'm using the local file system in both environments.

bymayo commented 1 year ago

@LoriWJ Struggling to fix this one!

But I have just released 2.0.1 which refactored the way images are transformed then stored. Can you try installing this and letting me know if it fixes this issue.

A little side note also, you can now use .render() with 2.0.1 e.g. {{ craft.pdfTransform.render(asset) }} and this now outputs as a Asset element (Where as before you could only get the URL) so you can do things like {{ craft.pdfTransform.render(asset).filename }} etc

LoriWJ commented 1 year ago

Thank you for looking into this, I appreciate it. We’ve now had to launch without the plugin. I can’t spend any more of the client’s budgeted time on it but if I have some time outside of work I may do more testing.

bymayo commented 1 year ago

@LoriWJ Thanks, yeah any feedback would be great.

zenbug commented 1 year ago

For what it's worth, I was having this same issue and the problem turned out to be a low memory_limit (and perhaps max_execution_time as well) in my PHP settings.