- ๐ท๐ดRomania Rares Badita
The issue arises when creating a URL from a request using the
Url::createFromRequest($request)
method.
When the Router class tries to match the url of the $request parameter to a route, we reach this code:// Check HTTP method requirement. if ($requiredMethods = $route->getMethods()) { // HEAD and GET are equivalent as per RFC. if ('HEAD' === $method = $this->context->getMethod()) { $method = 'GET'; } if (!in_array($method, $requiredMethods)) { $this->allow = array_merge($this->allow, $requiredMethods); $routes->remove($name); continue; } }
The problem is that the $method used to check against $requiredMethods is not obtained from the current $request, but from $context, which is the original request from the request stack.
This leads to an issue with REST exports that use the Facets serializer view style. When building the facets results,
FacetsUrlGenerator::getUrlForRequest()
wants to create a URL from a request to the actual view display(made with GET), not to the preview form(made with POST), thus resulting in a method mismatch and an exception being thrown.I've added a patch for the Facets module to catch this exception.
I've also changed the issue project from views-ui to facets.