Problem/Motivation

Under PHP 8.2, there are a lot of messages like Creation of dynamic property ... is deprecated. For example, see these test results from Webform.

Proposed resolution

Enabled PHP 8.2 testing in Views. Declare all the properties used.

Comments

Liam Morland created an issue. See original summary.

joseph.olstad’s picture

Yes I'm seeing this on the media project automated testing as well hundreds of messages

exception: [Deprecated function] Line 2260 of sites/all/modules/views/includes/view.inc:
Creation of dynamic property views_display::$display_plugin is deprecated

joseph.olstad’s picture

Title: Remove dynamic properties for PHP 8.2 compatibility » Fully support PHP 8.2 - Remove /replace dynamic properties
joseph.olstad’s picture

Here's some of what they were doing in Drupal 10 views to fix this.

commit 0ca45bf57b31087f3a5c2280f871552382b5ba1a
Author: catch <catch@35733.no-reply.drupal.org>
Date:   Tue Jul 26 12:36:10 2022 +0900

    Issue #3299853 by andypost, kim.pepper: Apply #[\AllowDynamicProperties] attribute to base classes to make PHP 8.2 log size sane
    
    (cherry picked from commit db2e2d2544cc0e10fa9f0f17bc26f57db255d1f6)

diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php
index 1d5afc118c9..dca96339738 100644
--- a/core/modules/views/src/Plugin/views/PluginBase.php
+++ b/core/modules/views/src/Plugin/views/PluginBase.php
@@ -37,6 +37,7 @@
  *
  * @ingroup views_plugins
  */
+#[\AllowDynamicProperties]
 abstract class PluginBase extends ComponentPluginBase implements ContainerFactoryPluginInterface, ViewsPluginInterface, DependentPluginInterface, TrustedCallbackInterface {
 
   /**
diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
index 57c18eeee14..14137a8c4f2 100644
--- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
+++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
@@ -150,6 +150,7 @@
  *
  * Extensions of this class can be used to create more interesting joins.
  */
+#[\AllowDynamicProperties]
 class JoinPluginBase extends PluginBase implements JoinPluginInterface {
 
   /**
diff --git a/core/modules/views/src/ResultRow.php b/core/modules/views/src/ResultRow.php
index 30814bf6281..2399f699838 100644
--- a/core/modules/views/src/ResultRow.php
+++ b/core/modules/views/src/ResultRow.php
@@ -5,6 +5,7 @@
 /**
  * A class representing a view result row.
  */
+#[\AllowDynamicProperties]
 class ResultRow {
 
   /**
joseph.olstad’s picture

StatusFileSize
new338 bytes

Try this

joseph.olstad’s picture

Status: Active » Needs review
joseph.olstad’s picture

Title: Fully support PHP 8.2 - Remove /replace dynamic properties » Fully support PHP 8.2 - Fix deprecated dynamic properties
joseph.olstad’s picture

StatusFileSize
new1.38 KB
joseph.olstad’s picture

joseph.olstad’s picture

StatusFileSize
new8.05 KB

New patch

joseph.olstad’s picture

StatusFileSize
new8.41 KB
joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

RTBC on patch 11

the remaining fix needs to be done in ctools.

I need views to work to be able to fix file_entity and media PHP 8.2 compatibility

damienmckenna’s picture

Thanks for working through this.

liam morland’s picture

Adding #[\AllowDynamicProperties] will fix it. A more robust fix is to declare the properties, for example, as done in #3323960: Remove dynamic properties for PHP 8.2 compatibility.

joseph.olstad’s picture

Please expedite review and please tag a release with this fix, it's holding back automated test coverage on the file_entity project, the media and many others. Likely many other contrib projects automated tests will fail until a release with this fix is cut.

AllowDynamicProperties still allows performance optimisation as it's only for some classes, not all.

I think we can move forward with this as-is, any future "improvements" can go into subsequent releases/issues.

joseph.olstad’s picture

I fixed i18n last night and cut a release
entity_translation I just RTBC'd my own patch, it's passing on PHP 8.2

I'll be able to push many more once ctools and views gets patched/tagged/released with fixes.

#3327347: Fully Support PHP 8.2

joseph.olstad’s picture

Oh sorry ya I noticed there's still one failure on PHP 8.2, I have no idea why though, probably unrelated to the changes, it was there previously also.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

That one error suggests there might be another bug somewhere causing the problem. So let's poke it with a stick a little more.

liam morland’s picture

The remaining test failure is a separate issue from the dynamic properties. This issue should be committed to fix the dynamic properties and another issue should be opened for that failure.

joseph.olstad’s picture

I'm guessing that this bug is probably comming from ctools.

Two months ago ctools automated tests fell apart mysteriously unrelated to code commits made to ctools.

I'm thinking we should commit the views patch as-is, then work on ctools, and then come back to views once ctools is fixed.

#3327350: Support PHP 8.2 with ctools

damienmckenna’s picture

Assigned: Unassigned » damienmckenna

I'll look into it tomorrow.

joseph.olstad’s picture

ctools possibly related issue, I uploaded a patch, can't get it to pass though but I'm sure it will pass if the framework was working as it was in august.

There's appears to be a ci bot runner /jenkins problem not caused by ctools but affects ctools.
#3327498: D10 deprecations broke D7 ctools testing since sept 8th-14th 2022

joseph.olstad’s picture

I've completed the entity_translation patch for PHP 8.2
#3327347-33: Fully Support PHP 8.2

@DamienMcKenna

Seeing as (patch #11 above) does not cause testing regressions on versions lower than PHP 8.2, could we just go ahead and push it in right away "as-is" so that I/we can continue working on file_entity and media and other modules that require/utilise views?

then once the ctools fixes land, we can follow up with a new issue to deal with the tests/styles/views_plugin_style_jump_menu.test .

For the sake of expediting progress, my vote is to push in patch #11 as-is, even publish a release with it if necessary, foollow up with the other fix after.

This way we can work on fixes for modules "other than" ctools that depend on views and at least move those forward quickly and come back and resolve all the issues after.

joseph.olstad’s picture

StatusFileSize
new60.55 KB

so, we can push in #11 as a stop-gap improvement, and then more slowly and over more time, work on an improvement to this issue.

I did a sort on the errors from the tests
and then used the uniq command to remove duplicates

see which properties would have to be added, not clear which classes but could be figured out.

#3327347-33: Fully Support PHP 8.2

damienmckenna’s picture

Status: Needs work » Fixed

Committed. Thanks.

Let's do separate issues if any other problems show up.

damienmckenna’s picture

Assigned: damienmckenna » Unassigned

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture

ah yes, still one fail, looks like it's because of ctools.

https://www.drupal.org/project/ctools/issues/3327350

Someone has to bark up the ctools tree.

I've got media, media_youtube, i18n, entity_translation and smtp to pass on PHP 8.2

Hopefully we can get ctools and whatever else going

I'm going to look into file_entity, it might work now due to the views fixes, going to trigger tests.

damienmckenna’s picture

FYI I updated the automated tests to use PHP 8.2 instead of 8.1.