Error: Class "Doctrine\Common\Collections\ArrayCollection" not found

Created on 4 October 2023, about 1 year ago
Updated 12 July 2024, 4 months ago

In views, when the "Display the subdivision name instead of the subdivision code" is checked, the site is suddenly seeing this error:

Error: Class "Doctrine\Common\Collections\ArrayCollection" not found in CommerceGuys\Addressing\Subdivision\Subdivision->__construct() (line 118 of /var/www/vendor/commerceguys/addressing/src/Subdivision/Subdivision.php).

Unchecking the checkbox solves the issue.

We also see warnings regarding ArrayCollection.php - I believe it's connected. Not sure if it's a Doctrine change or what.

πŸ› Bug report
Status

Closed: outdated

Version

1.12

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States greatmatter

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

Comments & Activities

  • Issue created by @greatmatter
  • πŸ‡·πŸ‡ΈSerbia bojanz

    What is your Drupal version?
    Did you install Address via Composer or Ludwig?

  • πŸ‡ΊπŸ‡ΈUnited States greatmatter

    We're running Drupal 10.1.5, and we installed Address via Composer.

  • πŸ‡·πŸ‡ΈSerbia bojanz

    Hm, we require doctrine/collections in the composer.json for commerceguys/addressing, so it should be impossible for the package to be missing. Furthermore, ArrayCollection is present in every version of doctrine/collections.

    If you can check what versions of commerceguys/addressing and doctrine/collections Composer has installed, that might help us with further debugging.

  • πŸ‡ΊπŸ‡ΈUnited States greatmatter

    Of course:
    commerceguys/addressing:1.4.2
    doctrine/collections:2.1.4

  • πŸ‡·πŸ‡ΈSerbia bojanz

    I apologize for the late response.

    You specified that you're using Address 2.0.x-dev which requires commerceguys/addressing v2.0.0 or newer, but your site has v1.4.2 installed. That is odd. Still, both addressing versions do allow doctrine/collections v2.1.4 to be used.

    Looking at doctrine/collections v2.1.4, I see an ArrayCollection class included: https://github.com/doctrine/collections/blob/2.1.4/src/ArrayCollection.php

    So this can only be some kind of autoloading bug.

  • πŸ‡ΊπŸ‡ΈUnited States greatmatter

    ...oy. There's the problem. I chose the wrong version for the issue. We're using drupal/address 1.12.0.

    I'm sorry...

  • πŸ‡·πŸ‡ΈSerbia bojanz

    Thanks, updating the affected version.

    However, my point from #6 still stands, the doctrine version looks fine and I can't explain the error, other than possibly relating it to autoloading.

    I can only advise trying to require doctrine/colections ~1.6 or ~2.0 to see if an older branch maybe doesn't exhibit the same problem.

  • Status changed to Closed: outdated 4 months ago
  • I ran into the same issue during a D8 -> D10 upgrade when I updated address to ^2. I'm guessing it's a weird autoload issue because the directory structure of doctrine/collections changes between v1 and v2.

    I tried running composer dump-autoload an composer cc but neither worked. I ended up needing to explicitly require an older version of doctrine/collections in my top-level composer.json (composer require 'doctrine/collections:^1.2') to get things working again.

  • πŸ‡ΊπŸ‡ΈUnited States wheelercreek

    I ran into the same issue - unable to view any orders. We can view the orders list page, but when we try to view an order we're getting this error. I had to downgrade to doctrine/collections 1.8.0 and now it's working.

Production build 0.71.5 2024