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\FileTransferSteps 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
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3308744-8.patch | 3.39 KB | andypost |
| #9 | interdiff.txt | 596 bytes | andypost |
| #4 | 3308744-4.patch | 3.38 KB | andypost |
Issue fork drupal-3308744
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
andypostFix from #3295821-80: Ignore: patch testing issue for PHP 8.2 attributes
Comment #3
andypostfix
Comment #4
andypostfix CS
Comment #5
bbralaLooks simple enough, but i have some questions. They might be overly defensive.
If this is string, shouldn't the default be string? Can be null now.
Same here, it will start NULL right? Shouldn't it have a default?
see above.
Won't this close off any other properties it might get or get set by any extending class? Is that part of the goal?
So any property wouldn't be set? Even if it is? What if this class is extended?
Shouldn't this check for existing propeties and unset if they exist?
Comment #6
bbralaAdding Slack discussion to this issue.
@andypost [12:23 PM]@Björn Brala (bbrala) https://www.drupal.org/i/3308744 also tricky as I can't get why it works at all
// and unserialized between requests, although the FileTransfer object itself
// will be reconstructed, the connection pointer itself will be lost. However,
// the FileTransfer object will still have the connection variable, even
// though the connection itself is now gone. So, although it's ugly, we have
// to unset the connection variable at this point so that the FileTransfer
// object will re-initiate the actual connection.
unset($filetransfer->connection);
Fix the default values to something sane
Make sure the $connection is resource/boolean/string to allow for the different connection types
Comment #7
andypostFixed doc-blocks and removed useless methods, it passes locally using
skilldlabs/php:82docker image with 8.2.0RC2Comment #8
bbralaUnfortunately we do need the isset and unset magic methods, other code depends on that to know what to do.
Comment #9
andypostyes, better to keep it, interdiff vs #4
Comment #10
bbralaI've gone through this pretty extensively. I don't think we need a CR for this, the logic should be the same for the concrete classes.
Comment #12
catchCommitted/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!
Probably a follow-up somewhere to not need all the magic, but this all might become irrelevant when automatic updates is further along.
Comment #14
silverham commentedThis 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. SoDrupal\Core\FileTransfer\FTPExtension->connect()no longer works. @see #3344877: [regression] FTPExtension class can no longer connect as of 9.5.x.Notice: Undefined property: Drupal\Core\FileTransfer\FTPExtension::$connection in Drupal\Core\FileTransfer\FTPExtension->connect() (line 16 of core/lib/Drupal/Core/FileTransfer/FTPExtension.php).