[3.x]: TypeError: Return value of craft\fields\Assets::_findFolder()
@i-just is already working on this.
Since Jan 24, 2024.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
What happened?
Description
Just updated a Craft CMS 3 site to 3.9.5 and now getting this error when trying to create a new entry:
TypeError: Return value of craft\fields\Assets::_findFolder() must be an instance of craft\models\VolumeFolder, null returned
FWIW the entry type does have a couple of asset fields, which "Restrict assets to a single folder" on Amazon S3 and that asset location does contain {slug} (I wonder if that might be of importance).
I can create new entries in other sections without any problems.
The only slightly awkward point is that I can't reproduce this issue locally, only in production, which is unusual. But given this site isn't under active development and the Craft CMS upgrade is the only change that's been made (this was working just fine a few days ago) I'm a little out of ideas!
Steps to reproduce
- Go to a section and hit the "New entry" button.
- Get a 500 error.
Stack trace
TypeError: Return value of craft\fields\Assets::_findFolder() must be an instance of craft\models\VolumeFolder, null returned
(/domain.com/vendor/craftcms/cms/src/fields/Assets.php:889)
return $folder;
craft\fields\Assets::_findFolder(/domain.com/vendor/craftcms/cms/src/fields/Assets.php:947)
return $this->_findFolder($sourceKey, $subpath, $element, $createDynamicFolders);
craft\fields\Assets::_uploadFolder(/domain.com/vendor/craftcms/cms/src/fields/Assets.php:638)
$folder = $this->_uploadFolder($element, false);
craft\fields\Assets::inputSources(/domain.com/vendor/craftcms/cms/src/fields/BaseRelationField.php:1008)
'sources' => $this->inputSources($element),
craft\fields\BaseRelationField::inputTemplateVariables(/domain.com/vendor/craftcms/cms/src/fields/Assets.php:698)
$variables = parent::inputTemplateVariables($value, $element);
craft\fields\Assets::inputTemplateVariables(/domain.com/vendor/craftcms/cms/src/fields/BaseRelationField.php:594)
$variables = $this->inputTemplateVariables($value, $element);
craft\fields\BaseRelationField::inputHtml(/domain.com/vendor/craftcms/cms/src/fields/Assets.php:283)
return parent::inputHtml($value, $element);
craft\fields\Assets::inputHtml(/domain.com/vendor/craftcms/cms/src/base/Field.php:465)
$html = $this->inputHtml($value, $element);
craft\base\Field::getInputHtml(/domain.com/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php:260)
$html = $this->_field->getInputHtml($value, $element);
craft\fieldlayoutelements\CustomField::inputHtml(/domain.com/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php:203)
$inputHtml = $this->inputHtml($element, $static);
craft\fieldlayoutelements\BaseField::formHtml(/domain.com/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php:213)
return (string)parent::formHtml($element, $static);
craft\fieldlayoutelements\CustomField::craft\fieldlayoutelements\{closure}(/domain.com/vendor/craftcms/cms/src/web/View.php:1529)
$response = $this->namespaceInputs($html(), $namespace, $otherAttributes, $withClasses);
craft\web\View::namespaceInputs(/domain.com/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php:214)
}, 'fields');
craft\fieldlayoutelements\CustomField::formHtml(/domain.com/vendor/craftcms/cms/src/models/FieldLayout.php:594)
return (string)$layoutElement->formHtml($element, $static);
craft\models\FieldLayout::craft\models\{closure}(/domain.com/vendor/craftcms/cms/src/web/View.php:1524)
return $html();
craft\web\View::namespaceInputs(/domain.com/vendor/craftcms/cms/src/models/FieldLayout.php:593)
$elementHtml = $view->namespaceInputs(function() use ($layoutElement, $element, $static) {
craft\models\FieldLayout::createForm(/domain.com/vendor/twig/twig/src/Extension/CoreExtension.php:1570)
$ret = $object->$method(...$arguments);
twig_get_attribute(/domain.com/vendor/craftcms/cms/src/helpers/Template.php:106)
return \twig_get_attribute($env, $source, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
craft\helpers\Template::attribute(/domain.com/storage/runtime/compiled_templates/cc/ccdeb57a8125a11059a9d998753a3fd8fa9394a42559dec1c7d29839d543e952.php:175)
$context["form"] = craft\helpers\Template::attribute($this->env, $this->source, craft\helpers\Template::attribute($this->env, $this->source, ($context["element"] ?%3F_null%29%2C_%22getFieldLayout%22%2C_%5B0%5D=%3E+%28%24context%5B%22element%22%5D+%
__TwigTemplate_77a0c1f2083b9dfb852c9a7f66358708c8549cc77bf8ab70910e2ddfc83e2509::doDisplay(/domain.com/vendor/twig/twig/src/Template.php:405)
$this->doDisplay($context, $blocks);
Twig\Template::displayWithErrorHandling(/domain.com/vendor/twig/twig/src/Template.php:378)
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
Twig\Template::display(/domain.com/storage/runtime/compiled_templates/6f/6f077381a6ddf3dcae3da5b6ea2777fefc054070a084d88ebfbf1f2933986d6b.php:124)
$this->parent->display($context, array_merge($this->blocks, $blocks));
__TwigTemplate_367b54d6e17f226ad63b87287416126ede1b4df71984d3ffd174f3ecde983176::doDisplay(/domain.com/vendor/twig/twig/src/Template.php:405)
$this->doDisplay($context, $blocks);
Twig\Template::displayWithErrorHandling(/domain.com/vendor/twig/twig/src/Template.php:378)
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
Twig\Template::display(/domain.com/vendor/twig/twig/src/Template.php:390)
$this->display($context);
Twig\Template::render(/domain.com/vendor/twig/twig/src/TemplateWrapper.php:45)
return $this->template->render($context, \func_get_args()[1] ?%3F_%5B0%5D=
Twig\TemplateWrapper::render(/domain.com/vendor/twig/twig/src/Environment.php:318)
return $this->load($name)->render($context);
Twig\Environment::render(/domain.com/vendor/craftcms/cms/src/web/View.php:408)
$output = $this->getTwig()->render($template, $variables);
craft\web\View::renderTemplate(/domain.com/vendor/craftcms/cms/src/web/View.php:461)
echo $this->renderTemplate($template, $variables);
craft\web\View::renderPageTemplate(/domain.com/vendor/craftcms/cms/src/web/Controller.php:216)
$this->response->data = $view->renderPageTemplate($template, $variables, $templateMode);
craft\web\Controller::renderTemplate(/domain.com/vendor/craftcms/cms/src/controllers/EntriesController.php:258)
return $this->renderTemplate('entries/_edit', $variables);
craft\controllers\EntriesController::actionEditEntry(:)
call_user_func_array(/domain.com/vendor/yiisoft/yii2/base/InlineAction.php:57)
return call_user_func_array([$this->controller, $this->actionMethod], $args);
yii\base\InlineAction::runWithParams(/domain.com/vendor/yiisoft/yii2/base/Controller.php:178)
$result = $action->runWithParams($params);
yii\base\Controller::runAction(/domain.com/vendor/yiisoft/yii2/base/Module.php:552)
$result = $controller->runAction($actionID, $params);
yii\base\Module::runAction(/domain.com/vendor/craftcms/cms/src/web/Application.php:295)
$result = parent::runAction($route, $params);
craft\web\Application::runAction(/domain.com/vendor/yiisoft/yii2/web/Application.php:103)
$result = $this->runAction($route, $params);
yii\web\Application::handleRequest(/domain.com/vendor/craftcms/cms/src/web/Application.php:280)
return parent::handleRequest($request);
craft\web\Application::handleRequest(/domain.com/vendor/yiisoft/yii2/base/Application.php:384)
$response = $this->handleRequest($this->getRequest());
yii\base\Application::run(/sites/domain.com/public/index.php:26)
$app->run();
Craft CMS version
3.9.5
PHP version
7.3.33
Operating system and version
Ubuntu 20.04
Database type and version
MySQL 5.7
Image driver and version
No response
Installed plugins and versions
| Plugin | Version |
|---|---|
| Amazon S3 | 1.3.2 |
| Asset Rev | 6.0.2 |
| Embedded Assets | 2.11.4 |
| Expanded Singles | 1.2.0 |
| Image Resizer | 2.2.2 |
| Maps | 3.9.4 |
| MatrixMate | 1.5.0 |
| Phone Number | 1.5.0 |
| Redactor | 2.10.12 |
| Rollbar | 1.0.3 |
| SEO | 3.4.62 |
| Super Table | 2.7.5.1 |
| Typed link field | 2.0.0-rc.2 |
| Webhooks | 2.4.1 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.