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
Issue fork project_browser-3500024
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
Comment #2
tim.plunkettWorking 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.Comment #3
tim.plunkettComment #5
tim.plunkettComment #6
phenaproximaWe really need this in Drupal CMS as soon as possible.
Comment #7
tim.plunkettFor 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:I'm sure the reason will be obvious once it's tracked down, but wow that's a weird bug right now.
Comment #8
rajab natshahFaced the issue after Drupal ~10.4
#3499406: Fix fallback logic for empty $source in browse() method to ensure config validation with improved fallback logic
Comment #9
tim.plunkettYes, that is an alternate approach to fixing the same bug.
Comment #10
jurgenhaasI'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.
Comment #11
tim.plunkett+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!
Comment #12
dinarcon commentedManually tested this per the
Steps to reproducein 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.
Comment #14
tim.plunkettInterestingly 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
Comment #16
chrisfromredfinDone!
Comment #18
nicxvan commented