Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STU-180] [Bug] TypeError: Cannot assign null to property rias\scout\jobs\IndexElement::$id of type int #363

Open
janhenckens opened this issue Jan 8, 2025 · 1 comment
Assignees

Comments

@janhenckens
Copy link
Member

When Craft Commerce attempts to creates a new cart and the store's autoSetNewCartAddresses setting is true, Scout breaks this process, resulting in the following:

TypeError: Cannot assign null to property rias\scout\jobs\IndexElement::$id of type int in /var/www/html/vendor/yiisoft/yii2/BaseYii.php:557
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure()
studioespresso/craft-date-range#1 /var/www/html/vendor/studioespresso/craft-scout/src/Scout.php(173): yii\base\BaseObject->__construct()
studioespresso/craft-date-range#2 [internal function]: rias\scout\Scout->rias\scout\{closure}()
studioespresso/craft-date-range#3 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
studioespresso/craft-date-range#4 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
studioespresso/craft-date-range#5 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3920): yii\base\Component->trigger()
studioespresso/craft-date-range#6 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1885): craft\services\Elements->_saveElementInternal()
studioespresso/craft-date-range#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1217): craft\services\Elements->craft\services\{closure}()
studioespresso/craft-date-range#8 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1872): craft\services\Elements->ensureBulkOp()
studioespresso/craft-date-range#9 /var/www/html/vendor/craftcms/commerce/src/elements/Order.php(1619): craft\services\Elements->duplicateElement()
studioespresso/craft-date-range#10 /var/www/html/vendor/craftcms/commerce/src/services/Carts.php(141): craft\commerce\elements\Order->autoSetAddresses()
studioespresso/craft-date-range#11 /var/www/html/modules/fireclaylogic/src/FireclayLogic.php(178): craft\commerce\services\Carts->getCart()
studioespresso/craft-date-range#12 [internal function]: modules\fireclaylogic\FireclayLogic->modules\fireclaylogic\{closure}()
studioespresso/craft-date-range#13 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
studioespresso/craft-date-range#14 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
studioespresso/craft-date-range#15 /var/www/html/vendor/yiisoft/yii2/web/User.php(500): yii\base\Component->trigger()
studioespresso/craft-date-range#16 /var/www/html/vendor/craftcms/cms/src/web/User.php(380): yii\web\User->afterLogin()
studioespresso/craft-date-range#17 /var/www/html/vendor/yiisoft/yii2/web/User.php(271): craft\web\User->afterLogin()
studioespresso/craft-date-range#18 /var/www/html/vendor/craftcms/cms/src/web/User.php(325): yii\web\User->login()
studioespresso/craft-date-range#19 /var/www/html/vendor/craftcms/cms/src/controllers/UsersController.php(445): craft\web\User->login()
studioespresso/craft-date-range#20 [internal function]: craft\controllers\UsersController->actionImpersonateWithToken()
studioespresso/craft-date-range#21 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
studioespresso/craft-date-range#22 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
studioespresso/craft-date-range#23 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
studioespresso/craft-date-range#24 /var/www/html/vendor/craftcms/cms/src/web/Application.php(350): yii\base\Module->runAction()
studioespresso/craft-date-range#25 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()
studioespresso/craft-date-range#26 /var/www/html/vendor/craftcms/cms/src/web/Application.php(318): yii\web\Application->handleRequest()
studioespresso/craft-date-range#27 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
studioespresso/craft-date-range#28 /var/www/html/web/index.php(12): yii\base\Application->run()
studioespresso/craft-date-range#29 {main}

Can confirm this does not happen when Scout is disabled, and Commerce correctly creates the cart with the addresses as expected. This seems to only happen when a user that is logged in has at least one address saved in their Craft User profile.

Craft Pro 5.5.8
Scout 5.0.3
PHP 8.3.14

From SyncLinear.com | STU-180

@janhenckens
Copy link
Member Author

Hey @chadwells, I'll try to reproduce and get to the bottom of this - will keep you posted!

@janhenckens janhenckens transferred this issue from studioespresso/craft-date-range Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant