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]: Segmentation fault (core dumped) when trying to run upgrade command #3227

Closed
gddotorg opened this issue Jul 21, 2023 · 3 comments
Closed
Assignees
Labels
bug commerce4 Issues related to Commerce v4

Comments

@gddotorg
Copy link

What happened?

What happened?

Description

I am currently in the process of updating the Commerce 3 version to 4 for a customer. Locally, everything has worked so far. Now I have made the adjustments to the staging and wanted to run ./craft commerce/upgrade. The customer migration also went through and now the address migration step should start. Unfortunately, the process terminates immediately and I receive a "Segmentation fault (core dumped)". Unfortunately, I can't find anything in the logs. Any idea where I could start?

Steps to reproduce

  1. Upgrade Craft Commerce via composer
  2. Run ./craft commerce/upgrade
  3. "Creating a user for every customer…" went through
  4. "Migrating address data…" starts and getting process terminates immediately after printing the process bar
  5. Segmentation fault (core dumped) is shown

Craft CMS version

4.4.16.1

Craft Commerce version

4.2.11

PHP version

8.1.20

Operating system and version

Linux 4.19.0-24-amd64

Database type and version

MariaDB 10.3.38

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-50)

Installed plugins and versions

  • Asset Rev | 7.0.0
  • Blitz | 4.5.0
  • CP Field Inspect | 1.4.4
  • Craft Commerce | 4.2.11
  • Digital Products | 3.2.2
  • Elasticsearch | 2.1.1
  • Element API | 3.0.1.1
  • Empty Coalesce | 4.0.0
  • Feed Me | 5.2.0
  • Field and Tab Permissions | 2.0.2
  • Field Manager | 3.0.7
  • Formie | 2.0.33
  • ImageOptimize | 4.0.5
  • Imager X | 4.2.1
  • Maintenance Mode | 1.0.0
  • Redactor | 3.0.4
  • Retour | 4.1.12
  • Sentry SDK | 2.0.1
  • SEOmatic | 4.0.30
  • Sprig | 2.6.2
  • Super Table | 3.0.9
  • Unzer Payment Gateway | 2.0.0
  • Vite | 4.0.6
  • Wishlist | 2.0.6
@gddotorg gddotorg added commerce4 Issues related to Commerce v4 bug labels Jul 21, 2023
@angrybrad
Copy link
Member

We've got a PR we're working on to optimize/speed up the upgrade command here: #3208

It's in a pretty good state - if this is happening on a non-production box, can you give that a whirl and see if it helps?

@gddotorg
Copy link
Author

@angrybrad First of all, I apologise for my late reply. I was able to debug and solve the issue. It seems that the following event in our custom module was responsible:

Event::on(
    Address::class,
    Model::EVENT_DEFINE_RULES,
    function (DefineRulesEvent $event) {
        /** @var Address $address */
        $address = $event->sender;
        $storeLocationAddress = Commerce::getInstance()->getStore()->getStore()->getLocationAddress();
        if ($address->id !== $storeLocationAddress->id) {
            $event->rules[] = [['firstName', 'lastName', 'addressLine1', 'locality', 'postalCode', 'countryCode'], 'required'];
        }
    }
);

I commented it out and then the upgrade process went through. I got the code from the Craft CMS documentation: https://craftcms.com/docs/4.x/addresses.html#validating-addresses

So to keep the validation, I went with this answer: craftcms/cms#11354 (comment)

It worked with on => Model::SCENARIO_DEFAULT

Event::on(
    Address::class,
    Model::EVENT_DEFINE_RULES,
    function (DefineRulesEvent $event) {
        /** @var Address $address */
        $address = $event->sender;
        $storeLocationAddress = Commerce::getInstance()->getStore()->getStore()->getLocationAddress();
        if ($address->id !== $storeLocationAddress->id) {
            $event->rules[] = [
                ['firstName', 'lastName', 'addressLine1', 'locality', 'postalCode', 'countryCode'],
                'required',
                'on' => Model::SCENARIO_DEFAULT
            ];
        }
    }
);

Maybe you could add the information to the documentation in Craft CMS :-)

@lukeholder
Copy link
Member

@AugustMiller Maybe we should put a notice on the upgrade guide here: https://craftcms.com/docs/commerce/4.x/upgrading.html

to be careful that your event listeners to things like address validation are compatible with the new addresses before running the upgrade command.

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
Projects
None yet
Development

No branches or pull requests

3 participants