yii2 ckeditor 加载出错 Invalid Parameter。

yangtoude
  • 326

1,问题:在加载kartikdetailDetailView时,开启ckeditor后,出现下面异常:
Invalid Parameter – yiibaseInvalidParamException
Trying to copy a directory to itself or a subdirectory.
看了下,问题可能出在下面的第2条:
BaseFileHelper::copyDirectory('/Users/qijiaona/var/www/intel/backend/web/assets', '/Users/qijiaona/var/www/intel/backend/web/assets/da31e3d5');

关闭ckeditor插件后就可以正常运行了。
求解决。

2,错误信息:

1. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/helpers/BaseFileHelper.php at line 260
2. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/AssetManager.php at line 542 – yii\helpers\BaseFileHelper::copyDirectory('/Users/qijiaona/var/www/intel/ba...', '/Users/qijiaona/var/www/intel/ba...', ['dirMode' => 509, 'fileMode' => null, 'beforeCopy' => Closure])
536537538539540541542543544545546547548                    };
                }
            }
            if (!isset($opts['afterCopy']) && $this->afterCopy !== null) {
                $opts['afterCopy'] = $this->afterCopy;
            }
            FileHelper::copyDirectory($src, $dstDir, $opts);
        }
 
        return [$dstDir, $this->baseUrl . '/' . $dir];
    }
 
    /**
3. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/AssetManager.php at line 458 – yii\web\AssetManager::publishDirectory('/Users/qijiaona/var/www/intel/ba...', [])
4. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/AssetBundle.php at line 183 – yii\web\AssetManager::publish('assets', [])
5. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/AssetManager.php at line 266 – yii\web\AssetBundle::publish(yii\web\AssetManager)
6. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/AssetManager.php at line 237 – yii\web\AssetManager::loadBundle('dosamigos\ckeditor\CKEditorWidge...', [], true)
7. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/View.php at line 284 – yii\web\AssetManager::getBundle('dosamigos\ckeditor\CKEditorWidge...')
8. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/AssetBundle.php at line 123 – yii\web\View::registerAssetBundle('dosamigos\ckeditor\CKEditorWidge...')
9. in /Users/qijiaona/var/www/intel/vendor/2amigos/yii2-ckeditor-widget/src/CKEditor.php at line 57 – yii\web\AssetBundle::register(yii\web\View)
10. in /Users/qijiaona/var/www/intel/vendor/2amigos/yii2-ckeditor-widget/src/CKEditor.php at line 44 – dosamigos\ckeditor\CKEditor::registerPlugin()
11. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/Widget.php at line 102 – dosamigos\ckeditor\CKEditor::run()
12. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/widgets/ActiveField.php at line 703 – yii\base\Widget::widget(['preset' => 'full', 'clientOptions' => ['allowedContent' => true, 'extraPlugins' => 'lineheight,uploadimage', 'line_height' => '1;1.2;1.5;2;2.5;3', 'imageUploadUrl' => '/accelerator/upload'], 'model' => common\models\Accelerator, 'attribute' => 'acc_desc_long', ...])
13. in /Users/qijiaona/var/www/intel/vendor/kartik-v/yii2-detail-view/DetailView.php at line 873 – yii\widgets\ActiveField::widget('\dosamigos\ckeditor\CKEditor', ['preset' => 'full', 'clientOptions' => ['allowedContent' => true, 'extraPlugins' => 'lineheight,uploadimage', 'line_height' => '1;1.2;1.5;2;2.5;3', 'imageUploadUrl' => '/accelerator/upload']])
14. in /Users/qijiaona/var/www/intel/vendor/kartik-v/yii2-detail-view/DetailView.php at line 785 – kartik\detail\DetailView::renderFormAttribute(['attribute' => 'acc_desc_long', 'format' => 'raw', 'type' => 'widget', 'widgetOptions' => ['class' => '\dosamigos\ckeditor\CKEditor', 'preset' => 'full', 'clientOptions' => ['allowedContent' => true, 'extraPlugins' => 'lineheight,uploadimage', 'line_height' => '1;1.2;1.5;2;2.5;3', 'imageUploadUrl' => '/accelerator/upload']], ...])
15. in /Users/qijiaona/var/www/intel/vendor/kartik-v/yii2-detail-view/DetailView.php at line 745 – kartik\detail\DetailView::renderAttributeItem(['attribute' => 'acc_desc_long', 'format' => 'raw', 'type' => 'widget', 'widgetOptions' => ['class' => '\dosamigos\ckeditor\CKEditor', 'preset' => 'full', 'clientOptions' => ['allowedContent' => true, 'extraPlugins' => 'lineheight,uploadimage', 'line_height' => '1;1.2;1.5;2;2.5;3', 'imageUploadUrl' => '/accelerator/upload']], ...])
16. in /Users/qijiaona/var/www/intel/vendor/kartik-v/yii2-detail-view/DetailView.php at line 718 – kartik\detail\DetailView::renderAttributeRow(['attribute' => 'acc_desc_long', 'format' => 'raw', 'type' => 'widget', 'widgetOptions' => ['class' => '\dosamigos\ckeditor\CKEditor', 'preset' => 'full', 'clientOptions' => ['allowedContent' => true, 'extraPlugins' => 'lineheight,uploadimage', 'line_height' => '1;1.2;1.5;2;2.5;3', 'imageUploadUrl' => '/accelerator/upload']], ...])
17. in /Users/qijiaona/var/www/intel/vendor/kartik-v/yii2-detail-view/DetailView.php at line 611 – kartik\detail\DetailView::renderDetailView()
18. in /Users/qijiaona/var/www/intel/vendor/kartik-v/yii2-detail-view/DetailView.php at line 548 – kartik\detail\DetailView::runWidget()
19. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/Widget.php at line 102 – kartik\detail\DetailView::run()
20. in /Users/qijiaona/var/www/intel/backend/views/accelerator/view.php at line 176 – yii\base\Widget::widget(['model' => common\models\Accelerator, 'mode' => 'view', 'formOptions' => ['options' => ['enctype' => 'multipart/form-data']], 'panel' => ['heading' => '众创空间详情', 'type' => 'primary'], ...])
21. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/View.php at line 326 – require('/Users/qijiaona/var/www/intel/ba...')
22. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/View.php at line 248 – yii\base\View::renderPhpFile('/Users/qijiaona/var/www/intel/ba...', ['model' => common\models\Accelerator, 'dataProvider' => yii\data\ActiveDataProvider, 'dpMentor' => yii\data\ActiveDataProvider, 'dpInvestor' => yii\data\ActiveDataProvider, ...])
23. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/View.php at line 150 – yii\base\View::renderFile('/Users/qijiaona/var/www/intel/ba...', ['model' => common\models\Accelerator, 'dataProvider' => yii\data\ActiveDataProvider, 'dpMentor' => yii\data\ActiveDataProvider, 'dpInvestor' => yii\data\ActiveDataProvider, ...], backend\controllers\AcceleratorController)
24. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/Controller.php at line 378 – yii\base\View::render('view', ['model' => common\models\Accelerator, 'dataProvider' => yii\data\ActiveDataProvider, 'dpMentor' => yii\data\ActiveDataProvider, 'dpInvestor' => yii\data\ActiveDataProvider, ...], backend\controllers\AcceleratorController)
25. in /Users/qijiaona/var/www/intel/backend/controllers/AcceleratorController.php at line 189 – yii\base\Controller::render('view', ['model' => common\models\Accelerator, 'dataProvider' => yii\data\ActiveDataProvider, 'dpMentor' => yii\data\ActiveDataProvider, 'dpInvestor' => yii\data\ActiveDataProvider, ...])
26. backend\controllers\AcceleratorController::actionView('58')
27. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/InlineAction.php at line 55 – call_user_func_array([backend\controllers\AcceleratorController, 'actionView'], ['58'])
28. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/Controller.php at line 154 – yii\base\InlineAction::runWithParams(['r' => 'accelerator/view', 'id' => '58'])
29. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/Module.php at line 454 – yii\base\Controller::runAction('view', ['r' => 'accelerator/view', 'id' => '58'])
30. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/web/Application.php at line 100 – yii\base\Module::runAction('accelerator/view', ['r' => 'accelerator/view', 'id' => '58'])
31. in /Users/qijiaona/var/www/intel/vendor/yiisoft/yii2/base/Application.php at line 375 – yii\web\Application::handleRequest(yii\web\Request)
32. in /Users/qijiaona/var/www/intel/backend/web/index.php at line 18 – yii\base\Application::run()

3,相关代码:
我的AppAsset类配置

    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.css',
    ];
    public $js = [
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];

4,其他参考:
ps: 我看到之前有人也遇到过类似的问题,比如sgmengfault上的这个yii2 Trying to copy a directory to itself or a subdirectory,还有yiichina上的这个创建表单报错 ,但这两个帖子都与我遇到的情况不同,求解决。

回复
阅读 2.8k
1 个回答

在AppAsset类中添加上这句:public $sourcePath = '@dosamigos/ckeditor/assets';就可以了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏