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

[5.x]: Attempt to read property "storeId" on null #3482

Closed
mjniland1 opened this issue May 6, 2024 · 5 comments
Closed

[5.x]: Attempt to read property "storeId" on null #3482

mjniland1 opened this issue May 6, 2024 · 5 comments

Comments

@mjniland1
Copy link

What happened?

Description

Applying the project configuration from Commerce 5.0.3 to a new project resulted in a failure with the error message: "error: Attempt to read property 'storeId' on null". While trying to troubleshoot this issue, I attempted to accessed the store settings on my original project at (admin/commerce/settings/stores/1) and encountered another error

Database Exception – yii\db\Exception
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'commerce_orders.id' in 'on clause'
The SQL being executed was: SELECT EXISTS(SELECT *
FROM c_commerce_orders
LEFT JOIN c_elements el ON el.id = commerce_orders.id
WHERE (storeId=1) AND (el.dateDeleted IS NULL))
Error Info: Array
(
[0] => 42S22
[1] => 1054
[2] => Unknown column 'commerce_orders.id' in 'on clause'

Steps to reproduce

  1. Upgrade a commerce 4.x project to commerce 5.0.3
  2. attempting to navigate to admin/commerce/settings/stores/1 will result in the db error above
  3. attempting to apply the upgraded 5.0.3 project config to a new project will result in the error: Attempt to read property "storeId" on null

Craft CMS version

Craft Pro 5.1.1

Craft Commerce version

5.0.3

PHP version

8.2.18

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Copy link

linear bot commented May 6, 2024

@lukeholder
Copy link
Member

Thanks for reporting this.

For the initial error, we have this issue you can follow here: #3479

For the subsequent query error, we have fixed this for the next release.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#3780e2a81515926b8e6b1417ad79ae331668bee1 as 5.0.3",
  "...": "..."
}

Then run composer update.

We will update this github issue once the release is out.

@mjniland1
Copy link
Author

mjniland1 commented May 7, 2024

Appreciate the quick response.

The query error has been fixed on my end but the issue referenced in #3479 still persists after upgrading to 5.x-dev#3780e2a81515926b8e6b1417ad79ae331668bee1.

Log after running composer install on the new build:

  • Downloading craftcms/commerce (5.x-dev 3780e2a)
  • Installing plugin "commerce" ... done
    Applying changes from your project config files ...
  • updating meta.names ... done
  • removing siteGroups.ca1a6137-baa3-4430-a0bc-51e1e6aaf243 ... done
  • removing sites.9b9465f2-e4f1-45c3-b655-77c3aa307af4 ...
    error: Attempt to read property "storeId" on null

The project config is a fresh rebuild from the database.

@mjniland1
Copy link
Author

Upgrading to 5.x-dev#323ac6403f8a91812af074811fab37fb5e021e93 as 5.0.3 in #3488 fixed the original issue for me but later in the process the config apply failed due to: error: Calling unknown method: craft\models\Site::getStore().

@lukeholder
Copy link
Member

@mjniland1 Can you submit a new issue and include steps to reproduce, and email your pre-upgrade DB, original commerce 4 project config folder, composer.json, composer.lock to support@craftcms.com and reference the github issue you created. Thanks.

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

2 participants