Problem/Motivation
While running the 3.x branch on Drupal 9, the following error is encountered:
Fatal error: Declaration of Drupal\csv_serialization\Encoder\CsvEncoder::encode($data, string $format, array $context = Array): string must be compatible with Symfony\Component\Serializer\Encoder\EncoderInterface::encode($data, $format, array $context = Array) in /var/lib/tugboat/stm/web/modules/contrib/csv_serialization/src/Encoder/CsvEncoder.php on line 125
This is due to the difference in EncoderInterface::encode() signatures between Symfony 4.4 (D9) and Symfony 6.2 (D10).
Proposed resolution
Is there a way to support both or do we need to drop support for Drupal 9 on the 3.x branch?
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | csv_serialization-3344110-29.patch | 1.68 KB | fox mulder |
| #26 | compat_with_encoderInterface_3344110_2.patch | 1.74 KB | nicolas s. |
| #19 | csv_serialization_upgrade_status_message.jpg | 228.27 KB | texas-bronius |
Issue fork csv_serialization-3344110
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
Comment #2
markdorisonComment #3
markdorisonComment #4
markdorisonConversation in Drupal Slack seems to confirm that dropping D9 support from the 3.x branch is the way to go.
Comment #6
markdorisonComment #8
markdorisonComment #10
andras_szilagyi commentedIn symfony 6.2 the signature is:
public function encode(mixed $data, string $format, array $context = []): stringwhile in csv_serialization the signature:
public function encode($data, string $format, array $context = []):stringshouldn't we fix this?
Comment #11
markdorison@Andras If you'd like to create a new issue with an MR for that change, I would be happy to review.
Comment #12
tonytheferg commentedThis not being in the 3.x release causes WSOD on Drupal 9 installations.
Fatal error: Declaration of Drupal\csv_serialization\Encoder\CsvEncoder::encode($data, string $format, array $context = []): string must be compatible with Symfony\Component\Serializer\Encoder\EncoderInterface::encode($data, $format, array $context = []) in /var/www/html/web/modules/contrib/csv_serialization/src/Encoder/CsvEncoder.php on line 125ddev composer require 'drupal/csv_serialization:^3.0' -Winstalled beta.
Comment #13
markdorison@tonytheferg: That beta release must incorrectly declared support for Drupal 9. If you run
composer require drupal/csv_serialization:^2.0 || ^3.0is that beta release still installed?Comment #14
tonytheferg commentedI'll check, that makes sense. Thanks. 👍
Comment #15
bcdev commentedI was getting issues upgrading this module to 3.0 when using a D9 install (currently moving to D10 but needed to upgrade this first). I was seeing the same error when running a drush updatedb:
Using the
composer require drupal/csv_serialization:^2.0 || ^3.0command allowed me to get past this and I'm assuming that this will work for D10 also once I start that upgrade process.Comment #16
webdrips commentedThanks for the tip @bcdev, that worked for me :)
Comment #17
aiphesHello
Thanks @bcdev, applied your tips and seem to be ok now.
Comment #18
bwoods commentedJust a followup for #15 – you will want to include
^2.0 || ^3.0directly in your composer file. Running the listed command will just require 2.0, since composer sees the pipes as a new command. The module will still show in Upgrade Status as needing to be updated, but at least it should be prepped to upgrade after the move to D10.Comment #19
texas-bronius commentedEchoing @bwoods in #18 the instructions given in https://www.drupal.org/project/upgrade_status read:
composer require drupal/csv_serialization:^2.0 || ^3.0whereas actually we need the quotes like:
composer require 'drupal/csv_serialization:^2.0 || ^3.0'or composer.json will not be updated as you'd expect.
Further, if you're already on 2.1, you shouldn't specify just 2.0 but
^2.1 || ^3.0I think. Maybe the best move is less specific, since we don't yet _know_ what the 3.x version will be at the time of finally pulling the trigger:^2.1 || ^3. Is this message dictated by this module or something else?Comment #20
markdorisoncomposer require 'drupal/csv_serialization:^2.0 || ^3.0'Needing to wrap quotes around the module and version probably depends on what shell you are running but the quotes should provide extra safety. Thank you for noting it!
It shouldn't matter. The caret allows all non-breaking (non-major) releases so specifying
^2.0will allow2.1and should not downgrade you. That said, feel free to specify2.1, if you are already on at least2.1there is no harm in it!Specifying
^3.0or^3should result in the same compatibility.Comment #21
nicolas s. commentedI propose this patch to fix error when drush cr
Comment #22
nicolas s. commentedComment #23
nicolas s. commentedComment #24
nicolas s. commentedComment #25
nicolas s. commentedComment #26
nicolas s. commentedComment #27
muthukris commented#19 works perfectly. Thanks @texas-bronius.
Comment #28
dianacastillo commentedthis doesnt work for D10 because the 3xdev doesnt work for d10 and the 4.0 version has the same issue still
Comment #29
fox mulder commentedpatch for ^4.0, I didn't test it