Dynamic property deprecated

Created on 22 May 2025, about 1 month ago

Problem/Motivation

Deprecated function: Creation of dynamic property GuzzleHttp\Psr7\Response::$umr_ok is deprecated in _user_mailman_register_parse_http() (line 976 of modules/contrib/user_mailman_register/user_mailman_register.module).

Steps to reproduce

Visit user/*/user_mailman_register using PHP 8.3, see the above error printed twice

Proposed resolution

I'd be happy to submit a patch if it would be accepted. I see many other patches needing review.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States danepowell

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

Comments & Activities

  • Issue created by @danepowell
  • πŸ‡ΊπŸ‡ΈUnited States rclemings

    Please do. I may not be able to test it right away but at least it will be available for anyone who needs it.

    Most if not all of the other patches you see were written by me and have not been reviewed by anyone else. If they work for you and you're comfortable doing so, please mark them RTBC and I can put them in a new release.

  • @danepowell opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States danepowell

    I was a little naive assuming this was a run-of-the-mill deprecation. The module is actually overriding a Drupal HTTP response in a way that breaks encapsulation and requires significant refactoring to fix properly.

    I took a more targeted approach in the linked merge request, which only modifies the affected function and preserves backwards compatibility with the rest of the module. Read: I'm kicking the refactoring can down the road :)

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

    I spun up a site with PHP 8.3.13 and the patch worked, with no obvious harm to a site running PHP 8.1.32, so I've merged it. Thanks.

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

    I'm getting this WSOD intermittently now:

    Error: Call to undefined method stdClass::getStatusCode() in _user_mailman_register_parse_http() (line 1050 of modules/contrib/user_mailman_register/user_mailman_register.module).
    

    I think the problem is this code is in the try and catch blocks just prior but isn't available at line 1050:

        // Add convenience methods
        if ($response) {
          $result->getBody = function() use ($response) {
            return $response->getBody();
          };
          $result->getStatusCode = function() use ($response) {
            return $response->getStatusCode();
          };
        }
    

    I added that code again before line 1050 and it seemed to take care of the error. Does that look right to you? Probably not the best way to address the problem though.

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

    None of this is the best way to address the problem :) I was just trying to avoid a more significant refactor.

    I guess you could define the convenience methods a second time outside the try/catch block. It sounds like you are referencing some specific code, but I don't see that you've made any commits?

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

    rclemings β†’ changed the visibility of the branch 3526170-dynamic-property-deprecated to hidden.

  • @rclemings opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States rclemings

    Unfortunately, I'm still getting sporadic errors, sporadic I guess because the module doesn't need to hit the Mailman site on every request. I can't tell for sure but it looks to me as if the problem lies is in the "convenience methods." So I've tried a different approach, just copying the results of the getBody() and getStatusCode() functions to the $result variable.

        $result->body = $response->getBody();
        $result->statusCode = $response->getStatusCode();
    

    (Lines 992-993 of user_mailman_register.module)

    So far, I'm not seeing any errors with PHP 8.3.13. Fingers cross.

    Let me know if you see a problem with this change.

Production build 0.71.5 2024