craftcms / redactor

Edit rich text content in Craft CMS using Redactor by Imperavi.
https://plugins.craftcms.com/redactor
MIT License
100 stars 48 forks source link

[3.x]: Upload to asset index can sometimes fail #414

Closed ccchapman closed 2 years ago

ccchapman commented 2 years ago

What happened?

Description

Upload to asset index can sometimes fail given the below conditions.

Steps to reproduce

  1. Create Redactor field
    • Enable "image" button
  2. Add field to entry type
  3. Create or edit an entry
  4. Click image button in Redactor field
  5. Upload a file

Expected behavior

The /index.php?p=actions/element-indexes/get-elements request has a numerical criteria.siteId and is successful.

Actual behavior

{
    "siteId": {
        "baseUrl": "...",
        "dateCreated": "...",
        "dateUpdated": "...",
        "enabled": true,
        "groupId": 1,
        "handle": "default",
        "hasUrls": true,
        "id": 1,
        "language": "en",
        "name": "...",
        "originalBaseUrl": null,
        "originalName": null,
        "primary": true,
        "sortOrder": 1,
        "uid": "..."
    }
}
PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type bigint: "default"
CONTEXT:  unnamed portal parameter $3 = '...'
#26 /var/www/.../vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement::execute
#25 /var/www/.../vendor/yiisoft/yii2/db/Command.php(1302): yii\db\Command::internalExecute
craftcms/cms#24 /var/www/.../vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command::queryInternal
craftcms/cms#23 /var/www/.../vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command::queryAll
craftcms/cms#22 /var/www/.../vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query::all
craftcms/cms#21 /var/www/.../vendor/craftcms/cms/src/db/Query.php(152): craft\db\Query::all
craftcms/cms#20 /var/www/.../vendor/craftcms/cms/src/services/Search.php(329): craft\services\Search::_searchElements
craftcms/cms#19 /var/www/.../vendor/craftcms/cms/src/services/Search.php(239): craft\services\Search::searchElements
craftcms/cms#18 /var/www/.../vendor/craftcms/cms/src/elements/db/ElementQuery.php(2846): craft\elements\db\ElementQuery::_applySearchParam
craftcms/cms#17 /var/www/.../vendor/craftcms/cms/src/elements/db/ElementQuery.php(1546): craft\elements\db\ElementQuery::prepare
craftcms/cms#16 /var/www/.../vendor/yiisoft/yii2/db/QueryBuilder.php(227): yii\db\QueryBuilder::build
craftcms/cms#15 /var/www/.../vendor/yiisoft/yii2/db/Query.php(157): yii\db\Query::createCommand
craftcms/cms#14 /var/www/.../vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query::all
craftcms/cms#13 /var/www/.../vendor/craftcms/cms/src/db/Query.php(152): craft\db\Query::all
craftcms/cms#12 /var/www/.../vendor/craftcms/cms/src/elements/db/ElementQuery.php(1624): craft\elements\db\ElementQuery::all
craftcms/cms#11 /var/www/.../vendor/craftcms/cms/src/base/Element.php(868): craft\base\Element::indexHtml
craftcms/cms#10 /var/www/.../vendor/craftcms/cms/src/controllers/ElementIndexesController.php(538): craft\controllers\ElementIndexesController::elementResponseData
craftcms/cms#9 /var/www/.../vendor/craftcms/cms/src/controllers/ElementIndexesController.php(135): craft\controllers\ElementIndexesController::actionGetElements
craftcms/cms#8 [internal](0): call_user_func_array
craftcms/cms#7 /var/www/.../vendor/yiisoft/yii2/base/InlineAction.php(57): yii\base\InlineAction::runWithParams
craftcms/cms#6 /var/www/.../vendor/yiisoft/yii2/base/Controller.php(178): yii\base\Controller::runAction
craftcms/cms#5 /var/www/.../vendor/yiisoft/yii2/base/Module.php(552): yii\base\Module::runAction
craftcms/cms#4 /var/www/.../vendor/craftcms/cms/src/web/Application.php(293): craft\web\Application::runAction
craftcms/cms#3 /var/www/.../vendor/craftcms/cms/src/web/Application.php(602): craft\web\Application::_processActionRequest
craftcms/cms#2 /var/www/.../vendor/craftcms/cms/src/web/Application.php(272): craft\web\Application::handleRequest
craftcms/cms#1 /var/www/.../vendor/yiisoft/yii2/base/Application.php(384): yii\base\Application::run
#0 /index.php(27): null

Craft CMS version

3.7.44

PHP version

8.1

Operating system and version

No response

Database type and version

PostgreSQL 14

Image driver and version

No response

Installed plugins and versions

brandonkelly commented 2 years ago

I’m not able to reproduce this.

Any chance you can send a database backup and your Composer files over to support@craftcms.com, so we can try to reproduce from there?

brandonkelly commented 2 years ago

Actually, I think I see what the issue is. Can you please change your craftcms/redactor requirement in composer.json to v2.x-dev and run composer update, and confirm that the bug no longer persists?

ccchapman commented 2 years ago

Verified! At least criteria.siteId is now as expected. I assume it will address the SQL exception; however, I do not know how to reliably reproduce.

Thank you.

brandonkelly commented 2 years ago

Thanks for checking! Redactor 2.10.9 and 3.0.1 are out with the fix.