Problem/Motivation

There is search functionality from the Search module in User.

Steps to reproduce

Proposed resolution

Remaining tasks

Fix Drupal\Tests\search\Functional\GenericTest::testModuleGenericIssues
Review

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3588379

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

quietone created an issue. See original summary.

quietone’s picture

Issue summary: View changes
Status: Active » Needs work

Fix Drupal\Tests\search\Functional\GenericTest::testModuleGenericIssues. The error is related to routes but I am not sure what the proper fix is. Anyone?

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "search.view" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 214 of core/lib/Drupal/Core/Routing/RouteProvider.php).

Drupal\Core\Routing\UrlGenerator->getRoute() (Line: 281)
quietone’s picture

Adding more detail for the error.

PHPUnit

1) Drupal\Tests\search\Functional\GenericTest::testModuleGenericIssues
Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.

/var/www/html/vendor/behat/mink/src/WebAssert.php:888
/var/www/html/vendor/behat/mink/src/WebAssert.php:145
/var/www/html/core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php:79
/var/www/html/core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php:50


browser output

The website encountered an unexpected error. Try again later.

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "search.view" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 214 of core/lib/Drupal/Core/Routing/RouteProvider.php).

Drupal\Core\Routing\UrlGenerator->getRoute() (Line: 281)
Drupal\Core\Routing\UrlGenerator->generateFromRoute() (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() (Line: 776)
Drupal\Core\Url->toString() (Line: 33)
Drupal\search\Hook\SearchHooks->help() (Line: 301)
Drupal\Core\Extension\ModuleHandler->invoke() (Line: 119)
Drupal\help\Controller\HelpController->helpPage()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 619)
Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():619}()
Fiber->start() (Line: 620)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 36)
Drupal\Core\Test\StackMiddleware\TestWaitTerminateMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 30)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 199)
Drupal\page_cache\StackMiddleware\PageCache->fetch() (Line: 136)
Drupal\page_cache\StackMiddleware\PageCache->lookup() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 61)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 753)
Drupal\Core\DrupalKernel->handle() (Line: 19)

The route search.view is used in search.links.menu.yml. It is setup in \Drupal\search\Routing\SearchPageRoutes::routes() but only if there there is a defined default search page. For some reason there is no default search page.

gábor hojtsy made their first commit to this issue’s fork.

gábor hojtsy’s picture

Status: Needs work » Needs review

I researched this with LLM assistance.

The problem seems to be that core/modules/user/src/Plugin/Search/UserSearch.php attempts to extend the Drupal\search_user\Plugin\Search\SearchUser class without requiring that module. I pushed a temporary attempt to conditionally define the class only if the base class is available (since the user module should not depend on the search_user module).

Why is the UserSearch plugin not in the search_user module?

gábor hojtsy’s picture

I see it is kept for BC. Is keeping the UserSearch plugin in user module (where it is) an API?

gábor hojtsy’s picture

The search.view problem is that the route is defined as disabled by default. Then core/modules/search/src/Routing/SearchPageRoutes.php makes it work if there was a default search provider. But in the test there is no search provider by default, so the link does not work in the help hook.

I proposed a fix with conditional help text based on whether the route exists. I'm not sure the text is good now, that needs more review, but this passes the text for me locally.

(Analysis was LLM assisted).

gábor hojtsy’s picture

Only test that seems to fail is search update test not finding the dump file. The dump file is there though, and it passes fine locally even. I've also seen the same test pass on CI without modifying anything around it. However now it failed in several times in a row on CI. I am out of ideas on that. Why is this failing on CI and passing locally when it is about a location of a dump file?!

quietone’s picture

I did a bit of a tidy on the recent changes. I removed the getting the route provider only because I found it easier to read without separating out a part of a paragraph.

Adding a try/catch in hook help for the case when the route search.view doesn't exists works for this case. But what of the uses of the route in contrib?

Would it be better to go to a page with a message like 'no search pages available'?

gábor hojtsy’s picture

Would it be better to go to a page with a message like 'no search pages available'?

Maybe for admins? I don't think its good for anonymous visitors to see a page with this. While there are many ways to fingerprint Drupal, I would generally avoid adding more such pages :)

smustgrave’s picture

So only open question is if core/modules/user/src/Plugin/Search/UserSearch.php needs a CR or can point to the search module being deprecated.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Talked to catch and he mentioned a CR so I went ahead and added a simple one and added it inline to the MR. Rest LGTM.