Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UrlComparerTrait : route not found when menu is get only and submit a form #179

Open
1 of 3 tasks
Erwane opened this issue Jul 9, 2019 · 3 comments
Open
1 of 3 tasks

Comments

@Erwane
Copy link
Collaborator

Erwane commented Jul 9, 2019

This is a (multiple allowed):

  • bug

  • enhancement

  • question

  • CakePHP Version: 3.8.0

  • Plugin Version/Branch: holt59/cakephp3-bootstrap-helpers dev-4.0.1-alpha 00ba937

What you did

if ($this->Navbar->compareUrls(['_name' => 'route.name'])) {
    // code
}

What happened

Thrown a route not found exception

What you expected to happen

find the route ;)

explanation

my route is a get only :
$routes->get('/queue', ['controller' => 'Emails', 'action' => 'queue'], 'route.name');
and is in the "top menu"

When i submit a form (POST, PATCH, PUT), the UrlComparerTrait create a Request with normalized url :
$url = Router::parseRequest(new ServerRequest($this->_removeRelative($url)));
But this request construction use the current environment and set the method to POST.
The route.name with POST method don't exists.

@Erwane
Copy link
Collaborator Author

Erwane commented Jul 9, 2019

I'm not sure about this, but this PR fix my problem ;)

@Holt59
Copy link
Collaborator

Holt59 commented Oct 15, 2019

To clarify a bit, the issue occurs when you have an URL that can be respond to both GET and POST request, and you have a GET "version" in the navigation bar?

@Erwane
Copy link
Collaborator Author

Erwane commented Oct 15, 2019

The issue occur when you have a GET only route, used in navbar, but you do a POST or PUT on form with error (no redirect).

The request is POST and the navbar route only exist in GET, this thrown a Route Not Found

As i said in PR, maybe we can check and compare only route who match the current method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants