开发者

An upgrade from CakePHP 1.2 to 1.3 broke my routes, although they should be 1.3 compatible

I`v been upgrading CakePHP from 1.2.10 to 1.3.11 by using "Migrating from CakePHP 1.2 to 1.3" Guide and i'm aware that i must ensure that my routes are compatible with 1.3.

However my routes don't do anything that's incompatible:

This is no longer supported as mid-route greedy stars behaved erratically, and complicated route compiling. Outside of these two edge-case features and the above changes the router behaves exactly as it did in 1.2

The other edge case is:

First path segments using full regular expressions was removed.

How my routes behave:

  • When opening homepage, doesn't work, however on 1.2 it sucessfully matched route #1 (solved by Ivo)
  • /lv/products *doesn't work*. Should have matched #6 using controller "Products" and default action "index" but it thinks that "lv" is controller (ignoring the :lang param)
  • /lv/products/index works!
  • /lv/products/view/productname works!

Cake provides errors similar to this error (copied when opening /lv/products:

Missing Controller
Error: LvController could not be found.
Error: Create the class LvController below in file: app\controllers\lv_controller.php
<?php
class LvController extends AppController {

    var $name = 'Lv';
}
?>

My routes:

    //Route #1: This route should have worked as a root route, because we have a default for :lang. But now i cannot open up the homepage if i don't define explicit "/" route
    Router::connect("/:lang/",开发者_开发百科
        array("controller" => "start", "lang" => "lv"),
        array("lang" => "[a-z]{2}")
    );

    //#2 This route seems to work ok.
    Router::connect("/admin/:lang/:controller/:action/*",
        array("lang" => "lv", "admin" => true),
        array("lang" => "[a-z]{2}")
    );

    // ==============================================================================

    //#3 Routes with static parts - works
    Router::connect("/:lang/info/*",
        array("controller" => "sections", "action" => "view", "lang" => "lv"),
        array("lang" => "[a-z]{2}")
    );

    //#4
    Router::connect("/:lang/news",
        array("controller" => "news", "action" => "listall", "lang" => "lv"),
        array("lang" => "[a-z]{2}")
    );

    //#5
    Router::connect("/:lang/employees",
        array("controller" => "employees", "action" => "index", "lang" => "lv"),
        array("lang" => "[a-z]{2}")
    );

    // ==============================================================================


    //#6 Catch all route. 
    Router::connect("/:lang/:controller/:action/*",
        array("lang" => "lv"),
        array("lang" => "[a-z]{2}")
    );

Thank you for any assistance.


For a default root, I would guess that you want '/', or '/<param>'

'/:lang/' expects something to be there for lang - it's not optional, afaik. Try '/:lang' instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜