Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed
chadwells opened this issue Jan 7, 2025 · 3 comments
Assignees
Labels
🕷 bug 📦 commerce Craft Commerce related linear Created by Linear-GitHub Sync

Comments

@chadwells
Copy link

chadwells commented Jan 7, 2025

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()
#1 /var/www/html/vendor/studioespresso/craft-scout/src/Scout.php(173): yii\base\BaseObject->__construct()
#2 [internal function]: rias\scout\Scout->rias\scout\{closure}()
#3 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#4 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
#5 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3920): yii\base\Component->trigger()
#6 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1885): craft\services\Elements->_saveElementInternal()
#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1217): craft\services\Elements->craft\services\{closure}()
#8 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1872): craft\services\Elements->ensureBulkOp()
#9 /var/www/html/vendor/craftcms/commerce/src/elements/Order.php(1619): craft\services\Elements->duplicateElement()
#10 /var/www/html/vendor/craftcms/commerce/src/services/Carts.php(141): craft\commerce\elements\Order->autoSetAddresses()
#11 /var/www/html/modules/fireclaylogic/src/FireclayLogic.php(178): craft\commerce\services\Carts->getCart()
#12 [internal function]: modules\fireclaylogic\FireclayLogic->modules\fireclaylogic\{closure}()
#13 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#14 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
#15 /var/www/html/vendor/yiisoft/yii2/web/User.php(500): yii\base\Component->trigger()
#16 /var/www/html/vendor/craftcms/cms/src/web/User.php(380): yii\web\User->afterLogin()
#17 /var/www/html/vendor/yiisoft/yii2/web/User.php(271): craft\web\User->afterLogin()
#18 /var/www/html/vendor/craftcms/cms/src/web/User.php(325): yii\web\User->login()
#19 /var/www/html/vendor/craftcms/cms/src/controllers/UsersController.php(445): craft\web\User->login()
#20 [internal function]: craft\controllers\UsersController->actionImpersonateWithToken()
#21 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#22 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#23 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#24 /var/www/html/vendor/craftcms/cms/src/web/Application.php(350): yii\base\Module->runAction()
#25 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()
#26 /var/www/html/vendor/craftcms/cms/src/web/Application.php(318): yii\web\Application->handleRequest()
#27 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#28 /var/www/html/web/index.php(12): yii\base\Application->run()
#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

STU-180

@janhenckens janhenckens self-assigned this Jan 8, 2025
@janhenckens
Copy link
Member

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

@janhenckens janhenckens added 🕷 bug 📦 commerce Craft Commerce related linear Created by Linear-GitHub Sync labels Jan 8, 2025
@janhenckens janhenckens changed the title [Bug] TypeError: Cannot assign null to property rias\scout\jobs\IndexElement::$id of type int [STU-180] [Bug] TypeError: Cannot assign null to property rias\scout\jobs\IndexElement::$id of type int Jan 8, 2025
@janhenckens
Copy link
Member

Hey @chadwells, a fix for this is out in 5.0.4 - can update and give it another try? Feel free to reopen should you still have any problems with this!

@chadwells
Copy link
Author

Confirmed this fixed the problem for us. Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🕷 bug 📦 commerce Craft Commerce related linear Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

2 participants