Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Running tests on PHP 8.2 I got
34x: Creation of dynamic property Drupal\views\Entity\View::$_updated is deprecated
13x in ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdates from Drupal\Tests\views\Kernel\EventSubscriber
5x in ViewsEntitySchemaSubscriberIntegrationTest::testVariousTableUpdatesForRevisionView from Drupal\Tests\views\Kernel\EventSubscriber
3x in ViewsEntitySchemaSubscriberIntegrationTest::testBaseTableRename from Drupal\Tests\views\Kernel\EventSubscriber
3x in ViewsEntitySchemaSubscriberIntegrationTest::testDataTableRename from Drupal\Tests\views\Kernel\EventSubscriber
3x in ViewsEntitySchemaSubscriberIntegrationTest::testRevisionDataTableRename from Drupal\Tests\views\Kernel\EventSubscriber
Steps to reproduce
Run ViewsEntitySchemaSubscriberIntegrationTest
on PHP 8.2
Proposed resolution
Define the property
Remaining tasks
patch, review, commit
User interface changes
no
API changes
no
Data model changes
no
Release notes snippet
no
Comment | File | Size | Author |
---|---|---|---|
#10 | 3295813-10.patch | 4.67 KB | andypost |
#10 | interdiff.txt | 633 bytes | andypost |
#8 | 3295813-8.patch | 4.67 KB | andypost |
#8 | interdiff.txt | 856 bytes | andypost |
Comments
Comment #2
andyposthere's initial fix
Comment #3
andypostdisable PHPCS for the property
Comment #4
Berdirthis is a pretty weird one.
Ironically, this property was created 6 years *after* the meta issue that's supposed to remove them which wasn't updated since 2016, which also makes sense as renaming them is an API change in many cases. And it actually explicitly uses get/set, wondering if it wasn't clear that this just sets a property with that name.
This is clearly an internal property that is just used in that single subscriber. Could we rewrite it to e.g. store the list of ids that should be resaved in a protected property of that subscriber:
$this->viewsToResave[$view->id] = TRUE/$view;
Comment #5
andypostThank you! Great idea, less loops and indexed array prevents saving more then one time
Comment #6
andypostBTW it could use WeakReference but then it can't be backported to 9.5
Comment #7
Berdirthat's a very creative use case for array_filter() :) should we just make this a plain old foreach and reset viewstoSave at the end?
Comment #8
andypostfixed it))
Comment #9
andyposttype needs to be removed to backport to 9.x
Comment #10
andypostremoved
array
type-hintComment #11
Berdir9.5 looks like an unrelated random fail:
this is just one of what's going to be many necessary fixes, but I think this makes sense.
Disclaimer: I didn't write any code, but the patch is directly based on my suggestion in #4, so maybe someone else wants to +1 this.
Comment #12
catchMade this change on commit. Everything else looks great so committed/pushed to 10.1.x and cherry-picked back to 9.5.x