On Feb 16, 2008 1:21 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Cake 1.2.0.6311-beta
>
> The 'day' param in the following route is always passed as the same
> value as :month, regardless of the :day value in the URL.
>
> Router::connect('/events/:year/:month/:day',
>         array('controller' => 'events', 'action' => 'view', 'day' => null),
>         array(
>                 'year' => '[12][0-9]{3}',
>                 'month' => '(0[1-9]|1[012])',
>                 'day' => '(0[1-9]|[12][0-9]|3[01])'
>         )
> );
>
> The first line in ViewsController::view() is:
>
> debug($this->params);
>
> produces:
>
> Array
> (
>     [pass] => Array
>         (
>             [0] => 13
>             [1] => 13
>         )
>
>     [named] => Array
>         (
>         )
>
>     [year] => 2008
>     [month] => 02
>     [day] => 02
>     [plugin] =>
>     [controller] => events
>     [action] => view
>     [form] => Array
>         (
>         )
>
>     [url] => Array
>         (
>             [url] => events/2008/02/13/
>         )
>
>     [bare] => 0
>     [webservices] =>
> )
>
> If I remove 'day' => null I see this error:
>
> The action 2008 is not defined in controller EventsController
>

And I've just noticed that, if I remove the month regex from the route, like so:

Router::connect('/events/:year/:month/:day',
        array('controller' => 'events', 'action' => 'view', 'day' => null),
        array(
                'year' => '[12][0-9]{3}',
                'day' => '(0[1-9]|[12][0-9]|3[01])'
        )
);

then it works:

Array
(
    [pass] => Array
        (
            [0] => 13
        )

    [named] => Array
        (
        )

    [year] => 2008
    [month] => 02
    [day] => 13
    [plugin] =>
    [controller] => events
    [action] => view
    [form] => Array
        (
        )

    [url] => Array
        (
            [url] => events/2008/02/13
        )

    [bare] => 0
    [webservices] =>
)

It seems the Route is applying the regex patterns in a really strange
way. The month matches against the day pattern and so it is set in
params[]. But it seems to me that it shouldn't because there is no
named pattern for month.

Is this a bug or a feature?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to