Framework: Markdown Email ErrorException - Undefined variable: subcopy

Created on 17 Aug 2017  路  10Comments  路  Source: laravel/framework

  • Laravel Version: 5.4.32
  • PHP Version: 7.0.9
  • Database Driver & Version: mysql Ver 15.1 Distrib 10.0.32-MariaDB

Description:

The 'subcopy' component in my Markdown template is throwing an ErrorException, but only in my production environment.

Steps To Reproduce:

I switched to using Markdown email in my Laravel app recently. In some of my markdown templates I've included "subcopy" components. Example of my Markdown template is here:

@component('mail::message')
    @component('mail::panel')
        panel content
    @endcomponent

    @component('mail::subcopy')
        subcopy content
    @endcomponent

    @component('mail::button', ['url' => $url])
        button text
    @endcomponent
@endcomponent 

When released to my production environment, I get the following error:

ErrorException: Undefined variable: subcopy (View: /var/www/vhosts/my.planetlabel.com/resources/views/vendor/mail/html/message.blade.php)

The same emails work fine on my development and staging environments, which for the most part mirror my production environment. I dont necessarily have to use the 'subcopy' component, but I am curious why it works fine on my development and staging environments, but not on my production environment.

Most helpful comment

@QWp6t it was my issue, I was upgraded application from 5.5 to 5.7, so 'or' depreciated and need to use '??' instead of that, i removed all 'or` code from mail template and now issue fixed.

All 10 comments

try to clear the views cache on your production server.

@lancemattson any chance you're running supervisor to process email jobs ?

When this error pops up, I run

php artisan cache:clear
php artisan clear-compiled
php artisan view:clear
supervisorctl reread
supervisorctl update
supervisorctl restart all

Rendering the views directly doesn't trigger an error, but supervisor has to be updated. I'll try to setup a test bench

@themsaid Clearing the views cache on my production server did not resolve the issue.

I actually ended up just removing the 'subcopy' component from all my email views. It wasnt a feature I absolutely needed.

@Lucassifoni I dont believe my production server is using 'supervisor' to process email jobs, but I will look into it and see if that could be the issue. Its good to hear that someone else has at least come across this error.

Thanks for your comments!

@lancemattson maybe not supervisor but anything using compiled views. This error only occurs after updates for me, and it seems that queue workers compile the jobs once and still use their version after a composer update or similar tinkering.

I only have limited comprehension of how those things are executed, I should dive into it instead of assuming this is the root cause.

I'll keep you updated if I ever encounter the cause of this precise issue !

Closing for lack of activity and being unable to replicate, please ping me in case anybody else was able to replicate this issue.

I am getting same error.

@shihabudheenf it seems there's been difficulty reproducing the error. Can you provide a minimal, complete, and verifiable example?

@QWp6t it was my issue, I was upgraded application from 5.5 to 5.7, so 'or' depreciated and need to use '??' instead of that, i removed all 'or` code from mail template and now issue fixed.

Had same issue, as @shihabudheenf says, if after a Laravel upgrade to 5.7, it's about making sure all blade templates are up to date (or to ??) as per upgrading docs on blade section.

To elaborate on @alariva's solution, I had Laravel's mail templates published in my views directory (resources/views/vendor/mail). These were published prior to the 5.7 upgrade and they all contained the or syntax. Once I deleted them and re-published them I was back up and running.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CupOfTea696 picture CupOfTea696  路  3Comments

progmars picture progmars  路  3Comments

ghost picture ghost  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments