Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect dynamic Field asset upload folder results in "Could not resolve the subpath" #2610

Closed
kr37 opened this issue Mar 20, 2018 · 1 comment
Assignees
Labels
bug severity:minor Cosmetic issues or bugs with simple workarounds

Comments

@kr37
Copy link

kr37 commented Mar 20, 2018

Description

This is not a huge problem, just an ungraceful degradation relating to bad user input.

When adding a field to a global set, the control panel gives an error: Could not resolve the subpath "branding/{siteHandle}"

The immediate solution (for me) was to correct to branding/{site} and it works fine, but I thought you'd want craft to check for this more gracefully.

Steps to reproduce

  1. Create a field with type 'asset', and set the upload folder incorrectly, such as branding/{siteHandle}
  2. On Settings->Globals, add the field and try to save. An error will be displayed.

Additional info

craft\errors\InvalidSubpathException: Could not resolve the subpath “branding/{siteHandle}”. in /var/www/craft3/vendor/craftcms/cms/src/fields/Assets.php:542
Stack trace:
#0 /var/www/craft3/vendor/craftcms/cms/src/fields/Assets.php(626): craft\fields\Assets->_resolveVolumePathToFolderId('folder:1', 'branding/{siteH...', Object(craft\elements\GlobalSet), true)
#1 /var/www/craft3/vendor/craftcms/cms/src/fields/Assets.php(278): craft\fields\Assets->_determineUploadFolderId(Object(craft\elements\GlobalSet))
#2 /var/www/craft3/vendor/craftcms/cms/src/base/Element.php(1723): craft\fields\Assets->afterElementSave(Object(craft\elements\GlobalSet), false)
#3 /var/www/craft3/vendor/craftcms/cms/src/services/Elements.php(459): craft\base\Element->afterSave(false)
#4 /var/www/craft3/vendor/craftcms/cms/src/services/Globals.php(282): craft\services\Elements->saveElement(Object(craft\elements\GlobalSet), false)
#5 /var/www/craft3/vendor/craftcms/cms/src/controllers/GlobalsController.php(82): craft\services\Globals->saveSet(Object(craft\elements\GlobalSet))
#6 [internal function]: craft\controllers\GlobalsController->actionSaveSet()
#7 /var/www/craft3/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#8 /var/www/craft3/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#9 /var/www/craft3/vendor/craftcms/cms/src/web/Controller.php(74): yii\base\Controller->runAction('save-set', Array)
#10 /var/www/craft3/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-set', Array)
#11 /var/www/craft3/vendor/craftcms/cms/src/web/Application.php(237): yii\base\Module->runAction('globals/save-se...', Array)
#12 /var/www/craft3/vendor/craftcms/cms/src/web/Application.php(445): craft\web\Application->runAction('globals/save-se...', Array)
#13 /var/www/craft3/vendor/craftcms/cms/src/web/Application.php(221): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#14 /var/www/craft3/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#15 /var/www/html/index.php(24): yii\base\Application->run()
#16 {main}
  • Craft version: Personal 3.0.0-RC14
  • PHP version: 7.1.15
  • Database driver & version: MySQL 5.5.59
  • Plugins & versions: Redactor 1.0.1 (Pixel & Tonic), Importable 1.0.1 (Mark Drzycimski), Amazon S3 1.0.8 (Pixel & Tonic), Calendar Links 1.0.0 (Superbig), Wordsmith 3.0.2 (Michael Rog), Environment Label 3.1.2 (Top Shelf Craft (Michael Rog))
    Domain: http://localhost
@brandonkelly brandonkelly added bug severity:minor Cosmetic issues or bugs with simple workarounds labels Mar 21, 2018
@andris-sevcenko
Copy link
Contributor

Since the actual subpath resolution happens after the element has been saved, it's not possible to add any validation errors or bail out of global set (which is an element) saving.

So, throwing an exception is the most appropriate way - if it looked like the global set had saved and an error message (which would be hacky to add), was not noticed, it might be pretty misleading to the user.

Taking all of that into account, it's probably best to leave the behavior as it is currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug severity:minor Cosmetic issues or bugs with simple workarounds
Projects
None yet
Development

No branches or pull requests

3 participants