Problem/Motivation

Detail page cannot be viewed now in projects coming from RandomDataPlugin. The reason is because the code tries to access a public property which was made private in #3296494: Dynamic properties deprecated in PHP8.2.

Steps to reproduce

Enable "Project Browser Devel" and make sure that RandomDataPlugin is enabled too, then visit project browser and click on the detail page for any project within the RandomDataPlugin. You won't see the detail page. You can check the watchdog and you might see related messages to accessing a private property.

Proposed resolution

Fix it and provide tests.

Also suggested by @tim.plunkett via slack:

I think we can add a getter. but we should have a dedicated issue either way, to capture the bug in test coverage

Remaining tasks

  • ✅ File an issue about this project
  • ☐ Manual Testing
  • ☐ Code Review
  • ☐ Accessibility Review
  • ☐ Automated tests needed/written?
CommentFileSizeAuthor
#5 test_only.diff1.04 KBfjgarlin
#4 test_only.diff1.05 KBfjgarlin
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fjgarlin created an issue. See original summary.

fjgarlin’s picture

Issue summary: View changes
fjgarlin’s picture

StatusFileSize
new1.05 KB

Test only file too.

fjgarlin’s picture

StatusFileSize
new1.04 KB

Not sure why the test only fails on svelte bundle if there aren't any changes there at all.
Trying again.
--
Edit: same
Svelte compiled files do not match. Running yarn build and commiting the changs should fix this.

In any case, this is not needed as we have the test in the full MR.

fjgarlin’s picture

Assigned: fjgarlin » Unassigned
Status: Active » Needs review

In any case, all the MR is ready and it fixes the regression.

It also adds getters, as suggested, and make the setters chainable, which is a frequent pattern. There is a test for the random plugin detail page, which is what was broken.

In order to test:

  • Spin up drupalpod
  • Enable "Project Browser Devel"
  • Go to Browse and select "RandomDataPlugin"
  • Click on detail page and you should see it (you could not before this fix)
tim.plunkett’s picture

I personally think this MR is overkill. The test is great! But changing all the setters to be fluent is unnecessary (and out-of-scope, even if we did want to do it).
Also I don't know that we need getters for everything. We can add more as we see fit, but I'd rather stick to what we need.

On a practical note, for the getters we DO add, we should have return types.
And for getters for Boolean values like "isCompatible", instead of "getIsCompatible" I think we can stick with one verb and have it stay "isCompatible".

If we ever do decide on fluent setters that return $this, the docblock should read @return $this which IDEs understand to mean "the same object" as opposed to a new instance that happens to be the same interface.

Another out-of-scope question: why did we bother with a ProjectInterface? I hope that wasn't my doing, but it seems overkill for what is essentially a domain object / value object. No one else is going to be subclassing or swapping out that class.

fjgarlin’s picture

No worries, I assumed that if we implemented one getter, we might want others, I started to play with multi-cursors in the editor and then things got out of hand.

I've now implemented just the one getter that we need, and as mentioned via slack, I also removed the "ProjectInterface" in favor of just "Project". Most of the MR is the docblocks transfer from one to the other and adding types. I'm happy to do this last part in another issue, but since we mentioned it here I thought that it'd be quicker.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! Much clearer. And I'm fine with the slight scope addition of dropping the interface, because we weren't going to add the new method to it anyway

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! merged

bnjmnm’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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