PHP 8.2 Deprecated function: Creation of dynamic property

Created on 11 January 2024, 11 months ago
Updated 10 September 2024, 3 months ago

Problem/Motivation

After switching to PHP 8.2 the module started throwing the following errors:

Deprecated function: Creation of dynamic property Drupal\drupalauth4ssp\SspHandler::$config is deprecated in Drupal\drupalauth4ssp\SspHandler->__construct() (line 32 of modules/contrib/drupalauth4ssp/src/SspHandler.php).

Deprecated function: Creation of dynamic property Drupal\drupalauth4ssp\SspHandler::$pathMatcher is deprecated in Drupal\drupalauth4ssp\SspHandler->__construct() (line 33 of modules/contrib/drupalauth4ssp/src/SspHandler.php).

Deprecated function: Creation of dynamic property Drupal\drupalauth4ssp\SspHandler::$request is deprecated in Drupal\drupalauth4ssp\SspHandler->__construct() (line 34 of modules/contrib/drupalauth4ssp/src/SspHandler.php).

This is caused by the properties mentioned in the warning not being defined in SspHandler class before they were used. PHP 8.2 deprecated usage of dynamic properties.

Steps to reproduce

Install the module on Drupal 10 with PHP 8.2. The warning will be displayed on every page request.

Proposed resolution

Define mentioned properties in the class.

๐Ÿ“Œ Task
Status

Needs review

Version

2.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡พBelarus spleshka UAE

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

Merge Requests

Comments & Activities

  • Issue created by @spleshka
  • ๐Ÿ‡ง๐Ÿ‡พBelarus spleshka UAE

    Spleshka โ†’ changed the visibility of the branch 3414009-php-8.2-deprecated to hidden.

  • ๐Ÿ‡ง๐Ÿ‡พBelarus spleshka UAE

    Spleshka โ†’ changed the visibility of the branch 3414009-php-8.2-deprecated to active.

  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡ง๐Ÿ‡พBelarus spleshka UAE
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia keshavv India
  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia realityloop

    This resolves the issue on my project.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States khaldoon_masud

    Could you also include Drupal\drupalauth4ssp\SspHandler::$sspSession property. it is also producing the deprecated warning.

    Deprecated function: Creation of dynamic property Drupal\drupalauth4ssp\SspHandler::$sspSession is deprecated in Drupal\drupalauth4ssp\SspHandler->getSspSession() (line 134 of /code/web/modules/contrib/drupalauth4ssp/src/SspHandler.php

  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand RoSk0 Wellington

    Recategorising as this is not really a bug.

    Needs work for #8 and rebase on the latest changes in the 2.x branch which now has GitLab CI configured together with the PHPStan.

    PHPStan base line have all the warning that must be resolved, except those two

    1. Access to constant DRUPALAUTH_EXTERNAL on an unknown class
    2. Access to constant DRUPALAUTH_EXTERNAL_USER_ID on an unknown class
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    samit.310@gmail.com โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    4 months ago
    Total: 129s
    #226573
  • Pipeline finished with Failed
    4 months ago
    Total: 596s
    #226583
  • Pipeline finished with Canceled
    4 months ago
    #226595
  • Pipeline finished with Failed
    4 months ago
    Total: 140s
    #226598
  • Pipeline finished with Success
    4 months ago
    Total: 128s
    #226607
  • Pipeline finished with Failed
    4 months ago
    Total: 143s
    #226615
  • Pipeline finished with Failed
    4 months ago
    #226626
  • Pipeline finished with Success
    4 months ago
    Total: 133s
    #226630
  • Pipeline finished with Failed
    4 months ago
    Total: 135s
    #226679
  • Pipeline finished with Success
    4 months ago
    Total: 131s
    #226684
  • Status changed to Needs review 4 months ago
  • First commit to issue fork.
  • Pipeline finished with Failed
    4 months ago
    Total: 141s
    #228037
  • Pipeline finished with Failed
    4 months ago
    Total: 138s
    #228046
  • Pipeline finished with Success
    4 months ago
    Total: 132s
    #228051
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rex.barkdoll

    I just installed this and it got the error to go away, happy with it working :)

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johan_vm Tilburg

    Made a patch of the latest MR.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johan_vm Tilburg

    The MR only applies on the dev branch, made another patch for 2.0.0-rc1

Production build 0.71.5 2024