Problem/Motivation

We are creating dynamic properties in the FileTransfer class:

exception: [Deprecated] Line 23 of includes/filetransfer/filetransfer.inc:
Creation of dynamic property TestFileTransfer::$jail is deprecated

exception: [Deprecated] Line 319 of includes/filetransfer/filetransfer.inc:
Creation of dynamic property TestFileTransfer::$chroot is deprecated

exception: [Deprecated] Line 117 of modules/simpletest/tests/filetransfer.test:
Creation of dynamic property TestFileTransfer::$connection is deprecated

exception: [Deprecated function] Line 23 of includes/filetransfer/filetransfer.inc:
Creation of dynamic property FileTransferFTPExtension::$jail is deprecated

Steps to reproduce

Run simpletest on PHP 8.2.

Proposed resolution

Declare these properties.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#4 interdiff-2_4.txt683 bytespoker10
#4 3322009-4.patch674 bytespoker10
#2 3322009-2.patch507 bytespoker10

Comments

poker10 created an issue. See original summary.

poker10’s picture

Status: Active » Needs review
StatusFileSize
new507 bytes

Let's see what the testbot says.

Status: Needs review » Needs work

The last submitted patch, 2: 3322009-2.patch, failed testing. View results

poker10’s picture

Status: Needs work » Needs review
StatusFileSize
new674 bytes
new683 bytes

The "problem" is, that the FileTransfer class uses the magic __get() method for $chroot and $connection properties.

  function __get($name) {
    if ($name == 'connection') {
      $this->connect();
      return $this->connection;
    }

    if ($name == 'chroot') {
      $this->setChroot();
      return $this->chroot;
    }
  }

If we declare them in the class, this magic method would not be called, $connection would not be initialized and that is the failure above.

Probably the easiest solution is to mark that class with #[AllowDynamicProperties] (see the patch), but it is only workaround. There are also other solutions, but these will need to change the magic method and it will be a bigger change, so it is questionable.

  • mcdruid committed 64d8e38 on 7.x
    Issue #3322009 by poker10: [D7 PHP 8.2] Deprecated function: Creation of...
mcdruid’s picture

Status: Needs review » Fixed

I agree that keeping the changes to a minimum makes sense here.

Thanks!

Status: Fixed » Closed (fixed)

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