Problem/Motivation

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

This issue intended to define all undefined properties on base classes added in #3299853: Apply #[\AllowDynamicProperties] attribute to base classes to make PHP 8.2 log size sane

Proposed resolution

Fix all child issues to safely remove the attribute

Remaining tasks

  1. core/modules/views/src/ResultRow.php #3275858: View's ResultRow uses deprecated dynamic properties
  2. core/lib/Drupal/Core/Extension/Extension.php #2024043: Add Module, Theme, Profile, and Extension value objects
  3. core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php #3299857: [PP-1] Remove AllowDynamicProperties attribute from ConfigEntityBase
  4. core/modules/views/src/Plugin/views/PluginBase.php #3299858: Remove AllowDynamicProperties attribute from views/PluginBase
  5. core/modules/views/src/Plugin/views/join/JoinPluginBase.php #3299859: Remove AllowDynamicProperties attribute from JoinPluginBase

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

andypost’s picture

Status: Postponed » Active

As attributes added

andypost’s picture

longwave’s picture

Maybe even that parent can be closed now we are hopefully green on PHP 8.2? This issue technically doesn't have to be completed until PHP 9.

andypost’s picture

Issue tags: +PHP 9.0

Great point! Let's introduce new tag

effulgentsia’s picture

Why are we assuming that PHP 9 will deprecate the #[\AllowDynamicProperties] attribute? Is there any official statement about that? I have not seen that.

I think this meta issue is still worth doing, but I'm unclear as to why it's a requirement for either PHP 8.2 or PHP 9.0 compatibility.

Berdir’s picture

> Why are we assuming that PHP 9 will deprecate the #[\AllowDynamicProperties] attribute? Is there any official statement about that? I have not seen that.

I remember seeing something about this being discussed. but that might be outdated. https://wiki.php.net/rfc/deprecate_dynamic_properties explicitly states that this will not be removed, at least that's how I interpret it.

And yes, it's definitely not a PHP 8.2 blocker.

But many of the attributes that we added also cause bad DX (e.g. the undocumented $entity->original property), so in most cases, we do want to get rid of it.

catch’s picture

Yeah so far there's no indication that they'll deprecate it, but it doesn't seem impossible that they will, so cutting down the number of places it's used like $entity->original seems good. But we might want to leave it for things like plugin annotations until we actually hear it's going to be deprecated if it's complicated to remove there.

longwave’s picture

I think I initially misunderstood this attribute as hiding the deprecation in PHP 8.x and that the hard error would occur in PHP 9 either way. But yes for better DX we should declare all properties where possible.

andypost’s picture

for better DX we should declare all properties where possible.

Lots of fixes could be extracted from #3295821: Ignore: patch testing issue for PHP 8.2 attributes

But things like ResultRow hopefully could be caught with phpstan or other static analysis tools just not clear how to apply it for contrib and custom codebase or provide a "shim" as we have few 10.x minors ahead

andypost’s picture

queued for all 5 issues patches to get baseline for failed tests

andypost’s picture

andypost’s picture

andypost’s picture

Issue summary: View changes

ordered list in IS

andypost’s picture

Version: 10.0.x-dev » 10.1.x-dev
FileSize
592 bytes

testing patch for UserSession

andypost’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.