craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 627 forks source link

Internal Server Error when changing volume path to a broken symlink #10396

Closed cornedor closed 2 years ago

cornedor commented 2 years ago

Description

When changing the File System Path to an already existing directory Craft throws an Internal Server Error without any additional information. This makes it unclear what happened.

Steps to reproduce

  1. Add a volume
  2. Manually create a symlink with a broken link
  3. Change the file system path to a new directory that contains the broken symlink

Additional info

yii\base\ErrorException: mkdir(): File exists in /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/helpers/BaseFileHelper.php:643
Stack trace:
#0 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(84): yii\base\ErrorHandler->handleError(2, 'mkdir(): File e...', '/MaskedProjectDirectory...', 643)
#1 [internal function]: craft\web\ErrorHandler->handleError(2, 'mkdir(): File e...', '/MaskedProjectDirectory...', 643, Array)
#2 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/helpers/BaseFileHelper.php(643): mkdir('/MaskedProjectDirectory...', 509)
#3 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/helpers/FileHelper.php(84): yii\helpers\BaseFileHelper::createDirectory('/MaskedProjectDirectory...', 509, true)
#4 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/volumes/Local.php(80): craft\helpers\FileHelper::createDirectory('/MaskedProjectDirectory...')
#5 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/validators/InlineValidator.php(84): craft\volumes\Local->validatePath('path', NULL, Object(yii\validators\InlineValidator), '@webroot/craft/...')
#6 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/validators/Validator.php(261): yii\validators\InlineValidator->validateAttribute(Object(craft\volumes\Local), 'path')
#7 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Model.php(367): yii\validators\Validator->validateAttributes(Object(craft\volumes\Local), Array)
#8 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/services/Volumes.php(358): yii\base\Model->validate()
#9 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/controllers/VolumesController.php(195): craft\services\Volumes->saveVolume(Object(craft\volumes\Local))
#10 [internal function]: craft\controllers\VolumesController->actionSaveVolume()
#11 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save-volume', Array)
#14 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('volumes/save-vo...', Array)
#15 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/Application.php(596): craft\web\Application->runAction('volumes/save-vo...', Array)
#16 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#17 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /MaskedProjectDirectory/craft/web/index.php(27): yii\base\Application->run()
#19 {main}

Next yii\base\Exception: Failed to create directory "/MaskedProjectDirectory/craft/web/craft/assets/media": mkdir(): File exists in /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/helpers/BaseFileHelper.php:648
Stack trace:
#0 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/helpers/FileHelper.php(84): yii\helpers\BaseFileHelper::createDirectory('/MaskedProjectDirectory...', 509, true)
#1 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/volumes/Local.php(80): craft\helpers\FileHelper::createDirectory('/MaskedProjectDirectory...')
#2 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/validators/InlineValidator.php(84): craft\volumes\Local->validatePath('path', NULL, Object(yii\validators\InlineValidator), '@webroot/craft/...')
#3 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/validators/Validator.php(261): yii\validators\InlineValidator->validateAttribute(Object(craft\volumes\Local), 'path')
#4 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Model.php(367): yii\validators\Validator->validateAttributes(Object(craft\volumes\Local), Array)
#5 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/services/Volumes.php(358): yii\base\Model->validate()
#6 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/controllers/VolumesController.php(195): craft\services\Volumes->saveVolume(Object(craft\volumes\Local))
#7 [internal function]: craft\controllers\VolumesController->actionSaveVolume()
#8 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#10 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save-volume', Array)
#11 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('volumes/save-vo...', Array)
#12 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/Application.php(596): craft\web\Application->runAction('volumes/save-vo...', Array)
#13 /MaskedProjectDirectory/craft/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#14 /MaskedProjectDirectory/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#15 /MaskedProjectDirectory/craft/web/index.php(27): yii\base\Application->run()
#16 {main}
andris-sevcenko commented 2 years ago

@cornedor well, that definitely is an edge-case. Improved the behavior here for the next release!

brandonkelly commented 2 years ago

Craft 3.7.31 is out now with that fix.