The commerceguys/addressing has added some PHP 7.3 compatible type hints in the current 1.4.0 version, affecting some class overrides of the address module:

https://github.com/commerceguys/addressing/commit/c81ded457fa0cc7d2c9f5b...

This leads to errors like this:

PHP Fatal error: Declaration of Drupal\address\Repository\AddressFormatRepository::processDefinition($countryCode, array $definition) must be compatible with CommerceGuys\Addressing\AddressFormat\AddressFormatRepository::processDefinition(string $countryCode, array $definition): array in /app/web/modules/contrib/address/src/Repository/AddressFormatRepository.php on line 38

should be sufficient to search the code base for "extends External" and have a look at those implementations. I'm lacking time this evening unfortunately - otherwise I'd provide a patch

Issue fork address-3302484

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

agoradesign created an issue. See original summary.

mglaman made their first commit to this issue’s fork.

mglaman’s picture

Status: Active » Needs review

Ran phpstan, these came back as errors.

mglaman’s picture

Status: Needs review » Needs work

Something is still broken in the widget. Needs manual review, I just used PHPStan @ level 2 to check.

pookmish’s picture

Priority: Normal » Major

Raising priority level.

greatmatter’s picture

For those landing here after running an update:

Check to see the version of commerceguys/addressing. If it's 1.4.0, try downgrading to 1.3.0.
composer show | grep addressing

composer require "commerceguys/addressing:1.3.0"

mglaman’s picture

Another quick fix:

    "conflict": {
        "drupal/drupal": "*",
        "commerceguys/addressing": ">=1.4.0"
    },
cobadger’s picture

Assigned: Unassigned » cobadger
Status: Needs work » Active

Patch forthcoming.

cobadger’s picture

Assigned: cobadger » Unassigned
Status: Active » Needs review
StatusFileSize
new1.76 KB

Patch attached.

Status: Needs review » Needs work
danrod’s picture

Patch #10 works for me, thanks for posting this, I just had this issue when trying to do "drush updatedb" after I did a major update with "composer update"

jsacksick’s picture

Patch still has issues:

The test is failing due to:

TypeError: CommerceGuys\Addressing\Validator\Constraints\AddressFormatConstraintValidator::validatePostalCode(): Argument #1 ($postalCode) must be of type string, null given, called in /var/www/html/vendor/commerceguys/addressing/src/Validator/Constraints/AddressFormatConstraintValidator.php on line 82 in CommerceGuys\Addressing\Validator\Constraints\AddressFormatConstraintValidator->validatePostalCode() (line 129 of /var/www/html/vendor/commerceguys/addressing/src/Validator/Constraints/AddressFormatConstraintValidator.php)
jsacksick’s picture

Status: Needs work » Needs review
StatusFileSize
new3.9 KB

The attached patch should fix the tests. Not 100% sure it's the right fix, but it fixes the test at least.

jsacksick’s picture

StatusFileSize
new4.76 KB
jsacksick’s picture

StatusFileSize
new4.76 KB
mglaman’s picture

AddressItem fields fetching property values should do ?? '' to handle null values, so that strings are always returned. At least for mandatory items.

jsacksick’s picture

StatusFileSize
new6.58 KB
jsacksick’s picture

StatusFileSize
new6.63 KB

Forgot a getter.

  • jsacksick committed 01cdc9b on 8.x-1.x
    Issue #3302484 by bojanz, jsacksick, mglaman, COBadger: commerceguys/...
bojanz’s picture

Status: Needs review » Reviewed & tested by the community

Boom.

jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks everyone!

lindsay.wils’s picture

Hi everyone. Thanks for the work here. Assuming this fix has just been added to the latest dev release? I have one site still on D8 and am seeing this issue also. Any chance someone has patched address 1.9 as yet?

Thanks

greatmatter’s picture

Anyone who did #7 - make sure you

composer remove commerceguys/addressing

...to allow the dependency to work. It'll probably throw an error:
"Removal failed, commerceguys/addressing is still present, it may be required by another package. See `composer why commerceguys/addressing`." but in my case, at least, the "remove" command updated it to 1.4.1.

YMMV.

Status: Fixed » Closed (fixed)

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

makkus183’s picture

Same here as in #23

devkinetic’s picture

For D8, as noted in #3302485: Fatal Error: commerceguys\addressing, it seems the best thing to do is roll back to 1.3.0.

goz’s picture

StatusFileSize
new5.77 KB

For people who are still in D8 and use the 8.x-1.9 module version, here is a patch to apply, based on commit #20 which only fix types.

tichris59’s picture

Goz, I used with success your patch in Drupal 8.9 thanks !

steveoriol’s picture

Thank you Goz !

drattar’s picture

i don't solve it by Downgrading commerceguys/addressing.

however i face similar error, but with small differences

Fatal error: Declaration of Drupal\address\Repository\CountryRepository::loadDefinitions($locale) must be compatible with CommerceGuys\Addressing\Country\CountryRepository::loadDefinitions(string $locale): array in /home/***/public/modules/contrib/address/src/Repository/CountryRepository.php on line 43

instead on line 38.
my issue are here

And also, Goz Patch doesn't work.

todd zebert’s picture

I agree with dratta that the 3302484-28-for-8.x-1.9.patch in #28 does not work, at least not with 'drupal/address:1.9' and the resulting "commerceguys/addressing":"v1.4.2" (resulting from the module's composer.json's requirement of "commerceguys/addressing": "^1.0.7".

todd zebert’s picture

This patch is for 'drupal/address:1.9' (last D8 module) and the resulting Composer dependency "commerceguys/addressing":"v1.4.x", tested and working.

gumdal’s picture

Thank you Goz, #28 worked for me!