Closed ghost closed 7 years ago
(1) Setting unknown property: yii2mod\comments\Module::enableInlineEdit
You need to install last package version 1.9.9.2
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a.username' in 'field list'
This error related to your User
class. If your model doesnt't has username
attribute, than you need to add it, or you can override the CommentModel
class and change the following methods:
Thanks for your issue. I need to update README for this issue.
Excellent thank you. That got me going.
Importing comments from legacy system. Original system was flat (not a tree, no parent ids). I figured this is enough to get me going:
(1)
public function add($fc)
{
$c = new CommentModel();
$c->entity = $fc->type_id; // "blog", "video" etc
$c->entityId = $fc->item_id;
$c->content = $fc->text->getAttribute('text');
//'parentId' int(11) DEFAULT NULL,
//'level' smallint(6) NOT NULL DEFAULT '1',
$c->createdBy = $fc->user_id;
$c->updatedBy = $fc->user_id;
//'relatedTo' varchar(500) COLLATE utf8_unicode_ci NOT NULL,
//'url' text COLLATE utf8_unicode_ci,
//'status' smallint(6) NOT NULL DEFAULT '1', APPROVED
//'createdAt' int(11) NOT NULL,
//'updatedAt' int(11) NOT NULL,
$c->save(false);
return true;
}
The fields "url" and "relatedTo" are not clear to me. I assume I will figure them out with some trial and poking about.
Indeed this works. The import completes and I can see/edit via index.php?r=comment%2Fmanage%2Findex
(NB: The README has that url wrong)
But I had to comment out two behaviours from the comment model...
(2)
Exception 'yii\base\NotSupportedException' with message 'Method "yii2mod\comments\models\CommentModel::insert" is not supported for inserting new nodes.' in /home/me/sites/www/vendor/paulzi/yii2-adjacency-list/AdjacencyListBehavior.php:637
In this case I am clueless. Will need to dig into https://github.com/paulzi/yii2-adjacency-list Have not thought about that kind of computing science for many decades.
Stack trace:
#0 [internal function]: paulzi\adjacencyList\AdjacencyListBehavior->beforeSave(Object(yii\base\ModelEvent))
#1 /home/me/sites/www/vendor/yiisoft/yii2/base/Component.php(545): call_user_func(Array, Object(yii\base\ModelEvent))
#2 /home/me/sites/www/vendor/yiisoft/yii2/db/BaseActiveRecord.php(930): yii\base\Component->trigger('beforeInsert', Object(yii\base\ModelEvent))
#3 /home/me/sites/www/vendor/yii2mod/yii2-comments/models/CommentModel.php(209): yii\db\BaseActiveRecord->beforeSave(true)
#4 /home/me/sites/www/vendor/yiisoft/yii2/db/ActiveRecord.php(490): yii2mod\comments\models\CommentModel->beforeSave(true)
#5 /home/me/sites/www/vendor/yiisoft/yii2/db/ActiveRecord.php(461): yii\db\ActiveRecord->insertInternal(NULL)
#6 /home/me/sites/www/vendor/yiisoft/yii2/db/BaseActiveRecord.php(635): yii\db\ActiveRecord->insert(false, NULL)
#7 /home/me/sites/www/console/controllers/ImportCommentController.php(92): yii\db\BaseActiveRecord->save(false)
#8 /home/me/sites/www/console/controllers/ImportCommentController.php(60): console\controllers\ImportCommentController->add(Object(common\modules\fox\models\FoxComment))
#9 [internal function]: console\controllers\ImportCommentController->actionGo()
#10 /home/me/sites/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /home/me/sites/www/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#12 /home/me/sites/www/vendor/yiisoft/yii2/console/Controller.php(128): yii\base\Controller->runAction('go', Array)
#13 /home/me/sites/www/vendor/yiisoft/yii2/base/Module.php(523): yii\console\Controller->runAction('go', Array)
#14 /home/me/sites/www/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('import-comment/...', Array)
#15 /home/me/sites/www/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('import-comment/...', Array)
#16 /home/me/sites/www/vendor/yiisoft/yii2/base/Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request))
#17 /home/me/sites/www/yii(30): yii\base\Application->run()
#18 {main}
(3) Exception 'yii\base\UnknownPropertyException' with message 'Getting unknown property: common\models\account\User::isGuest' in /home/me/sites/www/vendor/yiisoft/yii2/base/Component.php:147
In this case I assume the model was never intended to be used within the console for importing old data. But again feel clueless and must dedicate more time into figuring out what the purpose of this check is.
Stack trace:
#0 /home/me/sites/www/vendor/yiisoft/yii2/db/BaseActiveRecord.php(286): yii\base\Component->__get('isGuest')
#1 /home/me/sites/www/vendor/yiisoft/yii2/behaviors/BlameableBehavior.php(101): yii\db\BaseActiveRecord->__get('isGuest')
#2 /home/me/sites/www/vendor/yiisoft/yii2/behaviors/AttributeBehavior.php(117): yii\behaviors\BlameableBehavior->getValue(Object(yii\base\ModelEvent))
#3 [internal function]: yii\behaviors\AttributeBehavior->evaluateAttributes(Object(yii\base\ModelEvent))
#4 /home/me/sites/www/vendor/yiisoft/yii2/base/Component.php(545): call_user_func(Array, Object(yii\base\ModelEvent))
#5 /home/me/sites/www/vendor/yiisoft/yii2/db/BaseActiveRecord.php(930): yii\base\Component->trigger('beforeInsert', Object(yii\base\ModelEvent))
#6 /home/me/sites/www/vendor/yii2mod/yii2-comments/models/CommentModel.php(170): yii\db\BaseActiveRecord->beforeSave(true)
#7 /home/me/sites/www/vendor/yiisoft/yii2/db/ActiveRecord.php(490): yii2mod\comments\models\CommentModel->beforeSave(true)
#8 /home/me/sites/www/vendor/yiisoft/yii2/db/ActiveRecord.php(461): yii\db\ActiveRecord->insertInternal(NULL)
#9 /home/me/sites/www/vendor/yiisoft/yii2/db/BaseActiveRecord.php(635): yii\db\ActiveRecord->insert(false, NULL)
#10 /home/me/sites/www/console/controllers/ImportCommentController.php(92): yii\db\BaseActiveRecord->save(false)
#11 /home/me/sites/www/console/controllers/ImportCommentController.php(60): console\controllers\ImportCommentController->add(Object(common\modules\fox\models\FoxComment))
#12 [internal function]: console\controllers\ImportCommentController->actionGo()
#13 /home/me/sites/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /home/me/sites/www/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#15 /home/me/sites/www/vendor/yiisoft/yii2/console/Controller.php(128): yii\base\Controller->runAction('go', Array)
#16 /home/me/sites/www/vendor/yiisoft/yii2/base/Module.php(523): yii\console\Controller->runAction('go', Array)
#17 /home/me/sites/www/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('import-comment/...', Array)
#18 /home/me/sites/www/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('import-comment/...', Array)
#19 /home/me/sites/www/vendor/yiisoft/yii2/base/Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request))
#20 /home/me/sites/www/yii(30): yii\base\Application->run()
#21 {main}
PHP Warning: array_map(): An error occurred while invoking the map callback in /home/me/sites/www/vendor/yiisoft/yii2/log/FileTarget.php on line 106
PHP Warning: array_map(): An error occurred while invoking the map callback in /home/me/sites/www/vendor/yiisoft/yii2/log/FileTarget.php on line 106
me@tallone:~/sites/www$
(4)
Fail on widget display. "entityIdAttribute" cannot be empty.
Changed entity from "blog" to "blog_id", still no go. Hard coded entity as "blog_id" and got a page with no errors (and no comments)
if (empty($this->model->{$this->entityIdAttribute})) {
throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "entityIdAttribute" value for widget model cannot be empty.'));
}
(5) Finally I note encryption keys in the comment model (while trying to figure out how to handle entityIdAttribute). I did not expect to find encrypted entities and model name hashes.
All of the above are probably due to lack of effort and understanding on my part. I am sure the answers are available by studying the code. and some textbook on adjacency lists I guess.
I expected the entity type and id to point to the data items we are commenting on. But it has not fallen out that way. There is more I need to know. How is that mapping accomplished? What is going on in CommentModel::init ?
(6) Console log
/index.php?r=comment%2Fdefault%2Fcreate&entity=fQ%0C%C3%BA%C2%86%C2%AC%C2%8…%85%C2%88%C2%B5%1D%C3%BDA%C2%B9%3E6%7B%C3%88S%C3%BD%29ei%1Fq%C2%91+%C3%88s Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Because comment is a module, I think we need the leading forward slash for this ajax call.
(eg r=/comment) When I try it with POSTMAN I get an error saying bad submission (404) instead of 503.
At this point I conclude I do not have enough Yii2 experience to continue. Looks good but will need more time. Thank you
If you want to try this package with yii2 basic template, you can install yii2mod/yii2-base
Any good reason for that? Otherwise not a chance. My advanced template/project is well under way, I'm not going back. I did wonder if RBAC was a requirement (I still do). Sometimes it is faster to re-invent the wheel rather than reverse engineer Other People's Code. For me, this will need working sample data so I can see the parts moving as intended. I'll see if anyone at the forum has something. Thanks.
(1) Setting unknown property: yii2mod\comments\Module::enableInlineEdit
I grep the package for enableInlineEdit and find nothing?
(2) https://test.mysite.com/index.php?r=/comment/manage/index
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a.username' in 'field list'
No mention of authors in the readme, no migrations. A quick attempt to connect it to my user table failed (it wants a defined relation).
I am sorry to post idiot questions, and I suppose I will figure this out. But if am doing something very stupid please let me know. It seems like I have a half-baked version?
Looks very good. Thank you.