verbb / events

Craft CMS Plugin for events management and ticketing.
Other
22 stars 13 forks source link

Array to string conversion #118

Closed anchovy closed 1 month ago

anchovy commented 1 year ago

Describe the bug

We've just upgraded to craft v4 and so upgraded Events to 2.0.0-beta.8 and we're getting an issue saving an event in the CMS and via front-end forms. We had no issues previously in Events v 1.4.24

Stack trace of the error:

2023-01-18 01:28:02 [web.ERROR] [yii\base\ErrorException:2] yii\base\ErrorException: Array to string conversion in /Users/anchovy/site/vendor/craftcms/cms/src/helpers/Db.php:566
Stack trace:
#0 /Users/anchovy/site/vendor/craftcms/cms/src/web/ErrorHandler.php(79): yii\base\ErrorHandler->handleError(2, 'Array to string...', '/Users/anchovy/...', 566)
#1 /Users/anchovy/site/vendor/craftcms/cms/src/helpers/Db.php(566): craft\web\ErrorHandler->handleError(2, 'Array to string...', '/Users/anchovy/...', 566)
#2 /Users/anchovy/site/vendor/craftcms/cms/src/helpers/Db.php(817): craft\helpers\Db::parseParam('elements.id', Array, '=', false, 'integer')
#3 /Users/anchovy/site/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1330): craft\helpers\Db::parseNumericParam('elements.id', Array)
#4 /Users/anchovy/site/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#5 /Users/anchovy/site/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\CategoryQuery))
#6 /Users/anchovy/site/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#7 /Users/anchovy/site/vendor/craftcms/cms/src/db/Query.php(248): yii\db\Query->all(NULL)
#8 /Users/anchovy/site/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1492): craft\db\Query->all(NULL)
#9 /Users/anchovy/site/vendor/craftcms/cms/src/fields/Categories.php(114): craft\elements\db\ElementQuery->all()
#10 /Users/anchovy/site/vendor/craftcms/cms/src/base/Element.php(4878): craft\fields\Categories->normalizeValue(Array, Object(verbb\events\elements\Event))
#11 /Users/anchovy/site/vendor/craftcms/cms/src/base/Element.php(3846): craft\base\Element->normalizeFieldValue('eventStatus')
#12 /Users/anchovy/site/vendor/craftcms/cms/src/base/Element.php(2173): craft\base\Element->getFieldValue('eventStatus')
#13 /Users/anchovy/site/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\base\Element->craft\base\{closure}(Object(verbb\events\elements\Event), 'eventStatus')
#14 /Users/anchovy/site/vendor/craftcms/cms/src/web/View.php(625): yii\base\Model->toArray(Array, Array, false)
#15 /Users/anchovy/site/vendor/craftcms/cms/src/helpers/ElementHelper.php(222): craft\web\View->renderObjectTemplate('courses-events/...', Object(verbb\events\elements\Event), Array)
#16 /Users/anchovy/site/vendor/craftcms/cms/src/helpers/ElementHelper.php(137): craft\helpers\ElementHelper::_renderUriFormat('courses-events/...', Object(verbb\events\elements\Event))
#17 /Users/anchovy/site/vendor/craftcms/cms/src/validators/ElementUriValidator.php(56): craft\helpers\ElementHelper::setUniqueUri(Object(verbb\events\elements\Event))
#18 /Users/anchovy/site/vendor/yiisoft/yii2/validators/Validator.php(260): craft\validators\ElementUriValidator->validateAttribute(Object(verbb\events\elements\Event), 'uri')
#19 /Users/anchovy/site/vendor/yiisoft/yii2/base/Model.php(368): yii\validators\Validator->validateAttributes(Object(verbb\events\elements\Event), Array)
#20 /Users/anchovy/site/vendor/craftcms/cms/src/services/Elements.php(2841): yii\base\Model->validate()
#21 /Users/anchovy/site/vendor/craftcms/cms/src/services/Elements.php(1039): craft\services\Elements->_saveElementInternal(Object(verbb\events\elements\Event), true, false, NULL)
#22 /Users/anchovy/site/vendor/verbb/events/src/controllers/EventsController.php(163): craft\services\Elements->saveElement(Object(verbb\events\elements\Event))
#23 [internal function]: verbb\events\controllers\EventsController->actionSave()
#24 /Users/anchovy/site/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#25 /Users/anchovy/site/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#26 /Users/anchovy/site/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save', Array)
#27 /Users/anchovy/site/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('events/events/s...', Array)
#28 /Users/anchovy/site/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('events/events/s...', Array)
#29 /Users/anchovy/site/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#30 /Users/anchovy/site/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#31 /Users/anchovy/site/web/index.php(26): yii\base\Application->run()
#32 {main} {"memory":52610328,"exception":"[object] (yii\\base\\ErrorException(code: 2): Array to string conversion at /Users/anchovy/site/vendor/craftcms/cms/src/helpers/Db.php:566)"} 

`

Steps to reproduce

  1. Add an event in the CMS and save
  2. Save fails.

Craft CMS version

Craft Pro 4.3.6.1

Plugin version

2.0.0-beta.8

Multi-site?

No

Additional context

No response

engram-design commented 1 year ago

This seems to be an issue with the event URL it's creating (judging from the courses-events/... value). Can you confirm if you have advanced templating for your event type URLs? Or maybe its a custom field related to eventStatus?

engram-design commented 1 month ago

Closing due to age.