Drupal 10 compatibility (Fixed all tests)

Created on 28 December 2022, almost 2 years ago
Updated 30 June 2023, over 1 year ago

Make Commerce Stock module and submodules Drupal 10 compatible

Create a patch with core_version_requirement modified and rector suggested changes.

โœจ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡น๐Ÿ‡ทTurkey rgnyldz

    Any updates on this? Is there a dev version we can test and give feedback ?

  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    @RgnYLDZ you can apply the patch against current dev version and review it. You can even clone the 3330022-drupal-10-compatibility branch.
    Thank you for your interest!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom guy_schneerson

    Thanks, @silviuchingaru I was expecting the Event stuff and could not think of anything else that should cause an issue so I suspect you got it spot on :)

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    @guy_schneerson you are welcomed but I think that the patch is not ready because it uses event from Symfony 6 and is marked as compatible with Drupal 8 which is not the case because Symfony 6 was implemented in Drupal > 9.0.
    I think we should use it like Commerce does to make it also backward compatible.
    I'll update merge request soon with this.

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    Fixed all tests (error and deprecation)!

    After this patch, the output of run-tests.sh is:

    [obfuscated-user@localhost d10]$ ./run-tests.sh --verbose --directory modules/contrib/commerce_stock
    
    Drupal test run
    ---------------
    
    Tests to be run:
      - Drupal\Tests\commerce_stock\Kernel\StockServiceManagerTest
      - Drupal\Tests\commerce_stock\Functional\ProductAdminTest
      - Drupal\Tests\commerce_stock\Functional\StockServiceTest
      - Drupal\Tests\commerce_stock_local\Kernel\Entity\StockLocationTest
      - Drupal\Tests\commerce_stock_local\Kernel\LocalStockServiceTest
      - Drupal\Tests\commerce_stock_local\Kernel\LocalStockUpdaterTest
      - Drupal\Tests\commerce_stock_local\Kernel\OrderEventTransactionsKernelTest
      - Drupal\Tests\commerce_stock_local\Kernel\OrderEventsTransactionsTest
      - Drupal\Tests\commerce_stock_local\Kernel\StockLocationStorageTest
      - Drupal\Tests\commerce_stock_field\Kernel\StockLevelTest
      - Drupal\Tests\commerce_stock_field\Functional\StockLevelFormatterTest
      - Drupal\Tests\commerce_stock_field\Functional\StockLevelWidgetsTest
      - Drupal\Tests\commerce_stock_enforcement\Functional\EnforcementBrowserTest
      - Drupal\Tests\commerce_stock_enforcement\Functional\OutOfStockTest
    
    Test run started:
      Wednesday, January 25, 2023 - 23:58
    
    Test summary
    ------------
    
    Drupal\Tests\commerce_stock\Kernel\StockServiceManagerTest     1 passes
    Drupal\Tests\commerce_stock\Functional\ProductAdminTest        2 passes
    Drupal\Tests\commerce_stock\Functional\StockServiceTest        1 passes
    Drupal\Tests\commerce_stock_local\Kernel\Entity\StockLocatio   1 passes
    Drupal\Tests\commerce_stock_local\Kernel\LocalStockServiceTe   1 passes
    Drupal\Tests\commerce_stock_local\Kernel\LocalStockUpdaterTe   1 passes
    Drupal\Tests\commerce_stock_local\Kernel\OrderEventTransacti   3 passes
    Drupal\Tests\commerce_stock_local\Kernel\OrderEventsTransact   7 passes
    Drupal\Tests\commerce_stock_local\Kernel\StockLocationStorag   1 passes
    Drupal\Tests\commerce_stock_field\Kernel\StockLevelTest        6 passes
    Drupal\Tests\commerce_stock_field\Functional\StockLevelForma   2 passes
    Drupal\Tests\commerce_stock_field\Functional\StockLevelWidge   6 passes
    Drupal\Tests\commerce_stock_enforcement\Functional\Enforceme   2 passes
    Drupal\Tests\commerce_stock_enforcement\Functional\OutOfStoc   2 passes
    
    Test run duration: 45 min 19 sec
    
    Detailed test results
    ---------------------
    
    
    ---- Drupal\Tests\commerce_stock\Functional\ProductAdminTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      ProductAdminTest.   27 Drupal\Tests\commerce_stock\Functio
    
    Pass      Other      ProductAdminTest.   73 Drupal\Tests\commerce_stock\Functio
    
    
    
    ---- Drupal\Tests\commerce_stock\Functional\StockServiceTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockServiceTest.   40 Drupal\Tests\commerce_stock\Functio
    
    
    
    ---- Drupal\Tests\commerce_stock\Kernel\StockServiceManagerTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockServiceManag   38 Drupal\Tests\commerce_stock\Kernel\
    
    
    
    ---- Drupal\Tests\commerce_stock_enforcement\Functional\EnforcementBrowserTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      EnforcementBrowse   34 Drupal\Tests\commerce_stock_enforce
    
    Pass      Other      EnforcementBrowse   42 Drupal\Tests\commerce_stock_enforce
    
    
    
    ---- Drupal\Tests\commerce_stock_enforcement\Functional\OutOfStockTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      OutOfStockTest.ph   34 Drupal\Tests\commerce_stock_enforce
    
    Pass      Other      OutOfStockTest.ph   42 Drupal\Tests\commerce_stock_enforce
    
    
    
    ---- Drupal\Tests\commerce_stock_field\Functional\StockLevelFormatterTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockLevelFormatt   28 Drupal\Tests\commerce_stock_field\F
    
    Pass      Other      StockLevelFormatt   42 Drupal\Tests\commerce_stock_field\F
    
    
    
    ---- Drupal\Tests\commerce_stock_field\Functional\StockLevelWidgetsTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockLevelWidgets   24 Drupal\Tests\commerce_stock_field\F
    
    Pass      Other      StockLevelWidgets  155 Drupal\Tests\commerce_stock_field\F
    
    Pass      Other      StockLevelWidgets  242 Drupal\Tests\commerce_stock_field\F
    
    Pass      Other      StockLevelWidgets  357 Drupal\Tests\commerce_stock_field\F
    
    Pass      Other      StockLevelWidgets  452 Drupal\Tests\commerce_stock_field\F
    
    Pass      Other      StockLevelWidgets  470 Drupal\Tests\commerce_stock_field\F
    
    ---- Drupal\Tests\commerce_stock_field\Kernel\StockLevelTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockLevelTest.ph  151 Drupal\Tests\commerce_stock_field\K
    
    Pass      Other      StockLevelTest.ph  169 Drupal\Tests\commerce_stock_field\K
    
    Pass      Other      StockLevelTest.ph  181 Drupal\Tests\commerce_stock_field\K
    
    Pass      Other      StockLevelTest.ph  191 Drupal\Tests\commerce_stock_field\K
    
    Pass      Other      StockLevelTest.ph  199 Drupal\Tests\commerce_stock_field\K
    
    Pass      Other      StockLevelTest.ph  230 Drupal\Tests\commerce_stock_field\K
    
    
    
    ---- Drupal\Tests\commerce_stock_local\Kernel\Entity\StockLocationTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockLocationTest   54 Drupal\Tests\commerce_stock_local\K
    
    
    
    ---- Drupal\Tests\commerce_stock_local\Kernel\LocalStockServiceTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      LocalStockService   47 Drupal\Tests\commerce_stock_local\K
    
    
    
    ---- Drupal\Tests\commerce_stock_local\Kernel\LocalStockUpdaterTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      LocalStockUpdater  149 Drupal\Tests\commerce_stock_local\K
    
    
    
    ---- Drupal\Tests\commerce_stock_local\Kernel\OrderEventTransactionsKernelTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      OrderEventTransac  240 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventTransac  325 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventTransac  447 Drupal\Tests\commerce_stock_local\K
    
    
    
    ---- Drupal\Tests\commerce_stock_local\Kernel\OrderEventsTransactionsTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      OrderEventsTransa  262 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventsTransa  299 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventsTransa  318 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventsTransa  340 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventsTransa  376 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventsTransa  453 Drupal\Tests\commerce_stock_local\K
    
    Pass      Other      OrderEventsTransa  557 Drupal\Tests\commerce_stock_local\K
    
    
    
    ---- Drupal\Tests\commerce_stock_local\Kernel\StockLocationStorageTest ----
    
    
    Status    Group      Filename          Line Function
    --------------------------------------------------------------------------------
    Pass      Other      StockLocationStor   49 Drupal\Tests\commerce_stock_local\K
    
    
  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    Patch to add a test.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    Against D10 I tested locally and all pass, after commit, we'll have a dev release for composer to install and test further, D9.x has some deprecated functions that won't pass against PHP 8.1, 8s a known issue, but all should pass also from 7.3 to 8.0.
    I think this is ready for commit now.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark nicklasmf

    I'm getting the following .rej error file when trying to apply the patch to Drupal 9.5.3:

    --- modules/field/commerce_stock_field.info.yml
    +++ modules/field/commerce_stock_field.info.yml
    @@ -7,4 +7,4 @@ dependencies:
       - commerce_stock:commerce_stock
       - commerce_stock:commerce_stock_local
     core: 8.x
    -core_version_requirement: ^8 || ^9
    +core_version_requirement: ^8 || ^9 || ^10
    

    I am running a D10 site but couldn't install the module and the patch at the same time, so I downgraded to D9.5 and then installed commerce_stock. After this, I tried to apply the patch but got the error above.

    Can you confirm that the patch still works for you, and if so, can you elaborate on how I can test the patch?

  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    I queued a test agains Drupal 9.5.2, let's see if it passes.
    Meanwhile please post the content of.rej file.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark nicklasmf

    Sorry, if it was not clear enough in my post. The code in the grey box is the .rej file.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    Can you post exact commands and their output of how you try to patch, please?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom guy_schneerson

    @NicklasMF thank you for your hard work on this.
    I Tested on 10.0.3 with commerce 2.33 and all worked so far.
    I have not had a chance to test with 9 and I can see how Symfony 6 events may be an issue although it looks like Symfony 5 has an Event class that provides a forward-compatibility layer so maybe it will just work.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark nicklasmf

    Sure. I have following in composer.json:

    cweagans/composer-patches: 1.7.3
    drupal/commerce: 2.33.0
    drupal/commerce_stock: 1.0.0

    I then add the following:

    "patches": {
      "drupal/commerce_stock": {
        "#3330022 D10": "https://www.drupal.org/files/issues/2023-01-26/commerce-stock-d10-compat-3330022-8.patch"
      }
    },

    And run composer update drupal/commerce_stock in console.

    I get following error:

    Gathering patches for dependencies. This might take a minute.
      - Installing drupal/commerce_stock (1.0.0): Extracting archive
      - Applying patches for drupal/commerce_stock
        https://www.drupal.org/files/issues/2023-01-26/commerce-stock-d10-compat-3330022-8.patch (#D10)
       Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2023-01-26/commerce-stock-d10-compat-3330022-8.patch

    And the file commerce_stock_field.info.yml.rejis created:

    --- modules/field/commerce_stock_field.info.yml
    +++ modules/field/commerce_stock_field.info.yml
    @@ -7,4 +7,4 @@ dependencies:
       - commerce_stock:commerce_stock
       - commerce_stock:commerce_stock_local
     core: 8.x
    -core_version_requirement: ^8 || ^9
    +core_version_requirement: ^8 || ^9 || ^10
    
  • Issue was unassigned.
  • ๐Ÿ‡ท๐Ÿ‡ดRomania SilviuChingaru

    Can you try also, please, with:

    "patches": {
      "drupal/commerce_stock": {
        "#3330022 D10": "https://git.drupalcode.org/project/commerce_stock/-/merge_requests/14.diff"
      }
    },
    

    Thank you!

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark nicklasmf

    I don't know why that didn't work neither.
    I tried some things back and forth and finally got it to work. I removed one line in the start and added a new line after the specific file.

    From line 76:

    diff --git a/modules/field/commerce_stock_field.info.yml b/modules/field/commerce_stock_field.info.yml
    index 820088b68788c6e770fdb4432ab963d908f75429..d4994864e6db85472d9eca5fc554b74fde16f97f 100644
    --- a/modules/field/commerce_stock_field.info.yml
    +++ b/modules/field/commerce_stock_field.info.yml
    @@ -8,4 +8,4 @@ dependencies:
       - commerce_stock:commerce_stock_local
     core: 8.x
    -core_version_requirement: ^8 || ^9
    +core_version_requirement: ^8 || ^9 || ^10
    
    diff --git a/modules/field/tests/src/Functional/StockLevelFieldTestBase.php b/modules/field/tests/src/Functional/StockLevelFieldTestBase.php
    

    I'll just add the patch in case it is useful.
    And then I'll go test the patch now.

  • ๐Ÿ‡น๐Ÿ‡ญThailand AlfTheCat

    Latest patch applied cleanly, so far it all seems to work.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vipin.j

    vipin.j โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States socalerich

    So how do we install this with Drupal 10 then?

    I added this to my patches section in composer.json:

    "drupal/commerce_stock": {
        "3330022 - Drupal 10 compatibility (Fixed all tests)": "https://www.drupal.org/files/issues/2023-02-26/commerce-stock-d10-compat-3330022-17.patch"
    }
    

    but if I do composer require drupal/commerce_stock, I get

    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - drupal/commerce_stock[1.0.0-alpha1, ..., 1.0.0-alpha4] require drupal/core ~8.0 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev] but the package is fixed to 10.0.7 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
        - drupal/commerce_stock[1.0.0-alpha5, ..., 1.x-dev] require drupal/core ^8 || ^9 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but the package is fixed to 10.0.7 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
        - Root composer.json requires drupal/commerce_stock ^1.0 -> satisfiable by drupal/commerce_stock[1.0.0-alpha1, ..., 1.x-dev].
    
    Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
    You can also try re-running composer require with an explicit version constraint, e.g. "composer require drupal/commerce_stock:*" to figure out if any version is installable, or "composer require drupal/commerce_stock:^2.1" if you know which you need.
    
    Installation failed, reverting ./composer.json and ./composer.lock to their original content.
    
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom guy_schneerson

    After testing on both 9 and 10 I committed SilviuChingaru patch commerce-stock-d10-compat-3330022-8.patch
    I assume we will still fail tests and we will need a second commit but thought it best to have a dev version with 10 support to work and test on.
    Will look at the other proposed changes wen I can.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria agoradesign

    is there anything left do do? this is the last important blocker for our commerce sites to upgrade to 10.x

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom guy_schneerson

    @agoradesign should be good to go. Dev version should be all fine if you can give that a go and confirm that will help.
    I am away until Thursday and can push a version then.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria agoradesign

    Actually I do have the dev installed on 3 10.x sites. No problems so far, but I have to mention that two of them are stell under development and the third one is live though, but not under heavy traffic :D
    Anyway, we had one or two orders there since then, as well as saving stock changes via migrate import did not cause any errors as well

  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom guy_schneerson

    A big thank you to everyone that helped with this. I just pushed 8.x-1.1 and marked the issue as fixed. If anyone gets any issues specific to D10 then please reopen.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024