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

Router returns notFound when using query parameters #14087

Closed
Enzo-life opened this issue May 17, 2019 · 5 comments

Comments

@Enzo-life
Copy link

commented May 17, 2019

I have a simple router config in Phalcon 4.0:

use Phalcon\Mvc\Router;
$router = new Router(false);
$router->notFound(['controller' => 'Http', 'action' => 'code404']);
$router->add('/', ['controller' => 'index', 'action' => 'index']);

http://my.domain/ returns something from index controller. But when i add even symbol '?' to my url (http://my.domain/?), it returns 404 page. I can't get what should i change in route and didn't found any information about routing query parameters in documentation.

P.S. I debugged $_GET when using any parameters, they are present.

I asked at discussion forum, but Emilio Degiovanni said it's probably a bug. But as i see in topics, people can use GET parameters as well, so maybe i'm just doing something wrong.

Help pls :)

@scrnjakovic

This comment has been minimized.

Copy link
Contributor

commented May 22, 2019

What is your URI source?

<?php

use Phalcon\Mvc\Router;

// ...

// Use $_GET['_url'] (default)
$router->setUriSource(
    Router::URI_SOURCE_GET_URL
);

// Use $_SERVER['REQUEST_URI']
$router->setUriSource(
    Router::URI_SOURCE_SERVER_REQUEST_URI
);

I guess it's Router::URI_SOURCE_GET_URL as that's default. The query string does not have any effect on the router if the source is Router::URI_SOURCE_SERVER_REQUEST_URI. On the other hand, Router::URI_SOURCE_GET_URL depends on it, so I'd say it's beacuse of that.

@Enzo-life

This comment has been minimized.

Copy link
Author

commented May 25, 2019

Call to undefined method Phalcon\Mvc\Router::setUriSource()
As i see in sources, Phalcon v4.0 doesn't have that method.

I pass source to handler:
$response = $application->handle($_SERVER['REQUEST_URI']);
As i understand, this means Router::URI_SOURCE_SERVER_REQUEST_URI :)

@Enzo-life

This comment has been minimized.

Copy link
Author

commented May 25, 2019

But i've got your point and changed request uri to $_GET['_url'] and it seems like works now.

@scrnjakovic

This comment has been minimized.

Copy link
Contributor

commented May 28, 2019

Those methods were removed in #12380, as of 4.0.x you have to pass URI to the $application->handle() method. Whether you will pass $_GET['_uri'] or $_SERVER['REQUEST_URI'] depends on your server configuration. As long as phalcon receives a string to match, query parameters will have no effect on the match result.

@ekmst ekmst referenced this issue Jun 4, 2019

Merged

bugfix/router-notfound #14158

3 of 5 tasks complete

@niden niden added the Bug - Low label Jun 4, 2019

@niden niden added this to To do in 4.0 Release via automation Jun 4, 2019

@niden

This comment has been minimized.

Copy link
Member

commented Jun 4, 2019

Resolved in #14158

@niden niden closed this Jun 4, 2019

4.0 Release automation moved this from To do to Done Jun 4, 2019

@niden niden added the 4.0 label Jun 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
3 participants
You can’t perform that action at this time.