Problem/Motivation

There are multiple dynamic properties declared in various tests classes, see: https://www.drupal.org/pift-ci-job/2522871. This issue aims to fix all of them (strictly only in tests).

Steps to reproduce

Run simpletest on PHP 8.2

Proposed resolution

Define dynamic properties correctly.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#5 interdiff-2_4.txt1.46 KBpoker10
#4 3322003-4.patch36.75 KBpoker10
#2 3322003-2.patch36.47 KBpoker10

Comments

poker10 created an issue. See original summary.

poker10’s picture

Status: Active » Needs review
StatusFileSize
new36.47 KB

Adding a patch which should declare hopefully all of them.

I have not added comments to the properties, because there are minimum properties with comments in tests currently. Also once have used the #[AllowDynamicProperties] on the FakeRecord class. But all others are declared correctly (no #[AllowDynamicProperties]).

Let's check the testbot.

Status: Needs review » Needs work

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

poker10’s picture

Status: Needs work » Needs review
StatusFileSize
new36.75 KB

It seems like that filetransfer properties should be defined in the FileTransfer class, so removing them. Also added two missed declarations.

poker10’s picture

StatusFileSize
new1.46 KB

Forgot to add an interdiff..

mcdruid’s picture

Also once have used the #[AllowDynamicProperties] on the FakeRecord class. But all others are declared correctly

I've not looked closely, but why are we doing this in just this one class?

poker10’s picture

The FakeRecord class looks like this:

/**
 * Dummy class for fetching into a class.
 *
 * PDO supports using a new instance of an arbitrary class for records
 * rather than just a stdClass or array. This class is for testing that
 * functionality. (See testQueryFetchClass() below)
 */
class FakeRecord { }

It seems to me that anything can be fetched to the properties of this class. So I have not chosen to declare the three currently problematic properties:

exception: [Deprecated] Line 442 of modules/simpletest/tests/database_test.test:
Creation of dynamic property FakeRecord::$name is deprecated
	
exception: [Deprecated] Line 461 of modules/simpletest/tests/database_test.test:
Creation of dynamic property FakeRecord::$name is deprecated

exception: [Deprecated] Line 461 of modules/simpletest/tests/database_test.test:
Creation of dynamic property FakeRecord::$job is deprecated

But instead generally marked the class with the #[AllowDynamicProperties] (potentially to the future).

  • mcdruid committed 64871d4 on 7.x
    Issue #3322003 by poker10: [D7 PHP 8.2] Fix Deprecated function:...
mcdruid’s picture

Status: Needs review » Fixed

Makes sense, thanks!

I made one change on commit - s/An/A

+  /**
+   * An forum to delete.
+   */
+  protected $delete_forum;

Status: Fixed » Closed (fixed)

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