FriendsOfFlarum/pretty-mail

Remove deprecated functions from templates

Closed this issue · 4 comments

Bug Report

Current Behavior
Templates still use {!! app()->url() !!} which is invalid in 16+ and thows error

Call to undefined method Illuminate\Container\Container::url()

Steps to Reproduce

  1. Use default tempaltes, specifially the "user mentioned" which contains the {!! app()->url() !!} as part of discussion link
  2. Add a post/comment
  3. Error in UI, email never sends, and worse afterUpdate events like reindex never called.

Expected Behavior
Expect clean error and post-update functions to still ruin.

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2021-05-25 at 1 28 04 PM

\

Environment

Possible solution(s)
remove or repalce that call in template

From beta 14 upgrade guide:

The app helper now points to an instance of Illuminate\Container\Container, not Flarum\Foundation\Application. You might need to resolve things through the container before using them: for instance, app()->url() will no longer work; you'll need to resolve or inject an instance of Flarum\Foundation\Config and use that.

This was updated previously

<a href="{{ $url->to('forum')->base() }}">{{ $settings->get('forum_title') }}</a>

and

<a href="{{ $url->to('forum')->base() }}">{{ $settings->get('forum_title') }}</a>

And announced here https://discuss.flarum.org/d/11178-friendsofflarum-pretty-mail/121

I think the issue you are seeing may be due to old templates being held in the db. They're stored in the settings table. You could try resetting the templates to defaults, which should solve the problem you see here.

That said, I intend to refactor this extension in the next day or two ready for Flarum v1.0, and have some changes in mind to the templating system used by this extension to bring it more in line with standard Laravel templates (using partials as much as possible)

Doh! Yes perfect thank you and sorry!

No problem at all :)