craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
226 stars 170 forks source link

[4.x]: Internal server error when exporting CSV in expanded format #2953

Closed peterurban closed 2 years ago

peterurban commented 2 years ago

What happened?

Description

When I try to export a csv from of orders using the Expanded type I get a server error. Raw data and Line Items works as expected.

Steps to reproduce

  1. Select orders from the list
  2. Click Export and select Expanded export type
  3. Click Export

Expected behavior

Get a CSV file

Actual behavior

Server error

Output from PHP error log

`[29-Aug-2022 11:38:09 Europe/Copenhagen] An Error occurred while handling another error: TypeError: array_keys(): Argument #1 ($array) must be of type array, string given in /var/www/project/cms/vendor/craftcms/cms/src/web/CsvResponseFormatter.php:88 Stack trace:

0 /var/www/project/cms/vendor/craftcms/cms/src/web/CsvResponseFormatter.php(88): array_keys('Exception')

1 /var/www/project/cms/vendor/yiisoft/yii2/web/Response.php(1095): craft\web\CsvResponseFormatter->format(Object(craft\web\Response))

2 /var/www/project/cms/vendor/craftcms/cms/src/web/Response.php(286): yii\web\Response->prepare()

3 /var/www/project/cms/vendor/yiisoft/yii2/web/Response.php(339): craft\web\Response->prepare()

4 /var/www/project/cms/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()

5 /var/www/project/cms/vendor/craftcms/cms/src/web/ErrorHandler.php(192): yii\web\ErrorHandler->renderException(Object(yii\base\UnknownMethodException))

6 /var/www/project/cms/vendor/yiisoft/yii2/base/ErrorHandler.php(135): craft\web\ErrorHandler->renderException(Object(yii\base\UnknownMethodException))

7 /var/www/project/cms/vendor/craftcms/cms/src/web/ErrorHandler.php(66): yii\base\ErrorHandler->handleException(Object(yii\base\UnknownMethodException))

8 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\base\UnknownMethodException))

9 {main}

Previous exception: yii\base\UnknownMethodException: Calling unknown method: craft\models\FieldLayout::getFields() in /var/www/project/cms/vendor/yiisoft/yii2/base/Component.php:300 Stack trace:

0 /var/www/project/cms/vendor/craftcms/commerce/src/exports/Expanded.php(50): yii\base\Component->__call('getFields', Array)

1 /var/www/project/cms/vendor/craftcms/cms/src/controllers/ElementIndexesController.php(324): craft\commerce\exports\Expanded->export(Object(craft\commerce\elements\db\OrderQuery))

2 [internal function]: craft\controllers\ElementIndexesController->actionExport()

3 /var/www/project/cms/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

4 /var/www/project/cms/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)

5 /var/www/project/cms/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('export', Array)

6 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('element-indexes...', Array)

7 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('element-indexes...', Array)

8 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))

9 /var/www/project/cms/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))

10 /var/www/project/cms/web/index.php(12): yii\base\Application->run()

11 {main}`

Craft CMS version

4.2.3

Craft Commerce version

4.1.0

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

lukeholder commented 2 years ago

Thanks for reporting this has been fixed for the next release.