Deprecated function: Creation of dynamic property (with php 8.2)

Created on 19 October 2023, about 1 year ago

Problem/Motivation

On a host running PHP 8.2 (with display of error messages enabled), every very time a CSV is imported, a PHP deprecated function message is as follows appear:

Deprecated function: Creation of dynamic property Drupal\user_csv_import\Form\UserCsvImportForm::$file is deprecated in Drupal\user_csv_import\Form\UserCsvImportForm->validateForm() (line 316 of modules/contrib/user_csv_import/src/Form/UserCsvImportForm.php).

Repeat the above after changing your host's PHP version to 8.1 and you should see no messages about the issue.

Steps to reproduce

  1. Have your host running PHP 8.2.
  2. Under "Logging and errors", select Error messages to display: "All messages, with backtrace information".
  3. Install and enable User CSV Import.
  4. Navigate to Manage ยป People.
  5. Press "+ Import users from CSV".
  6. Press "Import users" (bottom of screen).
  7. See the PHP deprecated function message.

Proposed resolution

According to this document on php.net, creation of dynamic properties is deprecated.

Background: php.watch.

We need to update the code to be compatible with PHP 8.2.

๐Ÿ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ดNorway gisle Norway

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024