verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
95 stars 72 forks source link

[4.x] Internal server error #2005

Closed anita-chouhan closed 1 month ago

anita-chouhan commented 1 month ago

Describe the bug

After updating the Formie plugin to version 2.1.21, I experienced internal server issues when opening the form templates or selecting a form in an entry.

Steps to reproduce

  1. Install Craft CMS version higher than 4.9.4
  2. Install Formie plugin version higher than 2.1.20
  3. Try to visit the Templates section in Forms.

Form settings

Craft CMS version

4.10.6

Plugin version

2.1.21

Multi-site?

No

Additional context

The template contains a hidden field with a custom value. Error log shows an error for that field

Next yii\db\Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_xyz_srydwzye' in 'order clause'

engram-design commented 1 month ago

Are you able to send through the full stack trace of the error found in your logs? Just looking to trace that back a few steps.

And can you confirm if this error appears only when you go to edit a form? I know you mentioned "opening the form templates" and I wasn't sure what that was referring to.

It sounds like for some reason the field xyz no longer exists on the form. Re-saving the form should bring back any missing fields. Are you also trying to show that in a column in the Forms index?

anita-chouhan commented 1 month ago

The field name is field_fileId_srydwzye. I renamed it for reporting. Sharing the full stack trace.

Stack Trace

#0 /...path/vendor/yiisoft/yii2/db/Command.php(1325): yii\db\Schema->convertException(Object(PDOException), 'SELECT `element...')
#1 /...path/vendor/yiisoft/yii2/db/Command.php(1186): yii\db\Command->internalExecute('SELECT `element...')
#2 /...path/vendor/yiisoft/yii2/db/Command.php(417): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /...path/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /...path/vendor/craftcms/cms/src/db/Query.php(252): yii\db\Query->all(NULL)
#5 /...path/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1632): craft\db\Query->all(NULL)
#6 /...path/vendor/verbb/formie/src/elements/Form.php(182): craft\elements\db\ElementQuery->all()
#7 /...path/vendor/craftcms/cms/src/base/Element.php(1192): verbb\formie\elements\Form::indexElements(Object(verbb\formie\elements\db\FormQuery), 'template:1')
#8 /...path/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(701): craft\base\Element::indexHtml(Object(verbb\formie\elements\db\FormQuery), Array, Array, 'template:1', 'index', true, true)
#9 /...path/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(165): craft\controllers\ElementIndexesController->elementResponseData(true, true)
#10 [internal function]: craft\controllers\ElementIndexesController->actionGetElements()
#11 /...path/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /...path/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /...path/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('get-elements', Array)
#14 /...path/vendor/craftcms/cms/src/web/Application.php(340): yii\base\Module->runAction('element-indexes...', Array)
#15 /...path/vendor/craftcms/cms/src/web/Application.php(641): craft\web\Application->runAction('element-indexes...', Array)
#16 /...path/vendor/craftcms/cms/src/web/Application.php(302): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#17 /...path/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /...path/web/index.php(12): yii\base\Application->run()
#19 {main}
Additional Information:
Array
(
    [0] => 42S22
    [1] => 1054
    [2] => Unknown column 'field_fileId_srydwzye' in 'order clause'
)
 {"memory":10332632,"exception":"[object] (yii\\db\\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_fileId_srydwzye' in 'order clause'
The SQL being executed was: SELECT `elements`.`id`, `elements`.`canonicalId`, `elements`.`fieldLayoutId`, `elements`.`uid`, `elements`.`enabled`, `elements`.`archived`, `elements`.`dateLastMerged`, `elements`.`dateCreated`, `elements`.`dateUpdated`, `elements_sites`.`id` AS `siteSettingsId`, `elements_sites`.`slug`, `elements_sites`.`siteId`, `elements_sites`.`uri`, `elements_sites`.`enabled` AS `enabledForSite`, `formie_forms`.`id`, `formie_forms`.`handle`, `formie_forms`.`fieldContentTable`, `formie_forms`.`settings`, `formie_forms`.`templateId`, `formie_forms`.`submitActionEntryId`, `formie_forms`.`submitActionEntrySiteId`, `formie_forms`.`defaultStatusId`, `formie_forms`.`dataRetention`, `formie_forms`.`dataRetentionValue`, `formie_forms`.`userDeletedAction`, `formie_forms`.`fileUploadsAction`, `formie_forms`.`fieldLayoutId`, `formie_forms`.`uid`, `content`.`id` AS `contentId`, `content`.`title`, `content`.`field_aspectRatio_yqsgjrjs`, `content`.`field_email_jadtvbvo`, `content`.`field_embed_duocrnhr`, `content`.`field_featuresLists_dhttefvn`, `content`.`field_galleryType_amzhdxbe`, `content`.`field_headline_omjkyeiv`, `content`.`field_isCta_thswausn`, `content`.`field_label_keszzbds`, `content`.`field_label2_vqyavuch`, `content`.`field_label3_irbfetbx`, `content`.`field_legacyUrl_zyplheuc`, `content`.`field_oembed_cekhiqsd`, `content`.`field_phone_ibipueed`, `content`.`field_richTextSimplePlusList_afybwbum`, `content`.`field_richTextSimple_tdbmywoz`, `content`.`field_seoSummary_swfbkfdo`, `content`.`field_seoTitle_qczidvns`, `content`.`field_startDate_dprmbzjo`, `content`.`field_summary_osijuidn`, `content`.`field_text_elxdbklr`, `content`.`field_text2_qubvuarm`, `content`.`field_website_yeizixrc`, `content`.`field_width_btfmqrrh`
FROM (SELECT (SELECT COUNT(*)
FROM `fieldlayouttabs` `pages`
WHERE `pages`.`layoutId` = `formie_forms`.`fieldLayoutId`) AS `pageCount`, `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`
FROM `elements` `elements`
INNER JOIN `formie_forms` `formie_forms` ON `formie_forms`.`id` = `elements`.`id`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`
INNER JOIN `content` `content` ON `content`.`elementId` = `elements`.`id`
WHERE (`formie_forms`.`templateId`=1) AND (`elements`.`archived`=FALSE) AND (`elements`.`dateDeleted` IS NULL) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)
ORDER BY `field_fileId_srydwzye`, `elements`.`id`
LIMIT 100) `subquery`
INNER JOIN `elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`
INNER JOIN `formie_forms` `formie_forms` ON `formie_forms`.`id` = `subquery`.`elementsId`
INNER JOIN `content` `content` ON `content`.`id` = `subquery`.`contentId`
ORDER BY `field_fileId_srydwzye`, `elements`.`id` at /...path/vendor/yiisoft/yii2/db/Schema.php:676)
[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_fileId_srydwzye' in 'order clause' at /...path/vendor/yiisoft/yii2/db/Command.php:1320)"} 

I have also used forms within a matrix block. The error notification pops up when I try to select a form within the matrix field.

By "opening the form templates," I was referring to the "Templates" section under forms. See screenshot

Screenshot 2024-08-05 at 5 35 36 PM

The field field_fileId_srydwzye exists in the form. It is working fine on version 2.1.20. It is not used on the forms index view.

engram-design commented 1 month ago

Ah, I see what you mean. Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.1.21".

anita-chouhan commented 1 month ago

Thank you for the quick response, @engram-design. It is working fine after the update.

anita-chouhan commented 1 month ago

Issue resolved.