verbb / super-table

Super-charge your Craft workflow using Super Table.
MIT License
316 stars 47 forks source link

Unable to find the template “_components/fieldtypes/Assets/input”. #297

Closed thulstrup closed 5 months ago

thulstrup commented 5 years ago

Description

After updating Craft I'm unable to create or edit any content in the admin interface.

Craft throws an error: Twig Template Loading Error – craft\web\twig\TemplateLoaderException Unable to find the template “_components/fieldtypes/Assets/input” at line 27 of vendor/verbb/super-table/src/templates/field.html

Additional info

joshuabaker commented 5 years ago

Somehow the template mode is ending up as site, instead of cp, when trying to render that template.

Following the web of calls, it looks like there’s a suppressed exception somewhere in the view component, which is preventing the View::setTemplateMode from restoring the correct template mode.

nstCactus commented 5 years ago

The regression was introduced in 3.3.1.1. A temporary workaround is to downgrade Craft. I had no troubles with project-config when I did so.

engram-design commented 5 years ago

Thanks for reporting, I'll get up to the latest version and test as soon as I can

joshuabaker commented 5 years ago

Reverting to 3.3.1.1 worked. Thanks, @nstCactus 🙏

engram-design commented 5 years ago

So, just testing on 3.3.1.2, and I can't seem to recreate this issue. I've tested editing/creating Super Table field, editing/creating entries with Super Table fields attached to them, but all seems okay?

I wonder if its another plugin incorrectly settings the templateMode, before Super Table? Would have to be something common to 3 people though!

thulstrup commented 5 years ago

Here are my plugins:

The error still persists when I disable all of them (except Super Table).

engram-design commented 5 years ago

Thanks @thulstrup does this occur when you're editing specific entries, or any entries? When you load an entry, or save it? Does it happen for sections that don't have a Super Table field?

When specifically does it occur?

engram-design commented 5 years ago

If anymore can provide a screenshot of the full stack trace with devMode on, I can debug further

joshuabaker commented 5 years ago

@engram-design I don’t think a stack trace is going to help here as the exception surfacing is thrown by the template loader. As noted in craftcms/cms#4912, due to the 3.3.1.2 changes, the Assets field is suppressing any underlying exceptions.

I saw this exception being thrown by an SuperTableBlockElement instance with only the fieldId set. Briefly looking at the database, all looks present and correct. Is there any reason why that might have been unpopulated?

engram-design commented 5 years ago

@joshuabaker If not for the stack trace then when/where is the error occurring? I can't even get it to throw this error, which is what I'm try to recreate. Basically, after the error page that's showing Twig Template Loading Error – craft\web\twig\TemplateLoaderException Unable to find the template “_components/fieldtypes/Assets/input”

Not 100% sure about the second part to your question, and it depends when it occurred and what you were doing. Was it loading an entry to edit, saving, or something else?

Can you advise on your Super Table field setup maybe?

engram-design commented 5 years ago

I'm also not sure I follow about the error suppression within this file. I can uncomment those try/catch statements to throw that error, and even throw an exception further up, and it won't affect things from loading okay

joshuabaker commented 5 years ago

Here’s a breakdown of what I saw yesterday:

  1. To get a folder ID via a call to inputSources, the Assets field instance calls renderObjectTemplate
  2. View then sets the template mode to ‘site’
  3. View then tries to get variables from SuperTableBlockElement
  4. ownerId is not set so throws an exception (View therefore doesn’t get to reset the template mode to ‘cp’)
  5. Assets catches that exception
  6. But then throws a different kind of exception
  7. Unfortunately, this exception is caught
  8. As the template mode is still ‘site’ and not ‘cp’, the template loader then tries to load the _components/fieldtypes/Assets/input template in the wrong template mode
engram-design commented 5 years ago

Thanks for the detailed explanation @joshuabaker - was this an existing entry you were editing or a new one? Seems to be an issue with ownerId not being set, as you've mentioned

joshuabaker commented 5 years ago

Sure thing. It’s a complicated web of calls to traverse.

was this an existing entry you were editing or a new one?

It was an existing entry.

Seems to be an issue with ownerId not being set, as you've mentioned

If memory serves, only the fieldId was set on the SuperTableBlockElement instance.

I think the issue is actually unrelated to 3.3.1.2. It’s just that the moving setTemplateMode call before the element is accessed has allowed this to surface.

engram-design commented 5 years ago

Yep, that's what I'm thinking @joshuabaker - its just surfaced the issue. I'll try and investigate further, but might likely need access to one of these installs to see specifically what's going on.

Thanks for your troubleshooting!

thulstrup commented 5 years ago

@engram-design I can load existing entries, but I can't edit or create new. It only happens for entries with Super Table fields.

Here's a stack trace: https://pastebin.com/c5PMG1WY