Problem/Motivation

part of #3299855: [META] Get rid of #[\AllowDynamicProperties] attribute
Remove attribute added in #3299853: Apply #[\AllowDynamicProperties] attribute to base classes to make PHP 8.2 log size sane for JoinPluginBase

The test to catch it is \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testWorkspaces()

Unsilenced deprecation notices (24)

  24x: Creation of dynamic property Drupal\views\Plugin\views\join\Standard::$workspace_adjusted is deprecated
    24x in WorkspaceIntegrationTest::testWorkspaces from Drupal\Tests\workspaces\Kernel

Proposed resolution

Use WeakMap inside of \Drupal\workspaces\ViewsQueryAlter as this pseudo-service is re-created for each query alter hook, see workspaces_views_query_alter()

Remaining tasks

- agree
- patch/review/commit

User interface changes

no

API changes

TBD

Data model changes

no

Release notes snippet

no

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
StatusFileSize
new518 bytes
andypost’s picture

StatusFileSize
new439 bytes
new957 bytes

WIP

anchal_gupta’s picture

StatusFileSize
new2.09 KB
new476 bytes

I have Fixed CS error. Please Review

andypost’s picture

Thanks fixing my patch but looks you're added unrelated hunk

+++ b/core/tests/Drupal/FunctionalTests/EventSubscriber/MainContentViewSubscriberTest.php
@@ -0,0 +1,37 @@
+  public function testOnRedirectResponse(): void {
+    $this->drupalLogin($this->rootUser);
+    $this->drupalGet("/user?_wrapper_format=drupal_dialog");
+    $this->assertSession()->addressEquals('/user%3F_wrapper_format%3Ddrupal_dialog');

this test is not related here

andypost’s picture

Issue summary: View changes
StatusFileSize
new2.31 KB

Looks that's the only way to fix it with BC

But I'd like to change the property name to workspaceAdjasted so __get()/__set() could be needed

andypost’s picture

Version: 10.0.x-dev » 10.1.x-dev
StatusFileSize
new1.98 KB
new3.18 KB

I find it ready now

Status: Needs review » Needs work

The last submitted patch, 7: 3299859-7.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review

random failure, needs review

longwave’s picture

Does this need to be a property on the join? Could we add a property to the ViewsQueryAlter class that caches the altered objects?

+++ b/core/modules/workspaces/src/Plugin/views/join/Standard.php
@@ -0,0 +1,26 @@
+class Standard extends ViewsStandard {

Class name could be WorkspacesStandard to match plugin name?

andypost’s picture

@longwave Thank you! great idea to explore

andypost’s picture

StatusFileSize
new2.14 KB
new2.13 KB

Here's attempt to use internal property, the "query alter service" is created on every query alter, see workspaces_views_query_alter()

andypost’s picture

+++ b/core/modules/workspaces/src/ViewsQueryAlter.php
@@ -63,6 +63,13 @@ class ViewsQueryAlter implements ContainerInjectionInterface {
+   * An array of tables adjusted for workspace_association join.
...
+   * @var array
...
+  protected $adjustedTables = [];

It looks like backportable to 10.0.x

longwave’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me - only the service needs to know which joins have been altered as far as I can see.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/workspaces/src/ViewsQueryAlter.php
@@ -398,7 +405,7 @@ protected function getRevisionTableJoin($relationship, $table, $field, $workspac
+    $this->adjustedTables[$join->table] = TRUE;

Are we sure that that $join_table is going to be unique? What happens if a view has multiple joins to the same table?

andypost’s picture

Good catch, looking at code it's not clear but views doing aliasing on every table so probably it would be ok but better to as @lendude

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.95 KB
new2.46 KB

Other option could be using WeakMap to use join object as key so it should fix #15

andypost’s picture

Issue summary: View changes

Updated IS with last approach

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Brought this up in #needs-review-queue-initiative channel and @andypost pointed out this doesn't need a change record.

So moving this one on.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 88fab0ba7c and pushed to 10.1.x. Thanks!

I think removing #[\AllowDynamicProperties] is not an API change. It means that if anything in contrib is doing something similar that can make the same change and PHP will issue deprecations telling them they need to do it.

  • alexpott committed 88fab0ba on 10.1.x
    Issue #3299859 by andypost, Anchal_gupta, longwave, alexpott: Remove...

Status: Fixed » Closed (fixed)

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