0

I understand there's a lot of work being done on the Update Asset Indexes feature. I believe I've run into another issue related to MySQL, whereas other issues have been related to PHP's memory_limit.

Would appreciate some feedback on trying to address this issue.

Thanks!

2016/12/31 22:45:19 [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`homeaidoc`.`craft_assetfolders`, CONSTRAINT `craft_assetfolders_parentId_fk` FOREIGN KEY (`parentId`) REFERENCES `craft_assetfolders` (`id`) ON DELETE CASCADE). The SQL statement executed was: INSERT INTO `craft_assetfolders` (`uid`, `parentId`, `sourceId`, `name`, `path`, `dateUpdated`, `dateCreated`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6).
2016/12/31 22:45:19 [error] [exception.CDbException] CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`homeaidoc`.`craft_assetfolders`, CONSTRAINT `craft_assetfolders_parentId_fk` FOREIGN KEY (`parentId`) REFERENCES `craft_assetfolders` (`id`) ON DELETE CASCADE) in /var/www/craft/app/framework/db/CDbCommand.php:358
Stack trace:
#0 /var/www/craft/app/framework/db/ar/CActiveRecord.php(1081): CDbCommand->execute()
#1 /var/www/craft/app/framework/db/ar/CActiveRecord.php(810): CActiveRecord->insert(NULL)
#2 /var/www/craft/app/services/AssetsService.php(263): CActiveRecord->save()
#3 /var/www/craft/app/assetsourcetypes/BaseAssetSourceType.php(1022): Craft\AssetsService->storeFolder(Object(Craft\AssetFolderModel))
#4 /var/www/craft/app/assetsourcetypes/LocalAssetSourceType.php(121): Craft\BaseAssetSourceType->ensureFolderByFullPath('development/emm...')
#5 /var/www/craft/app/services/AssetIndexingService.php(40): Craft\LocalAssetSourceType->startIndex('cf59adea-fe2b-4...')
#6 /var/www/craft/app/tools/AssetIndexTool.php(94): Craft\AssetIndexingService->getIndexListForSource('cf59adea-fe2b-4...', '1')
#7 /var/www/craft/app/controllers/ToolsController.php(50): Craft\AssetIndexTool->performAction(Array)
#8 /var/www/craft/app/framework/web/actions/CInlineAction.php(49): Craft\ToolsController->actionPerformAction()
#9 /var/www/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#10 /var/www/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#11 /var/www/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#12 /var/www/craft/app/framework/web/CWebApplication.php(282): CController->run('performAction')
#13 /var/www/craft/app/etc/web/WebApp.php(817): CWebApplication->runController('tools/performAc...')
#14 /var/www/craft/app/etc/web/WebApp.php(287): Craft\WebApp->_processActionRequest()
#15 /var/www/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#16 /var/www/craft/app/index.php(62): CApplication->run()
#17 /var/www/public/index.php(19): require_once('/var/www/craft/...')
#18 {main}
REQUEST_URI=/index.php/admin/actions/tools/performAction
HTTP_REFERER=http://homeaidoc.craft.dev/admin/settings
---
1

That error indicates a problem with the data in your database.

The craft_assetfolders table has a parentId column that is a foreign key reference to its own id column. For whatever reason, that parentId column has a value that doesn't exist in any of the id columns, hence your errors.

Some common causes include:

  1. Someone manually editing database values.

  2. A botched import/export script when backing up/restoring databases.

  3. Having multiple Craft installs (maybe across environments) pointing to the same cloud based Asset source (S3, Google Cloud, etc.) and someone deletes/moves/etc. an Asset on one environment making the other one out of sync with reality.

|improve this answer|||||
  • I really appreciate the response. I did some tinkering in the craft_assetfolders table and fond some odd entries. I also disabled plugins that are supposed to help with import/exports, but it ended up being more trouble than it helped. Your advice helped out a lot! – vcao Jan 3 '17 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.