Problem/Motivation

In July 2018, PHP-FIG accepted PSR-17, providing a standard interface to http message factories. The interface for this standard requires PHP 7.0, and most implementations require PHP 7.1. The symfony/psr-http-message-bridge provides a wrapper interface around the message factory, and can be used with our current DiactorosFactory or with PSR-17 compliant factories. Beginning with psr-http-message-bridge v1.2, the non-PSR-17 Diactoros factory is deprecated, in favor of the PsrHttpFactory, which uses PSR-17 factories under the hood.

Proposed resolution

laminas/laminas-diactoros provides a set of PSR-17 standard factories beginning with version 2.0, which can be plugged into the symfony PsrHttpFactory wrapper, however version 2.0 requires PHP 7.1. We should consider switching when we also support a PHP minimum version of 7.1. Because the symfony wrappers have the same interface, there are no BC concerns, and we could do this in Drupal 8.9 if we choose to support a minimum PHP version of 7.1 in Drupal 8.9. Alternatively this could be targeted for Drupal 9.0

A test of this swapout was done in #3039584: The "Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory" class is deprecated since symfony/psr-http-message-bridge 1.2, use PsrHttpFactory instead. and it was found that a direct swap resulted in passed tests with minimal code adjustments

Remaining tasks

Update the vender versions,
Add services for the individual factories
Replace the current factory service with the new service, and pass in the individual factory service
Remove deprecation suppression messages regarding DiactorosFactory being deprecated in symfony/psr-http-message-bridge v1.2

User interface changes

none

API changes

Our message factory would use PSR-17 factories under the hood to build our PSR-7 messages

Data model changes

none

Release notes snippet

Drupal 9 has updated symfony/psr-http-message-bridge to version 2.0.0 so it now uses PSR-17 compliant message factories to create PSR-7 requests and responses. See https://www.drupal.org/node/3119204

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikelutz created an issue. See original summary.

tim.plunkett’s picture

Status: Postponed » Active

Not clear what this is postponed on, sorry if I'm missing something.

mikelutz’s picture

I had it postponed on PHP 7.1 as a minimum supported version.

we could do this in Drupal 8.9 if we choose to support a minimum PHP version of 7.1 in Drupal 8.9. Alternatively this could be targeted for Drupal 9.0

xjm’s picture

Will this issue allow us to drop Diactoros as a dependency?

catch’s picture

At the moment this is for updating to zend-diactoros 2.* rather than replacing it.

Wim Leers’s picture

Per #2917655-44: [9.4.x only] Drop official PHP 7.3 support in Drupal 9.4, it now seems likely that Drupal 8.9 will require PHP 7.1.

Once that becomes not just likely but fact, this would become unblocked (per #3, this has been blocked on PHP 7.1 being the minimum version). But it'd then still be blocked on the 8.9.x branch opening.

Wim Leers’s picture

#2917655-48: [9.4.x only] Drop official PHP 7.3 support in Drupal 9.4 makes it sound less likely again that Drupal 8.9 will require PHP 7.1, which would block this.

Wim Leers’s picture

Title: Replace the DiactrosFactory message factory in symfony/psr-http-message-bridge with a psr17 compliant message factory » Replace the DiactrosFactory message factory in symfony/psr-http-message-bridge with a PSR-17 compliant message factory
Wim Leers’s picture

Title: Replace the DiactrosFactory message factory in symfony/psr-http-message-bridge with a PSR-17 compliant message factory » [PP-1] Replace the DiactorosFactory message factory in symfony/psr-http-message-bridge with a PSR-17 compliant message factory
Status: Active » Postponed

Fixing typo in title, and updating status to make it more clear this is blocked on Drupal core requiring PHP 7.1 as its minimum version.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

Status: Postponed » Active
Related issues: +#3104353: Upgrade to Guzzle 7

7.2 at least required for 9.0 and related issue filed

Berdir’s picture

Title: [PP-1] Replace the DiactorosFactory message factory in symfony/psr-http-message-bridge with a PSR-17 compliant message factory » Replace the DiactorosFactory message factory in symfony/psr-http-message-bridge with a PSR-17 compliant message factory
Version: 8.9.x-dev » 9.1.x-dev
longwave’s picture

longwave’s picture

Status: Active » Needs review
FileSize
12.14 KB

Following #3104015: Replace ZendFramework/* dependencies with their Laminas equivalents this patch takes the upgrade in #3104354: Update Laminas components including Diactoros and work in #3039584: The "Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory" class is deprecated since symfony/psr-http-message-bridge 1.2, use PsrHttpFactory instead. and also upgrades symfony/psr-http-message-bridge to v2.0.0 for good measure. As we need to change service definitions here, for full compatibility with 8.9 can this be committed to 9.0 or do we have to wait until 9.1?

catch’s picture

Version: 9.1.x-dev » 9.0.x-dev
Issue tags: +Needs release manager review

I don't see a reason here to wait until 9.1.x to commit this, there's no API change really, but Berdir moved it up to 9.1 so may have views?

longwave’s picture

FileSize
13.95 KB
1.46 KB

Rerolled, and removed two skipped deprecations that are obsoleted by this patch.

longwave’s picture

FileSize
8.04 KB
longwave’s picture

andypost’s picture

Looks ready except RM-appproval

longwave’s picture

FileSize
8.35 KB

Reroll

xjm’s picture

Priority: Normal » Major
  1. +++ b/core/composer.json
    @@ -41,7 +41,7 @@
    -        "symfony/psr-http-message-bridge": "^1.2.0",
    +        "symfony/psr-http-message-bridge": "^2.0",
    

    This part at least seems totally non-controversial to do in 9.0.x if it's done in time for beta.

  2. +++ b/core/core.services.yml
    @@ -776,8 +776,17 @@ services:
       psr7.http_message_factory:
    -    class: Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory
    +    class: Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory
    +    arguments: ['@psr17.server_request_factory', '@psr17.stream_factory', '@psr17.uploaded_file_factory', '@psr17.response_factory']
    

    It's still possible that this could be disruptive and might need the same thorough testing Wim did previously? Maybe we could split it into a separate issue?

In general, I'd also want to know what Symfony's long-term support plans are for the message bridge, since it's versioned separately from the rest of the Symfony components.

longwave’s picture

FileSize
7.83 KB

Thanks for the review!

#21.2 has to be done if we do #21.1, as DiactorosFactory is removed in symfony/psr-http-message-bridge 2.0.0; this is the backward incompatible part.

Note that this patch also removes two deprecation messages - the DiactorosFactory is considered deprecated, hence its removal in 2.0.0. I don't know Symfony's plans but I can only assume that 2.x will be supported better than 1.x going forwards.

Rerolled patch attached, as composer.lock has changed and the other parts have fuzzed a bit.

catch’s picture

+++ b/core/core.services.yml
@@ -786,8 +786,17 @@ services:
     class: Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory
+  psr17.server_request_factory:
+    class: Laminas\Diactoros\ServerRequestFactory
+  psr17.stream_factory:
+    class: Laminas\Diactoros\StreamFactory
+  psr17.uploaded_file_factory:
+    class: Laminas\Diactoros\UploadedFileFactory
+  psr17.response_factory:
+    class: Laminas\Diactoros\ResponseFactory

I don't think we're using it yet, but these seem like good candidates for defining as internal service definitions.

longwave’s picture

> I don't think we're using it yet, but these seem like good candidates for defining as internal service definitions.

We can set public: false on these I think?

catch’s picture

That sounds good, moving to needs work for that change.

Symfony contracts also has a different version number to the other Symfony components, see https://github.com/symfony/contracts/releases

I assume they're doing this for any new components that are self-contained (but which might be new dependencies for other parts of Symfony, which contracts definitely is).

catch’s picture

Status: Needs review » Needs work
longwave’s picture

Status: Needs work » Needs review
FileSize
7.91 KB
872 bytes

Changed the new services to be public: false

catch’s picture

Status: Needs review » Reviewed & tested by the community

Thanks I think that's all that's left here.

alexpott’s picture

Issue summary: View changes

Updating the issue summary so it references laminas/laminas-diactoros and not zend.

alexpott’s picture

Rerolled as #3117558: 9.0.x core's hash in composer.lock is wrong landed ... the only difference is

2c2
< index b75e457532..14af35207b 100644
---
> index 959558421e..14af35207b 100644
9c9
< -                "reference": "f8e50d64acdddb816b10f83ca307712bd2cd65e5"
---
> -                "reference": "1135d82ca80e22e7f25b1bd9a8613cae5ae06372"
catch’s picture

Opened a ticket to clarify the support cycle. Given we're already using this component I think it's fine to answer before that's answered, so untagging. (Also this doesn't really supply an API as such, so if we had to downgrade during beta due to bad news, it wouldn't be the worst thing, but having to downgrade is less likely than having to upgrade due to dropped support).

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Here's the github issue to track support cycle https://github.com/symfony/psr-http-message-bridge/issues/76

I agree with @catch that getting onto v2 is good for D9 prior to beta.

Committed 05b122f and pushed to 9.0.x. Thanks!

  • alexpott committed 05b122f on 9.0.x
    Issue #3043471 by longwave, catch, Wim Leers, xjm: Replace the...
alexpott’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

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