Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit dd90b91

Browse files
committed
Merge branch 'hotfix/8'
Close #8
2 parents 7ff0f4c + 5bf6f12 commit dd90b91

File tree

4 files changed

+1
-169
lines changed

4 files changed

+1
-169
lines changed

doc/book/routing.md

-68
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ You may use any route type as a child route of a `Part` route.
341341
> 'scheme' => 'Zend\Router\Http\Scheme',
342342
> 'segment' => 'Zend\Router\Http\Segment',
343343
> 'wildcard' => 'Zend\Router\Http\Wildcard',
344-
> 'query' => 'Zend\Router\Http\Query',
345344
> 'method' => 'Zend\Router\Http\Method',
346345
> ];
347346
> foreach ($plugins as $name => $class) {
@@ -440,73 +439,6 @@ $route = Segment::factory([
440439
]);
441440
```
442441

443-
### Zend\\Router\\Http\\Query (Deprecated)
444-
445-
> #### Potential security issue
446-
>
447-
> Misuse of this route can lead to potential security issues.
448-
449-
> #### Deprecated
450-
>
451-
> This route part is deprecated since you can now add query parameters without a
452-
> query route.
453-
454-
The `Query` route part allows you to specify and capture query string parameters
455-
for a given route.
456-
457-
The intention of the `Query` part is that you do not instantiate it in its own
458-
right, but use it as a child of another route part.
459-
460-
An example of its usage would be:
461-
462-
```php
463-
$route = Part::factory([
464-
'route' => [
465-
'type' => 'literal',
466-
'options' => [
467-
'route' => 'page',
468-
'defaults' => [],
469-
],
470-
],
471-
'may_terminate' => true,
472-
'route_plugins' => $routePlugins,
473-
'child_routes' => [
474-
'query' => [
475-
'type' => 'Query',
476-
'options' => [
477-
'defaults' => [
478-
'foo' => 'bar',
479-
],
480-
],
481-
],
482-
],
483-
]);
484-
```
485-
486-
This then allows you to create query strings using the url view helper.
487-
488-
```php
489-
$this->url(
490-
'page/query',
491-
[
492-
'name' => 'my-test-page',
493-
'format' => 'rss',
494-
'limit' => 10,
495-
]
496-
);
497-
```
498-
499-
Per the above example, you must add `/query` (the name we gave to our query
500-
route segment) to your route name in order to append a query string. If you do
501-
not specify `/query` in the route name, then no query string will be appended.
502-
503-
Our example "page" route has only one defined parameter of "name"
504-
(`/page[/:name]`), meaning that the remaining parameters of "format" and "limit"
505-
will then be appended as a query string.
506-
507-
The output from our example should then be
508-
`/page/my-test-page?format=rss&limit=10`
509-
510442
### Zend\\Router\\Http\\Wildcard (Deprecated)
511443

512444
> #### Potential security issue

src/Http/Part.php

+1-19
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ public function match(Request $request, $pathOffset = null, array $options = [])
156156
$pathLength = strlen($uri->getPath());
157157

158158
if ($this->mayTerminate && $nextOffset === $pathLength) {
159-
$query = $uri->getQuery();
160-
if ('' == trim($query) || ! $this->hasQueryChild()) {
161-
return $match;
162-
}
159+
return $match;
163160
}
164161

165162
if (isset($options['translator'])
@@ -233,19 +230,4 @@ public function getAssembledParams()
233230
// don't have to return anything here.
234231
return [];
235232
}
236-
237-
/**
238-
* Is one of the child routes a query route?
239-
*
240-
* @return bool
241-
*/
242-
protected function hasQueryChild()
243-
{
244-
foreach ($this->routes as $route) {
245-
if ($route instanceof Query) {
246-
return true;
247-
}
248-
}
249-
return false;
250-
}
251233
}

test/Http/PartTest.php

-21
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,6 @@ public static function getRouteAlternative()
149149
'param_delimiter' => '/'
150150
]
151151
],
152-
/*
153-
'query' => array(
154-
'type' => 'Zend\Router\Http\Query',
155-
'options' => array(
156-
'key_value_delimiter' => '=',
157-
'param_delimiter' => '&'
158-
)
159-
)
160-
*/
161152
]
162153
);
163154
}
@@ -479,18 +470,6 @@ public function testPartRouteMarkedAsMayTerminateButWithQueryRouteChildWillMatch
479470
],
480471
'route_plugins' => self::getRoutePlugins(),
481472
'may_terminate' => true,
482-
/*
483-
'child_routes' => array(
484-
'query' => array(
485-
'type' => 'Zend\Router\Http\Query',
486-
'options' => array(
487-
'defaults' => array(
488-
'query' => 'string',
489-
),
490-
),
491-
),
492-
),
493-
*/
494473
];
495474

496475
$route = Part::factory($options);

test/Http/TreeRouteStackTest.php

-61
Original file line numberDiff line numberDiff line change
@@ -168,67 +168,6 @@ public function testAssembleCanonicalUriWithHostnameRouteAndRequestUriWithoutSch
168168
$this->assertEquals('http://example.com/', $stack->assemble([], ['name' => 'foo']));
169169
}
170170

171-
public function testAssembleCanonicalUriWithHostnameRouteAndQueryRoute()
172-
{
173-
$this->markTestSkipped('Query route part has been deprecated in ZF as of 2.1.4');
174-
$uri = new HttpUri();
175-
$uri->setScheme('http');
176-
$stack = new TreeRouteStack();
177-
$stack->setRequestUri($uri);
178-
$stack->addRoute(
179-
'foo',
180-
[
181-
'type' => 'Hostname',
182-
'options' => [
183-
'route' => 'example.com',
184-
],
185-
'child_routes' => [
186-
'index' => [
187-
'type' => 'Literal',
188-
'options' => [
189-
'route' => '/',
190-
],
191-
'child_routes' => [
192-
'query' => [
193-
'type' => 'Query',
194-
],
195-
],
196-
],
197-
],
198-
]
199-
);
200-
201-
$this->assertEquals(
202-
'http://example.com/?bar=baz',
203-
$stack->assemble(['bar' => 'baz'], ['name' => 'foo/index/query'])
204-
);
205-
}
206-
207-
public function testAssembleWithQueryRoute()
208-
{
209-
$this->markTestSkipped('Query route part has been deprecated in ZF as of 2.1.4');
210-
$uri = new HttpUri();
211-
$uri->setScheme('http');
212-
$stack = new TreeRouteStack();
213-
$stack->setRequestUri($uri);
214-
$stack->addRoute(
215-
'index',
216-
[
217-
'type' => 'Literal',
218-
'options' => [
219-
'route' => '/',
220-
],
221-
'child_routes' => [
222-
'query' => [
223-
'type' => 'Query',
224-
],
225-
],
226-
]
227-
);
228-
229-
$this->assertEquals('/?bar=baz', $stack->assemble(['bar' => 'baz'], ['name' => 'index/query']));
230-
}
231-
232171
public function testAssembleWithQueryParams()
233172
{
234173
$stack = new TreeRouteStack();

0 commit comments

Comments
 (0)