Problem/Motivation

With the release of mglaman/phpstan-drupal 1.1.37 (https://github.com/mglaman/phpstan-drupal/releases/tag/1.1.37) the false positives on "Missing cache backend declaration for performance." should be gone. (https://github.com/mglaman/phpstan-drupal/pull/592)

Let's bump mglaman/phpstan-drupal to 1.1.37, remove the ignore from core/phpstan.neon.dist and see where we stand.

If the false-positives are indeed gone, we can fix all valid remaining fails on this one in this issue.

Steps to reproduce

Proposed resolution

- Bump mglaman/phpstan-drupal to 1.1.37
- Remove "Missing cache backend declaration for performance." from core/phpstan.neon.dist
- Evaluate/fix any remaining failures from that (now un-ignored) rule.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#12 3377000-nr-bot.txt90 bytesneeds-review-queue-bot

Issue fork drupal-3377000

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

Spokje created an issue. See original summary.

spokje’s picture

16 New errors without the Missing cache backend declaration for performance. rule.
At first (quick) glance they all seem legit.

longwave’s picture

LanguageNegotiationMethodManager could call setCacheBackend() instead of initialising the properties itself. In fact it looks like the $cacheKeyPrefix is not even used so enabling this has caught some historical cruft.

The migrate plugins look like false positives; it might be worth raising an upstream bug, given that setCacheBackend() is actually called in the parent constructor.

Most of the others are test cases where we don't really care about performance.

spokje’s picture

The migrate plugins look like false positives; it might be worth raising an upstream bug, given that setCacheBackend() is actually called in the parent constructor.

Most of the others are test cases where we don't really care about performance.

By what I gather of the current implementation, every plugin class is now required to have a setCacheBackend() in it's __construct().

What I gather of the above quote is:

We want setCacheBackend() in every plugin class __construct(), unless:
- it's the base class, where we define the base class as being the class that has the implementation of setCacheBackend().
- it's a test class.
- it has a parent that already has a setCacheBackend() in it's __construct().

Is that about right?

That would leave only \Drupal\Core\Menu\MenuLinkManager as a valid flagged failure.

spokje’s picture

Since this is going to be postponed on a Yet To Be Created upstream issue, I've split off the low hanging fruit LanguageNegotiationMethodManager-bit from #4 to #3377318: Remove cruft from LanguageNegotiationMethodManager.

Also:

Most of the others are test cases where we don't really care about performance.

Performance is indeed a bit of a non-issue in tests, but shouldn't we force it anyway, for Best Practice-reasons?

longwave’s picture

Your summary in #5 looks correct to me.

In this issue, should we just add all the cases to the baseline, to ensure any future plugin managers are caught, and open upstream issue(s) as appropriate? Then we can handle fixing the baselined issues as we normally do in followups, or when phpstan-drupal updates and breaks the updated deps build.

spokje’s picture

Title: Remove phpstan ignore "#^Missing cache backend declaration for performance.#" » [PP-1] Remove phpstan ignore "#^Missing cache backend declaration for performance.#"
Status: Active » Postponed

In this issue, should we just add all the cases to the baseline,

That's indeed probably the best way to ensure any progress, or at least no new regressions creeping in.
Let's wait until the already RTBC-ed #3377318: Remove cruft from LanguageNegotiationMethodManager gets committed to prevent us dancing the Reroll-Rumba.

spokje’s picture

Title: [PP-1] Remove phpstan ignore "#^Missing cache backend declaration for performance.#" » [PP-Upstream] Remove phpstan ignore "#^Missing cache backend declaration for performance.#"

Opened https://github.com/mglaman/phpstan-drupal/issues/598 upstream to handle #5.

Leaving this postponed for a little bit, while I try to get a PR up there.

spokje’s picture

Title: [PP-Upstream] Remove phpstan ignore "#^Missing cache backend declaration for performance.#" » Remove phpstan ignore "#^Missing cache backend declaration for performance.#"
Status: Postponed » Needs review

In this issue, should we just add all the cases to the baseline, to ensure any future plugin managers are caught, and open upstream issue(s) as appropriate? Then we can handle fixing the baselined issues as we normally do in followups, or when phpstan-drupal updates and breaks the updated deps build.

@longwave in #7

Sorry, this got lost somewhere in my torrent of ToDo's.

The upstream PR is proving more difficult than expected, also it's hard testing over there when core has the rule messages ignored.
So let's indeed just add to baseline and take it from there.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

MR seems to be doing what @spokje says in #10 but not sure the pro of moving from the .dist to 15 entries in the baseline?

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

xjm’s picture

@smustgrave Moving the entries to the baseline means we can fix them individually as needed, when appropriate to the context, and sort legit failures from any further false positives.

xjm’s picture

Title: Remove phpstan ignore "#^Missing cache backend declaration for performance.#" » Remove phpstan ignore for "#^Missing cache backend declaration for performance.#"
longwave’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Needs work » Fixed

The bot was wrong, this still applies for me. Let's just get this in given it is is only baseline changes.

Committed and pushed 6514a92979 to 11.x and 1b80269cd5 to 10.2.x. Thanks!

  • longwave committed 1b80269c on 10.2.x
    Issue #3377000 by Spokje, longwave, xjm: Remove phpstan ignore for "#^...

  • longwave committed 6514a929 on 11.x
    Issue #3377000 by Spokje, longwave, xjm: Remove phpstan ignore for "#^...

Status: Fixed » Closed (fixed)

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