myparcelnl / prestashop

PrestaShop module to integrate with MyParcel NL and BE
https://developer.myparcel.nl/nl/documentatie/11.prestashop.html
10 stars 5 forks source link

[BETA]: (beta-2) install method doesn't exists #243

Closed mariuszsienkiewicz closed 5 months ago

mariuszsienkiewicz commented 6 months ago

Version check

PrestaShop version

8.1.5

PHP version

8.1

What went wrong?

When I try to upgrade the module from version 1.7.1 or 1.7.2 (but any version will be problematic I think) to beta-2 I get this error:

[2024-04-18 12:48:45] request.CRITICAL: Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\UndefinedMethodError: "Attempted to call an undefined method named "install" of class "MyParcelNL\PrestaShop\Service\ModuleService"." at /psroot/modules/myparcelnl/vendor/myparcelnl/pdk/src/Base/Facade.php line 25 {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\UndefinedMethodError(code: 0): Attempted to call an undefined method named \"install\" of class \"MyParcelNL\\PrestaShop\\Service\\ModuleService\". at /psroot/modules/myparcelnl/vendor/myparcelnl/pdk/src/Base/Facade.php:25)"} []

The problem is in the upgrade scripts:

https://github.com/myparcelnl/prestashop/blob/45fd4612de21d7a86723dc0eda5ad8748efd7c5f/upgrade/upgrade-1.7.2.php#L5-L8

It uses Facade that sets the ancestor to MyParcelNL\PrestaShop\Service\ModuleService which of course doesn't contain the install method and because of this upgrade fails.

It's quite surprising that every update script has the same content, is it because the beta version doesn't support updates for now, or why does it look like this?

Reproduction steps

  1. Install the module version 1.7.1 on clean PrestaShop installation
  2. Try to upgrade to beta-2
  3. See the results

Relevant log output

No response

Additional context

No response

EdieLemoine commented 5 months ago

Hi @mariuszsienkiewicz, thanks for reporting. I've opened a pr that (re-)adds the method, and also fixes issues with it. For example, if you for some reason had a faulty API key saved in the old module, you could not upgrade until you either deleted or fixed it. Also, the module needed to be passed to the install method.

Upgrades are definitely implemented and should work, I've added a PHPDoc comment to each upgrade method to point readers towards the implementation that hopefully clears up how this works. Small tl;dr: In the install function of the PDK we check whether we're supposed to do a fresh install or an upgrade. If upgrading, it determines which upgrade migrations need to be run based on the previous installed version.

myparcel-bot[bot] commented 5 months ago

:tada: This issue has been resolved in version 4.0.0-beta.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

myparcel-bot[bot] commented 1 day ago

:tada: This issue has been resolved in version 4.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: