shipperhq / module-shipper

Base ShipperHQ Repo
Open Software License 3.0
21 stars 21 forks source link

setup:upgrade fails after composer update to version 20.39.7 (Magento CE 2.4.1) #85

Closed msyhr closed 3 years ago

msyhr commented 3 years ago

Below if statement always returns true:

if (version_compare($context->getVersion(), '1.0.5') < 0 || !$custDestTypeAttribute) {

EAV attribute already exists in datbase:

image

However, this code always returns an empty array

$custDestTypeAttribute = $customerSetup->getAttribute('customer_address','destination_type');

setup:upgrade then faults trying to insert an already existing attribute

Changing the above line to the below resolved the issue for me.

$custDestTypeAttribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'destination_type');

ibraheemnabeelfauzi commented 3 years ago

Hi @msyhr -- thank you for the details. We'll look into this. Can you please tell us what version of the SHQ ext you upgraded from?

msyhr commented 3 years ago

20.36.1

ibraheemnabeelfauzi commented 3 years ago

@msyhr thanks again.

ibraheemnabeelfauzi commented 3 years ago

@msyhr Hi again - I got few questions in regards to this.

Can you please tell me what version of PHP & MySQL were you running here and share any other relevant details a I could replicate this with a local 2.4.1 version of Magento.

msyhr commented 3 years ago

PHP 7.4.13 (cli) (built: Dec 11 2020 08:31:11) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies

Your MySQL connection id is 8 Server version: 8.0.22-13 Percona Server (GPL), Release 13, Revision 6f7822f Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Has happened on Magento 2.4.1 and 2.4.2. Ran into the issue again with the last release (20.40.0). Obviously because my "fix" was just temporary code in the vendor/ directory the composer:update removed edit. setup:upgrade return's the same error (duplicate attribute_code) changing that same line solved the issue again.

ibraheemnabeelfauzi commented 3 years ago

@msyhr Thank you very much. Did you follow the instructions on the following doc line by line when upgrading? https://docs.shipperhq.com/installing-magento-2-shipperhq-extension/

As in regards to the last statement, you've upgraded from 2.4.1 to 2.4.2 then you've upgraded the extension from 20.39.7 to 20.40.0 which cause the same issue?

Can you clarify the vendor/directory and composer: update piece a bit more for me, please?

Are you implying that AFTER making the changes in vendor/directory and running upgrade, setup the installation proceeds without stalling? Or are you saying that the composer: update: remove that bit of code which you re-added and then you re-ran the setup: upgrade and that fixed it?

Thanks again!

TravisBernard commented 3 years ago

My understanding is this issue was for a specific release and has since been resolved. Closing the ticket. Thank you for the report.

moElwan commented 2 years ago

Confirming that we do see the same issue on M2.4.2-p2 Module version: "shipperhq/module-shipper": "20.45.5" upgrading from the module version 20.39.0 PHP 7.4.22

Checking with Xdebug $custDestTypeAttribute always returns empty array while the attribute destination_type do exist on eav_attribute table as showing in the screenshot image

This leads to this error when running setup:upgrade

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-destination_type' for key 'EAV_ATTRIBUTE_ENTITY_TYPE_ID_ATTRIBUTE_CODE', query was: INSERT INTO `eav_attribute` (`entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
TravisBernard commented 2 years ago

Noting here that the latest editions of the module now use declarative schema and data patches instead of update scripts and so the highlighted code is no longer in use.