Problem/Motivation

I think there is a development-only method leftover on the NotificationMessageBlock:

  /**
   * {@inheritDoc}
   */
  public function getCacheMaxAge() {
    return 0;
  }

This means that any page which has this blocked placed on it, whether there are notification messages to be displayed or not, becomes immediately uncacheable.

Proposed resolution

  1. Delete this method
  2. Ensure that messages are correctly cached.
    • This must include caching based on any visibility conditions configured per-message (Thanks to @droath for this tip)

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

gabesullice created an issue. See original summary.

gabesullice’s picture

This patch is combined with #3222678: Add BrowserTest for viewing a notification message as an anonymous visitor. I'll post another patch that can be applied after that one is committed that will not conflict.

gabesullice’s picture

Once #3222678: Add BrowserTest for viewing a notification message as an anonymous visitor lands, the attached patches should apply and you should be able to run tests on them to confirm that they work as expected.

You'll notice that I left a TODO in the test. I started trying to debug why the second "path-specific" message is not displaying, but it seems to be unrelated to caching, so I stopped because I ran out of time. The test that is not commented out still shows that this attached patch fixes the reported problem in the issue summary though.

Note: these will both fail to apply until the other issue is committed. They can be retested after it is.

gabesullice’s picture

Whoops, looks like what I wrote isn't compatible with that version of PHP.

FAIL & COMBINED should fail and pass tests. They contain the patch in the other issue.

TEST-ONLY and .patch won't apply, but they should fail and pass when the other issue lands.

The last submitted patch, 4: 3224578-4-block-cacheability-FAIL.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gabesullice’s picture

gabesullice’s picture

StatusFileSize
new1.62 KB
new6.28 KB
new13.16 KB

Whoops, had to remove some PHP 8 only syntax.

The last submitted patch, 7: 3224578-7-block-cacheability-TEST-ONLY.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • gabesullice committed da964ee on 8.x-1.x
    Issue #3224578 by gabesullice: Placing a NotificationMessageBlock on a...
gabesullice’s picture

Status: Needs review » Fixed
StatusFileSize
new2.38 KB

Cleaned up a couple CS violations on commit.

Status: Fixed » Closed (fixed)

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