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
Closed

Router returns notFound when using query parameters #14087

Enzo-life opened this issue May 17, 2019 · 5 comments
Labels
bug A bug report status: low Low

Comments

@Enzo-life
Copy link

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
Copy link
Contributor

scrnjakovic 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
Copy link
Author

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
Copy link
Author

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

@scrnjakovic
Copy link
Contributor

scrnjakovic 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 mentioned this issue Jun 4, 2019
5 tasks
@niden niden added the Bug - Low label Jun 4, 2019
@niden
Copy link
Member

niden commented Jun 4, 2019

Resolved in #14158

@niden niden closed this as completed Jun 4, 2019
@niden niden added the 4.0 label Jun 21, 2019
@niden niden added bug A bug report status: low Low and removed Bug - Low labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

3 participants