Development

#4960 (do not filter null defaults if they are optional)

You must first sign up to be able to contribute.

Ticket #4960 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

do not filter null defaults if they are optional

Reported by: jablko Assigned to: fabien
Priority: minor Milestone: 1.2.0 RC2
Component: routing Version:
Keywords: Cc:
Qualification: Unreviewed

Description

I have the following route, and generate_shortest_url is true:

test:
  url: /text/:optional
  param: { optional: ~ }

I works like a charm for matchesUrl() - the URL "/text" gets correctly routed to the default module and action. However it fails in matchesParameters() unless the "optional" parameter is specified. For example:

    var_dump($this->getController()->genUrl(array()));

- does not return "/text"

I think this is because in sfRoute.class.php:153, symfony filters all null or empty parameters, including optional parameters. I wish if generate_shortest_url is true and the parameter is optional, symfony would not filter it. This should enable the following behavior from my route:

  • genUrl(array()) => "/text"
  • matchesUrl("/text") => array('module' => 'default', 'action' => 'index', 'optional' => null);
  • genUrl(array('optional' => 'foo')) => /text/foo
  • matchesUrl("/text/foo") => array('module' => 'default', 'action' => 'index', 'optional' => 'foo');

Change History

11/23/08 11:15:03 changed by FabianLange

  • milestone set to 1.2.0 RC2.

11/24/08 23:22:28 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

in r13322

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.