Fix magic connection property access from \Drupal\Core\FileTransfer\FileTransfer::__get()

Created on 9 September 2022, over 2 years ago
Updated 3 May 2024, 8 months ago

Problem/Motivation

Part of #3275851: [META] Fix PHP 8.2 dynamic property deprecations

This method (and connection opening) working because the $connection property is not defined on the class, so magic getter can attempt connection and save it into property which should be named diffent.

Testing Drupal\Tests\system\Functional\FileTransfer\FileTransferTest
.                                                                   1 / 1 (100%)

Time: 00:04.673, Memory: 4.00 MB

OK (1 test, 3 assertions)

Unsilenced deprecation notices (1)

  1x: Creation of dynamic property Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer::$connection is deprecated
    1x in FileTransferTest::testJail from Drupal\Tests\system\Functional\FileTransfer

Steps to reproduce

Run Drupal\Tests\system\Functional\FileTransfer\FileTransferTest test on PHP 8.2 using cumulative patch #3295821-80: Ignore: patch testing issue for PHP 8.2 attributes
and at CI https://dispatcher.drupalci.org/job/drupal_patches/147180/testReport/jun...

Proposed resolution

Fix test and define missing property

Remaining tasks

patch/review/commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

🐛 Bug report
Status

Fixed

Version

9.5

Component
File system 

Last updated about 9 hours ago

Created by

🇫🇷France andypost

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia silverham

    This fix is now causing a regression, as $object->connect() is called recursively and nested calls to PHP magic methods with the same parameters are ignored by PHP engine. So Drupal\Core\FileTransfer\FTPExtension->connect() no longer works. @see 🐛 [regression] FTPExtension class can no longer connect as of 9.5.x Needs work .

    Notice: Undefined property: Drupal\Core\FileTransfer\FTPExtension::$connection in Drupal\Core\FileTransfer\FTPExtension->connect() (line 16 of core/lib/Drupal/Core/FileTransfer/FTPExtension.php).

  • First commit to issue fork.
Production build 0.71.5 2024