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

[4.x]: Error saving OrderHistory, userId must be initialized #3858

Closed
rvgool-oym opened this issue Jan 22, 2025 · 3 comments
Closed

[4.x]: Error saving OrderHistory, userId must be initialized #3858

rvgool-oym opened this issue Jan 22, 2025 · 3 comments
Assignees
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce Fixed

Comments

@rvgool-oym
Copy link

What happened?

Description

When updating an Order Status through the console we are currently facing the following exception:
Typed property craft\commerce\models\OrderHistory::$userId must not be accessed before initialization

This is a result by a previous fix that only sets the userId when the request is not a console-request (be857b5)

Therefor when doing the following, we get the error mentioned above.

$order = ...
$order->orderStatusId = $statusCompletedId;
Craft::$app->getElements()->saveElement($order);

Craft CMS version

4.13.8

Craft Commerce version

4.7.2

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@rvgool-oym rvgool-oym added bug commerce4 Issues related to Commerce v4 Craft Commerce labels Jan 22, 2025
Copy link

linear bot commented Jan 22, 2025

PT-2394 [4.x]:

@rvgool-oym rvgool-oym changed the title [4.x]: [4.x]: Error saving OrderHistory, userId must be initialized Jan 22, 2025
@lukeholder
Copy link
Member

@rvgool-oym Thanks for reporting this issue. We have fixed this for the next release.

To get the fix early, change your craftcms/commerce requirement in composer.json in your Craft Commerce 4.x project to:

"require": {
  "craftcms/commerce": "4.x-dev#9ea381a97d393f50f46ea0a60ad4cf6dbe252954 as 4.8.0",
  "...": "..."
}

or if you are using 5.x:

"require": {
  "craftcms/commerce": "5.x-dev#149790a844bd28a9e6ae4518601637431595bcea 5.3.0.2",
  "...": "..."
}

Then run composer update.

Thanks again.

We will update this ticket once fix in inside an official release.

@lukeholder lukeholder self-assigned this Feb 3, 2025
@nfourtythree
Copy link
Contributor

Commerce version 5.3.1 has now been released with this fix included.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce Fixed
Projects
None yet
Development

No branches or pull requests

3 participants