Invoice PDF corrupted

The invoice PDFs generated for the customer are corrupted. Customers are unable to open the invoice attached nor are they able to open the online version of the PDF in the customer portal. However the PDF on the live invoice screen is not corrupted.

I’m running the v4.1.4 with PHP7.

The last lines from storage/logs/laravel-error:


[2018-02-01 11:30:04] production.ERROR: ***ErrorException*** [0] : /var/www/html/app/Ninja/Repositories/InvoiceRepository.php [Line 1220] => Trying to get property of non-object  {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","url":"https://myhost","previous":"https://myhost","user_agent":"","ip":"127.0.0.1","count":1,"is_console":"yes","is_api":"no","db_server":"mysql"} []
[2018-02-01 11:47:59] production.ERROR: ***ErrorException*** [0] : /var/www/html/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /var/www/html/resources/views/invoices/view.blade.php)  {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","url":"https://myhost/view/nennbnh5gm8l20bxuxguruuvcmmecsj4","previous":"https://myhost/client/invoices","user_agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0","ip":"77.163.6.86","count":1,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-02-01 11:51:56] production.ERROR: ***ErrorException*** [0] : /var/www/html/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /var/www/html/resources/views/invoices/view.blade.php)  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Sjoerd Blom","method":"GET","url":"https://myhost/view/nennbnh5gm8l20bxuxguruuvcmmecsj4","previous":"https://myhost/client/invoices","user_agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0","ip":"77.163.6.86","count":2,"is_console":"no","is_api":"no","db_server":"mysql"} []

Are you using a rijndael cipher? It would cause the “The MAC is invalid” errors.

http://docs.invoiceninja.com/en/latest/update.html#version-4-0

No. It’s a clean install.

php artisan ninja:update-key --legacy=true


Thu, 01 Feb 2018 13:00:41 +0000 Running UpdateKey...

                                                                               
  [RuntimeException]                                                           
  The only supported ciphers are MCRYPT_RIJNDAEL_128 and MCRYPT_RIJNDAEL_256.  
                                                                               

I just did an update and a restart of nginx and php-fpm. Still getting an ‘Whoops, looks like something went wrong.’ when trying to access the invoice in the client portal.

Can you try deleting storage/logs/laravel-error.log, loading the client portal and then checking /errors

Same error. Want to see a copy of the stacktrace.log as well?


[2018-02-01 13:49:53] production.ERROR: ***ErrorException*** [0] : /var/www/html/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /var/www/html/resources/views/invoices/view.blade.php)  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Sjoerd Blom","method":"GET","url":"https://myhost/view/nennbnh5gm8l20bxuxguruuvcmmecsj4","previous":"https://myhost/client/invoices","user_agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0","ip":"77.163.6.86","count":7,"is_console":"no","is_api":"no","db_server":"mysql"} []

It may help, please email it to contact@invoiceninja.com

You may want to try reinstalling the app.

Thanks. It has been sent.
Hmmm… reinstalling the app… Just had loads of trouble upgrading from 3.8 to current… :frowning:

But thanks so much for making time to help me out!

Try archiving the gateways on /settings/online_payments and adding them back

Is it a new install or an upgrade?

Above you wrote ‘clean install’ so I assumed you had just started using the app.

Yes! That was the solution! Thank you sooo much! :slight_smile:

After so many failed upgrades, I decided to import an SQL dump into the current release and force a database upgrade from there on. That worked.