Remove AllowDynamicProperties attribute from views/PluginBase

Created on 25 July 2022, over 2 years ago
Updated 27 February 2023, almost 2 years ago

Problem/Motivation

part of 🌱 [META] Get rid of #[\AllowDynamicProperties] attribute Active
Remove attribute added in #3299853: Apply #[\AllowDynamicProperties] attribute to base classes to make PHP 8.2 log size sane β†’ for PluginBase

Proposed resolution

provide API (probably magic __get()/__set()) to add properties to views plugins dynamically

Remaining tasks

- agree
- patch/review/commit

User interface changes

no

API changes

TBD

Data model changes

no

Release notes snippet

no

πŸ“Œ Task
Status

Fixed

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 11 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.

  • πŸ‡«πŸ‡·France andypost

    As \Drupal\views\ViewExecutable::_preQuery() assigning position property for every views' plugin I moved the definition to PluginBase as the property was added to \Drupal\views\Plugin\views\argument\ArgumentPluginBase::$position in πŸ“Œ Fix 'Access to an undefined property' PHPStan L0 errors - public properties Fixed

    Patch should fix a lot of tests

  • πŸ‡«πŸ‡·France andypost

    Checking remains, the $render_tokens which is used only by \Drupal\views\Plugin\views\field\FieldPluginBase so renamed and looking for reviews

     2x: Creation of dynamic property Drupal\views\Plugin\views\style\DefaultStyle::$render_tokens is deprecated
        2x in RevisionRelationshipsTest::testBlockContentRevisionRelationship from Drupal\Tests\block_content\Kernel\Views
    
  • πŸ‡«πŸ‡·France andypost

    And a bit more

      2x: Creation of dynamic property Drupal\views\Plugin\views\argument\StringArgument::$validated_title is deprecated
        1x in ArgumentValidatorTermNameTest::testArgumentValidatorTermName from Drupal\Tests\taxonomy\Kernel\Views
        1x in ArgumentValidatorTermNameTest::testArgumentValidatorTermNameAccess from Drupal\Tests\taxonomy\Kernel\Views
    
      1x: Creation of dynamic property Drupal\taxonomy\Plugin\views\argument\IndexTid::$validated_title is deprecated
        1x in ArgumentValidatorTermTest::testArgumentValidatorTerm from Drupal\Tests\taxonomy\Kernel\Views
    

    and

      2x: Creation of dynamic property Drupal\user\Plugin\views\filter\Permissions::$tableAliases is deprecated
        2x in HandlerFilterPermissionTest::testFilterPermission from Drupal\Tests\user\Kernel\Views
    
    1) Drupal\Tests\views\Functional\Plugin\ContextualFiltersStringTest::testUserRoleContextualFilter
    Exception: Deprecated function: Creation of dynamic property Drupal\user\Plugin\views\argument\RolesRid::$tableAliases is deprecated
    Drupal\views\ManyToOneHelper->ensureMyTable()() (Line: 214)
    
    1) Drupal\Tests\views\Functional\Plugin\ExposedFormCheckboxesTest::testExposedIsAllOfFilter
    Exception: Deprecated function: Creation of dynamic property Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::$tableAliases is deprecated
    Drupal\views\ManyToOneHelper->ensureMyTable()() (Line: 214)
    
  • πŸ‡«πŸ‡·France andypost

    Attempt to fix, looks better to split every property into own issue

  • πŸ‡«πŸ‡·France andypost

    It's an array of strings

  • Status changed to Needs work almost 2 years ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    @andypost asked me to chime in with an opinion, so here it is.

    +++ b/core/modules/views/src/Plugin/views/PluginBase.php
    @@ -107,6 +106,16 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
    +   * The handler position.
    +   *
    +   * @see \Drupal\views\ViewExecutable::_preQuery()
    +   * @see \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getValue()
    +   * @see \Drupal\views\Plugin\views\display\DisplayPluginBase::renderArea()
    +   * @see template_preprocess_views_view_summary()
    

    These @see everywhere are very helpful now, but will at some point get hopelessly outdated since we will never ever remember to update them when the code being referred to changes for whatever reason. So do we really want these? No idea how they were done in other issues like this one.

    I'm fine with renaming the variables to camelcase, but this could be considered a BC break. This being Views, there is a high possibility that somebody somewhere is making use of these variables under their current name in a way we don't expect.
    Will a change record suffice or should we do deprecation errors (which might be tricky)? We need an answer on that.

    Setting to needs work to get a documented decision on these questions.

  • πŸ‡«πŸ‡·France andypost

    There's some usage in contrib

    - http://codcontrib.hank.vps-private.net/search?text=validated_title
    - http://codcontrib.hank.vps-private.net/search?text=render_tokens

    so I reverted it and tuned docblocks, let's see if sniffers will allow it (I gonna explore DeprecatedServicePropertyTrait meantime)

    That's looks minimal patch

    let's do rename via πŸ“Œ [META] Rename Views properties to core standards Closed: duplicate

  • Status changed to Needs review almost 2 years ago
  • πŸ‡«πŸ‡·France andypost

    Specific follow-ups are

    - validated_title existing πŸ“Œ In ArgumentPluginBase Rename Views properties to core standards Postponed
    - render_tokens filed πŸ“Œ In StylePluginBase Rename Views properties to core standards Needs work

  • Status changed to RTBC almost 2 years ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Nice and minimal and the follow ups look good to me.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Committed ab9bb57 and pushed to 10.1.x. Thanks!

  • Status changed to Fixed almost 2 years ago
    • catch β†’ committed ab9bb579 on 10.1.x
      Issue #3299858 by andypost, Lendude: Remove AllowDynamicProperties...
  • πŸ‡¬πŸ‡§United Kingdom catch
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024