Bug #1635

Routing: Routes should ignore query parameters if not configured

Added by Karsten Dambekalns almost 7 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2008-10-02
Priority:Must have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:MVC
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 1
PHP Version: Complexity:
Has patch: Affected Flow version:

Description

Currently a route behaves weird if a query is given but not configured. Consider this example:

$c->TYPO3Route_ServiceWithControllerAndFormat
    ->setUrlPattern('typo3/service/v1/[@controller].[@format]')
    ->setControllerComponentNamePattern('F3::@package::Service::Controller::@controllerController')
    ->setViewComponentNamePattern('F3::@package::Service::View::@controller::@action@format')
    ->setDefaults(
        array(
            '@package' => 'TYPO3',
        )
    );

Now calling the URLs as following results in...

http://site/typo3/service/v1/sites.json
=> correct output
http://site/typo3/service/v1/sites.json?something
=> An invalid request format (json?something) was given.

Not good. Trying to add ? to the end:

$c->TYPO3Route_ServiceWithControllerAndFormat
    ->setUrlPattern('typo3/service/v1/[@controller].[@format]?')

Still the same results.

Workaround: add "?[@dummy]" to the pattern, and it works.

$c->TYPO3Route_ServiceWithControllerAndFormat
    ->setUrlPattern('typo3/service/v1/[@controller].[@format]?[@dummy]')

Expected solution:
  • ignore a query if not needed

Associated revisions

Revision 7c04992d
Added by Bastian Waidelich almost 7 years ago

  • FLOW3: (MVC) Changed handling of Query parameters in URIs. They are ignored now, unless explicitly configured in URI pattern. This fixes #1635. Note: if you want to access a query parameter, you still have to add it to your route.
  • FLOW3: (MVC) Some smaller tweaks and fixes in Route class.

History

#1 Updated by Bastian Waidelich almost 7 years ago

Todo: When a query string is given in the UriPattern, this should be matched exactly. If not, query strings are ignored.

#2 Updated by Bastian Waidelich almost 7 years ago

  • Target version set to 1.0 alpha 1

#3 Updated by Bastian Waidelich almost 7 years ago

  • Subject changed from Routes should ignore query parameters if not configured to Routing: Routes should ignore query parameters if not configured

#4 Updated by Karsten Dambekalns almost 7 years ago

  • Target version deleted (1.0 alpha 1)

#5 Updated by Karsten Dambekalns almost 7 years ago

  • Target version set to 1.0 alpha 1

#6 Updated by Bastian Waidelich almost 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r1408.

#7 Updated by Bastian Waidelich over 6 years ago

NOTE Behavior of queries in Routes will change:
Query strings won't be part of the URI patterns anymore to avoid complexity of configuration and implementation.
Instead, query strings will be ignored when matching routes. All query parameters will be passed through to the current request object.
When building URIs, remaining Route values will be added to the query string in the format:

?key1=value1&key2=value2

Also available in: Atom PDF