solspace / craft-freeform

Freeform for Craft: The most reliable form builder that's ready for wherever your project takes you.
https://docs.solspace.com/craft/freeform/v5/
Other
47 stars 60 forks source link

Freeform downgraded to 4.0.8 when updating to Craft 4.5 #791

Closed jrrdnx closed 1 year ago

jrrdnx commented 1 year ago

Freeform 4 was downgraded from 4.1.6 to 4.0.8 when running composer update to update Craft 4.4.17 to 4.5.1. I haven't run into anything like this before, so I'm not exactly sure what the reason for this is. Running composer update again has no affect (Nothing to install, update or remove) and Utilities -> Updates now lists all versions of Freeform from 4.0.9 to 4.1.6.

Steps to reproduce

  1. Run composer update
  2. Find Craft has updated to 4.5.1 while Freeform was downgraded to 4.0.8

Expected behavior

No downgrading of Freeform

Craft & Plugin Info (please complete the following information):

Additional context

composer.json:

"solspace/craft-freeform": "^4.0.0",

CLI output from running composer update:

craft % composer update
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 0 installs, 7 updates, 4 removals
  - Removing maennchen/zipstream-php (2.4.0)
  - Removing markbaker/complex (3.0.2)
  - Removing markbaker/matrix (3.0.1)
  - Removing phpoffice/phpspreadsheet (1.25.2)
  - Upgrading aws/aws-sdk-php (3.278.3 => 3.279.5)
  - Upgrading composer/composer (2.2.19 => 2.2.21)
  - Upgrading craftcms/cms (4.4.17 => 4.5.1)
  - Upgrading guzzlehttp/promises (1.5.3 => 2.0.1)
  - Upgrading psr/http-message (1.1 => 2.0)
  - Downgrading solspace/craft-freeform (4.1.6 => 4.0.8)
  - Upgrading yiisoft/yii2 (2.0.47 => 2.0.48.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 7 updates, 4 removals
  - Downloading craftcms/cms (4.5.1)
  - Downloading yiisoft/yii2 (2.0.48.1)
  - Downloading psr/http-message (2.0)
  - Downloading composer/composer (2.2.21)
  - Downloading aws/aws-sdk-php (3.279.5)
  - Downloading solspace/craft-freeform (4.0.8)
  - Removing phpoffice/phpspreadsheet (1.25.2)
  - Removing markbaker/matrix (3.0.1)
  - Removing markbaker/complex (3.0.2)
  - Removing maennchen/zipstream-php (v2.4.0)
  - Upgrading craftcms/cms (4.4.17 => 4.5.1): Extracting archive
  - Upgrading yiisoft/yii2 (2.0.47 => 2.0.48.1): Extracting archive
  - Upgrading psr/http-message (1.1 => 2.0): Extracting archive
  - Upgrading guzzlehttp/promises (1.5.3 => 2.0.1): Extracting archive
  - Upgrading composer/composer (2.2.19 => 2.2.21): Extracting archive
  - Upgrading aws/aws-sdk-php (3.278.3 => 3.279.5): Extracting archive
  - Downgrading solspace/craft-freeform (4.1.6 => 4.0.8): Extracting archive
jrrdnx commented 1 year ago

Apparently the Craft update upgraded psr/http-message to v2, but a dependency of phpoffice/phpspreadsheet is still requiring v1:

Problem 1
    - maennchen/zipstream-php[2.1.0, ..., 2.4.0] require psr/http-message ^1.0 -> found psr/http-message[1.0, 1.0.1, 1.1] but the package is fixed to 2.0 (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.
    - solspace/craft-freeform 4.1.6 requires phpoffice/phpspreadsheet 1.25.2 -> satisfiable by phpoffice/phpspreadsheet[1.25.2].
    - phpoffice/phpspreadsheet 1.25.2 requires maennchen/zipstream-php ^2.1 -> satisfiable by maennchen/zipstream-php[2.1.0, ..., 2.4.0].
    - Root composer.json requires solspace/craft-freeform 4.1.6 -> satisfiable by solspace/craft-freeform[4.1.6].
kjmartens commented 1 year ago

Hi @jrrdnx,

Sorry for the trouble you're experiencing.

I just tried this out myself (using composer update and updating from Craft 4.4.16.1 => 4.5.1 while on Freeform 4.1.6), and it worked without issue.

Which version of PHP are you using and what does your entire main composer.json file look like? 🙂

jrrdnx commented 1 year ago

We're using PHP 8.2.7 on this project.

I was able to run composer update with the -W flag to downgrade psr/http-message and get Freeform back to 4.1.6, so everything is back to working order now. But I am interested if I'm doing something different that would cause the discrepancy in behavior between you and I.

composer.json:

{
  "require": {
    "craftcms/cms": "^4.4.0",
    "craftcms/feed-me": "^5.2",
    "craftcms/redactor": "^3.0.0",
    "diginov/craft-sentry-logger": "^4.1.0",
    "jrrdnx/craft-cloudflare-r2": "^1.0",
    "mmikkel/cp-field-inspect": "^1.4.0",
    "nystudio107/craft-retour": "^4.1.0",
    "nystudio107/craft-seomatic": "^4.0.0",
    "nystudio107/craft-vite": "^4.0.0",
    "panlatent/schedule": "0.4.0.1",
    "putyourlightson/craft-blitz-recommendations": "^2.1.0",
    "putyourlightson/craft-sherlock": "^4.3.0",
    "reusser/craft-sso": "dev-main",
    "sebastianlenz/linkfield": "^2.1.0",
    "solspace/craft-calendar": "^4.0",
    "solspace/craft-freeform": "^4.0.0",
    "spicyweb/craft-embedded-assets": "^3.1.0",
    "spicyweb/craft-neo": "^3.7.0",
    "utakka/redactor-anchors": "^1.4",
    "verbb/expanded-singles": "^2.0.0",
    "verbb/super-table": "^3.0.0",
    "vlucas/phpdotenv": "^5.4.0"
  },
  "require-dev": {
    "craftcms/generator": "^1.2",
    "yiisoft/yii2-shell": "^2.0.3"
  },
  "autoload": {
    "psr-4": {
      "reusser\\": "modules/"
    }
  },
  "config": {
    "allow-plugins": {
      "craftcms/plugin-installer": true,
      "yiisoft/yii2-composer": true,
      "php-http/discovery": true
    },
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "8.2.1"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  },
  "repositories": [
    {
      "type": "path",
      "url": "./plugins/*",
      "options": {
        "symlink": true
      }
    },
    {
      "type": "vcs",
      "url": "..."
    }
  ]
}

Also, in case it helps, running composer depends psr/http-message outputs:

aws/aws-sdk-php          3.279.6 requires psr/http-message (^1.0 || ^2.0) 
guzzlehttp/psr7          2.6.0   requires psr/http-message (^1.1 || ^2.0) 
maennchen/zipstream-php  2.4.0   requires psr/http-message (^1.0)         
php-http/client-common   2.7.0   requires psr/http-message (^1.0 || ^2.0) 
php-http/httplug         2.4.0   requires psr/http-message (^1.0 || ^2.0) 
php-http/message         1.16.0  requires psr/http-message (^1.1 || ^2.0) 
php-http/message-factory 1.1.0   requires psr/http-message (^1.0 || ^2.0) 
psr/http-client          1.0.2   requires psr/http-message (^1.0 || ^2.0) 
psr/http-factory         1.0.2   requires psr/http-message (^1.0 || ^2.0) 

So maennchen/zipstream-php is the only package not requiring v1 or v2 of psr/http-message. phpoffice/phpspreadsheet is the only package requiring maennchen/zipstream-php, with solspace/craft-freeform the only package requiring phpoffice/phpspreadsheet.

kjmartens commented 1 year ago

Thanks for the extra information, @jrrdnx.

Looking further into it, I can see that phpoffice/phpspreadsheet requires: "maennchen/zipstream-php": "^2.1 || ^3.0",

Then, maennchen/zipstream-php v2 (PHP ^8.0) requires: "psr/http-message": "^1.0",

While maennchen/zipstream-php v3 (PHP ^8.1) suggests (not requires): "psr/http-message": "^2.0",

I suppose that a fresh composer install instead of running composer update would have still had the maennchen/zipstream-php v1 chosen, as all of the others offer both and would downgrade themselves.

That said, I see that we lock phpoffice/phpspreadsheet in at v1.25.2, which doesn't yet include the "maennchen/zipstream-php": "^2.1 || ^3.0", fix. I will check and see if we can update phpoffice/phpspreadsheet to v1.29.0, as it seems to include it at that point:

https://github.com/PHPOffice/PhpSpreadsheet/commit/dbba80255562892845249f9e9e9c7c014eda547f

kjmartens commented 1 year ago

This should be resolved as of 4.1.7+. 🙂