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

param2path failed when given integer #185

Closed
MartkCz opened this issue Aug 23, 2017 · 3 comments

Comments

@MartkCz
Copy link

commented Aug 23, 2017

  • bug report? yes
  • feature request? no
  • version: dev-master f0b30ff

Description

I tried to generate link:

{plink News:detail category => $news->getCategory()->getName(), id => $news->getId(), name => $news->getSubject()}

and it's failed in class Route in method param2path: https://github.com/nette/application/blob/master/src/Application/Routers/Route.php#L330

TypeError: Argument 1 passed to Nette\Application\Routers\Route::param2path() must be of the type string, integer given

Dump of params:
category => "xxx"
id => 3614
name => "xxx"
action => "xxx"

It's ok:

{plink News:detail category => $news->getCategory()->getName(), id => (string) $news->getId(), name => $news->getSubject()}
@dg

This comment has been minimized.

Copy link
Member

commented Aug 23, 2017

It should be converted to string here

$params[$name] = (string) $params[$name];

Can you find out why this is not happening?

@MartkCz

This comment has been minimized.

Copy link
Author

commented Aug 23, 2017

Because fixity is not set. Values of $meta:

pattern => "#(?:[0-9]+)\z#A" (15)
filterOut => array (2)
0 => "Nette\Application\Routers\Route" (31)
1 => "param2path" (10)
filterTable2 => null

My router:

new Route('https://%domain%/stranka/<newsFilter-paginator-page [0-9]+>', [
			'presenter' => 'Homepage',
			'action' => 'default',
		]);

I can give more information, if you want

@MartkCz

This comment has been minimized.

Copy link
Author

commented Aug 23, 2017

I tried test case Routers/Router.basic.phpt with int parameter:
ok:

Assert::same('http://example.com/homepage/12', testRouteOut(new Route('<presenter>/<id= \d{1,3}>'), 'Homepage', ['id' => 12]));

failed:

Assert::same('http://example.com/homepage/12', testRouteOut(new Route('<presenter>/<id [0-9]+>'), 'Homepage', ['id' => 12]));

@dg dg closed this in b62d2f5 Aug 24, 2017

dg added a commit that referenced this issue Aug 24, 2017

Route: converts all scalar params to strings [Closes #185]
+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 3, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 3, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 3, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 3, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 10, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 20, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string

dg added a commit to nette/routing that referenced this issue Feb 20, 2019

Route: converts all scalar params to strings [Closes nette/applicatio…
…n#185]

+ fixed conversion of false in default values to string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.