What steps will reproduce the problem? 1. urlManager caseCensitive ture 2. mixed case in controller ID e.g. OfficeSearch 3. before v1.05 view path protected/views/OfficeSearch/xxxx 4. v1.05 needs to be protected/views/officeSearch/xxxx
CWebApplication.php R922 Line 403, $id[0]=strtolower($id[0]); Which was not there before.
Suggest to use $id = strtolower($id); so always use lower case directory name or remove this line to preserve the old convention of caseCensitive.
Comment #1
Posted on May 13, 2009 by Helpful CamelThis behavior has been there since the 1.0.1 release. Basically, the controller view directory name should be exactly the same as the controller ID.
Comment #2
Posted on May 13, 2009 by Grumpy BirdHi Qiang, thanks for your quick reply.
However this change wasn't there in R878. We used to have the directory name exactly the same as the controllerID without lowering the first character, but since 1.0.5 we need rename the view directory name to lower the first character in order to make things work.
Please review.
Comment #3
Posted on May 13, 2009 by Helpful CamelThe line was there to fix the following bug: http://code.google.com/p/yii/issues/detail?id=218
This change has been introduced in version 1.0.4.
Comment #4
Posted on May 13, 2009 by Grumpy BirdIt's definitely not in R878 (which is the revision for 1.0.4 release), please check. The project we are running, only had this problem after upgraded from 1.0.4 to 1.0.5.
We just thinking it maybe makes more sense to have all the directory name in lowercase, or keep exactly the same as the controller name as case sensitive. Lower the first char would make the name convention harder to follow if you have multiple words in the controllerID.
Comment #5
Posted on May 13, 2009 by Grumpy Birdbtw, by lowering the first char doesn't fixed the issue 218 completely if you have a second or more words in the controllerID which is capitalized.
It should be either case insensitive as all in lower case or completely case sensitive without lowering the first char. Shouldn't it?
Comment #6
Posted on May 13, 2009 by Helpful CamelIssue 218 was about an unexpected exception (i.e., using different route in the GET parameter could cause an exception about view not found.)
After the fix, if you do not enter the characters in correct cases, you will see a "page not found" exception, which is acceptable and expected.
The original design is: the controller view directory's name should be exactly the same as the controller ID which has the first letter in lower case.
Comment #7
Posted on May 13, 2009 by Grumpy BirdThe original design is: the controller view directory's name should be exactly the same as the controller ID which has the first letter in lower case.
This original design you are talking about, only appears to be in 1.0.5, before that we'll have to name the view directory exactly same as the controller ID with first letter in upper case.
Since this change is not documented, and bit unexpected, we will have to comment out Line 403 CWebApplication.php R922, or rename quite few directory named and replace lot of inclusions to make the project work again for 1.0.5. Just thought to let you know if you think it's necessary to do something about it.
People on Windows won't have this issue, however if they don't following your original design naming convention, it will cause lot of trouble if they try to publish projects to a *nix box.
Comment #8
Posted on May 13, 2009 by Helpful CamelI am sorry for causing the pain to you.
Actually, as I said, this behavior has been there since 1.0.4. And according to the guide, it is by design that the controller ID be the same as the controller view directory (see the convention section). Before 1.0.4, this was not true and thus the bug report 218 and its fix.
We will not revert it back because it would cause more confusion. If you want to make the route case-insensitive, please set caseSensitive to false and make sure all controller IDs (and their view directories) are in lower case.
Comment #9
Posted on May 13, 2009 by Grumpy BirdWe have put more thought towards it, here's something for you to consider. As of the current version 1.0.5. With urlManager->caseSensitive set to true (which is the default), supposedly the URL are case sensitive. However on both *nix and windows, you'll be able to do http://sitename/index.php?r=Site or http://sitename/index.php?r=site Since you have unconditionally converted the id to capitalize regardless the urlManager->caseSensitive parameter. $className=ucfirst($id).'Controller'; Expected result would be only one URL is valid. Correct? So you need to define should the case sensitive URL have the controllerID in lower case or capitalized. And in regarding the view directory name it should always be views/site, since you had $id[0]=strtolower($id[0]);
Now if we set urlManager->caseSensitive to false, and having a controllerID as OfficeSearchController The framework won't be able to locate the controller, since it'll lower the whole string and then ucfirst it, i.e. it'll look for OfficesearchController. It maybe only our problem, since we have more than one words in controller IDs. However unless there are such rules in the naming convention, people may have this common problem too. In regarding the view directory name the yii will look for views/officesearch in case insensitive or views/officeSearch while case sensitive. You see the problem here? If urlManager->caseSensitive parameter is solely for the purpose of URL, the directory naming convention should always be consistent. Otherwise people will stumble unexpected view not found issues when they try to change the urlManager->caseSensitive (although it's unlikely). But you want to make sure they understand the implications before they hit such issues.
So we'll wait for your advice on this matter, before we make changes to few of our Yii based projects. Thanks!
Comment #10
Posted on May 13, 2009 by Grumpy BirdOn http://www.yiiframework.com/doc/guide/basics.convention You might want to change "WebRoot/protected/views/ControllerID: this directory holds view files for a single controller class. Here ControllerID stands for the ID of the controller. It can be customized via CController::getViewPath." to "WebRoot/protected/views/ControllerID: this directory holds view files for a single controller class. Here ControllerID stands for the ID of the controller, WITH FIRST LETTER IN LOWER CASE. It can be customized via CController::getViewPath."
Comment #11
Posted on May 13, 2009 by Helpful CamelIf you set caseSensitive=false, you have to name your controller classes in lower case except the first letter. So your OfficeSearchController should be named as OfficesearchController. Also, the view directories and controller subdirectories must all be in lower case, as you know that the route would be turned into lower-case first.
The setting caseSensitive=true is mainly for advisory purpose, meaning that the URL might be case sensitive in some situations (e.g. *nix). It doesn't really mean two URLs are different if one of the characters is in different cases (as you can see, if we change the case of an action ID character, the URL would still be able to access the same action since method names are case insensitive.)
To conclude, we are not going to change the current behavior. As you suggested, we will improve our documentation to make this clearer. Thanks.
Status: Invalid
Labels:
Priority-Medium
Milestone-1.0.6