Problem/Motivation

I first encountered this when using the Drupal CMS trial on Acquia.

It did not occur locally when clicking browse Modules.

@timplunkett mentioned the trial has:
$config['project_browser.admin_settings']['enabled_sources'] = ['recipes'];
in settings.php

Adding this locally reproduces it.

Steps to reproduce

Add $config['project_browser.admin_settings']['enabled_sources'] = ['recipes']; to settings.php
Visit /admin/modules/browse/drupalorg_jsonapi

The website encountered an unexpected error. Try again later.

AssertionError: assert($source instanceof ProjectBrowserSourceInterface) in assert() (line 117 of modules/contrib/project_browser/src/Element/ProjectBrowser.php).

Drupal\project_browser\Element\ProjectBrowser->getDrupalSettings() (Line: 96)
Drupal\project_browser\Element\ProjectBrowser->attachProjectBrowserSettings()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 825)
Drupal\Core\Render\Renderer->doCallback() (Line: 387)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Proposed resolution

This issue will turn the WSOD into a 404, removing the incorrect link will happen in #3500078: Drupal CMS default content links to Project Browser source disabled in the Trial

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

nicxvan created an issue. See original summary.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

Working on this. It's even easier to reproduce than the IS, just go to /admin/modules/browse/asdf. It doesn't just matter if it's enabled/disabled, it's also whether it exists at all.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Issue summary: View changes
Status: Active » Needs review

tim.plunkett’s picture

Title: WSOD when using settings to limit sources to recipes » WSOD when accessing non-enabled or non-existent source plugin
phenaproxima’s picture

We really need this in Drupal CMS as soon as possible.

tim.plunkett’s picture

For some reason, this MR causes a regression on 10.4.x

For example, running \Drupal\Tests\project_browser\Functional\InstallerControllerTest::testCoreModuleActivate() now gets this error on activation:

{"message":"PluginNotFoundException: The \u0022filter_format\u0022 entity type does not exist.","phase":"project install"}

I'm sure the reason will be obvious once it's tracked down, but wow that's a weird bug right now.

tim.plunkett’s picture

Yes, that is an alternate approach to fixing the same bug.

jurgenhaas’s picture

I've left a couple of comments in the MR hoping that they could be included as well. But leaving at NR just in case you don't want to cover those as well.

tim.plunkett’s picture

+1 to RTBC for all of the tweaks since my initial fix. That installer decorator change being the needed fix is wild. I was half-wrong in #7, not obvious at all!

dinarcon’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested this per the Steps to reproduce in the issue summary. The WSOD is replaced by a 404 error. Also tried @tim.plunkett's steps in comment #2. With the MR is applied, the WSOD also gone.

Looked at the code and discussions in GitLab. Checked in with @phenaproxima in Slack. He confirmed the discussion about plugin decoration is outside the scope for the current issue.

Looks good to me.

tim.plunkett’s picture

Interestingly enough, I was messing around with higher levels of PHPStan and Level 4 would have caught at least the part from #3501194: $source !== 'recipes' is a comparison of incompatible types

chrisfromredfin’s picture

Status: Reviewed & tested by the community » Fixed

Done!

Status: Fixed » Closed (fixed)

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

nicxvan’s picture