Problem/Motivation

When switching between workspace, the block content is not available until clear the cache.

Steps to reproduce

1. On LIVE workspace: Create a custom block and assign to a region visible on home page.
2. Switch to stage and clear cache
3. Switch back to LIVE workspace.

Expected
See block added in step 1 is visible

Actual:
See 'This block is broken or missing. You may be missing content or you might need to enable the original module.'
The block wouldn't appear back until resave or clear cache in LIVE workspace.

Originally reported by @sirko_el

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vijaycs85 created an issue. See original summary.

timmillwood’s picture

Status: Active » Needs review
FileSize
5.93 KB

Here's a test patch for this:

Status: Needs review » Needs work

The last submitted patch, 2: 2944805-2.patch, failed testing. View results

timmillwood’s picture

Project: Workspace » Multiversion
Status: Needs work » Needs review

Moving to Multiversion, because that's where it needs fixing.

Status: Needs review » Needs work

The last submitted patch, 2: 2944805-2.patch, failed testing. View results

timmillwood’s picture

Status: Needs work » Needs review
FileSize
5.93 KB
8.39 KB

Here's a fix

The last submitted patch, 6: 2944805-6-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 6: 2944805-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

timmillwood’s picture

Status: Needs work » Needs review
FileSize
6.78 KB
13.24 KB
vijaycs85’s picture

Thanks @timmillwood. I applied the patch and it fixes the broken block.


If we have more than one user logged in and do the steps 1 and 2 in "steps to reproduce" in one session, the other users get the issue.
timmillwood’s picture

FileSize
5.4 KB
11.51 KB

This should fix the multi user issue by decorating the BlockManager, and overriding the cache key whenever it's used. I tried to override it in the constructor, although this is loaded really early and often isn't rebuilt when switching workspaces.

Status: Needs review » Needs work

The last submitted patch, 11: 2944805-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

vijaycs85’s picture

Looks much cleaner. Few comments:

  1. +++ b/multiversion.services.yml
    @@ -66,6 +66,12 @@ services:
    +    decoration_priority: 50
    

    Not sure how this affect anyway or why 50.

  2. +++ b/src/Block/BlockManager.php
    @@ -0,0 +1,43 @@
    +    $active_workspace = \Drupal::service('workspace.manager')->getActiveWorkspace();
    ...
    +    $active_workspace = \Drupal::service('workspace.manager')->getActiveWorkspace();
    ...
    +    $active_workspace = \Drupal::service('workspace.manager')->getActiveWorkspace();
    

    probably, we can inject it in decorator?

timmillwood’s picture

Status: Needs work » Needs review
FileSize
821 bytes
11.59 KB

Looks like the cache is cleared before the workspace table is created.

Status: Needs review » Needs work

The last submitted patch, 14: 2944805-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

timmillwood’s picture

Status: Needs work » Needs review
FileSize
6.78 KB
12.96 KB

Fixing #13 and #14.

Status: Needs review » Needs work

The last submitted patch, 16: 2944805-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

timmillwood’s picture

Status: Needs work » Needs review
FileSize
12.94 KB

timmillwood credited jeqq.

timmillwood’s picture

  • timmillwood committed c66a6d2 on 8.x-1.x
    Issue #2944805 by timmillwood, vijaycs85, jeqq: Switching workspace...
timmillwood’s picture

Status: Needs review » Fixed

timmillwood’s picture

I should've credited @sirko_el

Status: Fixed » Closed (fixed)

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