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
Some classes has usage of undefined properties which are not fixed in #3274474: Fix 'Access to an undefined property' PHPStan L0 errors because could be caught by tests only (not phpstan)
The issue intended for all classes except tests
Steps to reproduce
See #3295821-91: Ignore: patch testing issue for PHP 8.2 attributes
Proposed resolution
Define missing properties
Remaining tasks
- collect all changes from testing issue #3295821-91: Ignore: patch testing issue for PHP 8.2 attributes
- make sure tests pass on PHP 8.2
- review/commit
User interface changes
no
API changes
no
Data model changes
no
Release notes snippet
no
Comment | File | Size | Author |
---|---|---|---|
#32 | interdiff_29-32.txt | 809 bytes | narendra.rajwar27 |
#32 | 3309748-32.patch | 554 bytes | narendra.rajwar27 |
#29 | 3309748-9.5.x-29.patch | 617 bytes | andypost |
#20 | interdiff_18-20.txt | 463 bytes | Ratan Priya |
#20 | 3309748-20.patch | 507 bytes | Ratan Priya |
|
Comments
Comment #2
andypostre-title and scoped
Comment #3
andypostComment #4
Berdirso #3274474: Fix 'Access to an undefined property' PHPStan L0 errors took the easy way out and dropped them from that issue, but we still need to fix it.
needs a core maintainer decision but I expect we still need minimal docs on this one (or also just put the dynamic property annotation on it and make it a problem for another day?)
The fix IMHO is still to add the AllowedDynamicProperties annotation to \Drupal\Component\Plugin\Definition\PluginDefinition. plugin definitions are imho expected to be extensible. just adding these might fix the core tests for now, but it will not fix contrib. We can have a follow-up to use magic get/set or something, but that should be ok for now.
this is an absolute mess. we need to clean this up, but instead of adding all these properties, lets also use the annotation on this class.
this is a config entity class, so this can be removed.
ok, so that's this part:
Isn't there a better way to check that it's the same object? According to https://www.php.net/manual/en/language.oop5.object-comparison.php, we can simply do a $renderer === $renderer2 comparison, then we can drop this. same for the widget above.
I think that load thing in MigrateSkipRowTest is a bogus leftover. the test still passes if you comment it out, lets just remove that there.
the others we either need to document properly or clean up. What I'm not 100% clear about is the different between the plugin definition and the plugin class here. Ah, I see. \Drupal\migrate\Plugin\Migration::__construct() is the culprit, it moves everything from configuration and plugin definition directly to the class. We either need to limit that to existing properties or add the annotation as well, because this could contain anything then.
same here, this is already on the parent class now.
config entity, safe to remove.
this is kind of a weird one.
the bug is arguably in \Drupal\Core\TypedData\TypedData::setValue, this sets $this->value but doesn't actually define such a property. but that's more or less because the type there isn't defined.
as a computed string, I don't think this expects to have a value set, but all properties get set to a value through \Drupal\Core\TypedData\Plugin\DataType\Map::setValue(), even if nothing was set for them.
I think this for now is correct, lets just set a generic docblock like on \Drupal\Core\TypedData\PrimitiveBase.
this _should_ go through magic get/set, do tests really fail without this?
Comment #5
Berdir> I think this for now is correct, lets just set a generic docblock like on \Drupal\Core\TypedData\PrimitiveBase.
Alternatively, we could overwrite setValue() and ignore the input, as we do not support setting a value.
Comment #6
mondrakeRe #4.1 the way out was meant to be #3299678: Deprecate DiffEngine and replace with sebastian/diff, but I reckon that is too late for 9.5. IMHO better go for the dynamic property annotation for now, then directionally work to remove DiffEngine.
Comment #7
andypost@mondrake maybe better to define this properties and clean up phpstan ignore?
Comment #8
mondrake@andypost dunno… it was like that in #3274474: Fix 'Access to an undefined property' PHPStan L0 errors before being expuncted. I guess we need guidance here.
Comment #9
andypostThere's 2 child issues filed during DrupalConEur sprints
- #3311442: Only set defined properties on config entities in EntityForm::copyFormValuesToEntity - needs to clean-up to remove useless properties access
- #3311466: Remove obsolete ViewExecutable::editing property access - just discovered while working on previous
Comment #10
andypostLet's see how many will fail in combined with #3311383: Apply #[\AllowDynamicProperties] attribute to core classes to allow contrib has less noise in logs
Comment #11
andypostAdded missed hunks and ViewUI attribute
Comment #12
andypostOther way to fix
Comment #14
andypostProbably this could be closed because patch will contain only one change after #3311562: Set sqlQuery in Entity\Query\Sql Condition classes on own class
this is only will left here as other classes are from tests
Comment #15
andypostall missing properties
Comment #16
Berdiredit: commented on the wrong issue.
Comment #17
andypostThe only remaining fix here, to catch it use
\Drupal\Tests\views\Functional\TaxonomyGlossaryTest
Comment #18
andypostAdded @see to where the property is used as public
Comment #19
BerdirI think the "to" here is not necessary and not valid english, can be removed.
Comment #20
Ratan Priya CreditAttribution: Ratan Priya at OpenSense Labs commented@Berdir,
Made changes as per comment #19.
Needs review.
Comment #21
BerdirThanks.
Comment #22
alexpottGiven we added handler with a typehint I think we should be adding this with one too...
so
public bool $formula = FALSE;
Comment #26
alexpottDiscussed with a @catch - we agreed to make a commit to add the typehint and be done.
Committed and pushed 4a16f2a856 to 10.1.x and 19bd9092bd to 10.0.x. Thanks!
Comment #29
andypostHere's a patch for 9.5.x - I bet it safe to backport
Comment #30
alexpottIf we're going to backport this then I think we should backport [##3295157] too
Comment #31
longwaveThis should add the declaration before the constructor, as in 10.1.x.
Comment #32
narendra.rajwar27Adding declaration above constructor.
Comment #33
BerdirI agree with #30 and I'm at the same time against backporting #3295157: Fix 'Access to an undefined property' PHPStan L0 errors - public properties, I was wrong with an earlier slack thread, I believe *that* issue is what broke search_api in D10 and backporting would break it there too. So, IMHO, we should close this and leave PHP 8.2 support for D10+.
Comment #34
andypostAgree with #33