Hello,
I’ve encountered a bit weird problem regarding the PHP build in class ReflectionMethod.
Edit2: Looks like PHP bug https://bugs.php.net/bug.php?id=61384
Edit: Seems the problem is in my system. Tested with the following simple code:
class Test {
function barTest($foo) {
}
}
$method = new ReflectionMethod('Test', 'bartest');
var_dump($method->getName());
var_dump($method->name);
foreach($method->getParameters() as $i=>$param) {
var_dump($param->getName());
var_dump($param->name);
}
[b]and got results
bool(false) string(7) "barTest" bool(false) string(3) "foo"
while the same code ran in http://writecodeonline.com/php/ (PHP5) returns
string(7) "barTest" string(7) "barTest" string(3) "foo" string(3) "foo"
I’m running:
PHP Version 5.4.4, Linux Fedora 17
Linux home.desktop 3.4.0-1.fc17.i686.PAE #1 SMP Sun Jun 3 06:54:54 UTC 2012 i686[/b]
-
Created a webapp with Yii 1.1.10.
-
Followed the Wiki article "SEO-conform Multilingual URLs + Language Selector Widget (i18n)" and wanted to be able to manage the languages from the database so my urlManager rules are:
'rules'=>array(
'gii' => 'gii',
'gii/<controller:\w+>' => 'gii/<controller>',
'<language>/' => 'site/index',
'<language>/page/<view:\w+>'=>'site/page',
'<language>/<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<language>/<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<language>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<language>/<controller:\w+>'=>'<controller>/index',
'<language>/<action:.*>'=>'site/<action>',
),
-
Created model and CRUD with Gii from db table language.
-
Created a language record in db and called the URL "/en/language/view/1".
-
Got Exception with Stack trace:
exception 'CHttpException' with message 'Your request is invalid.' in
/var/www/yii-1.1.10/web/CController.php:337
Stack trace:
#0 /var/www/yii-1.1.10/web/CController.php(310):
CController->invalidActionParams(Object(CInlineAction))
#1 /var/www/yii-1.1.10/web/filters/CFilterChain.php(134):
CController->runAction(Object(CInlineAction))
#2 /var/www/yii-1.1.10/web/filters/CFilter.php(41): CFilterChain->run()
#3 /var/www/yii-1.1.10/web/CController.php(1146):
CFilter->filter(Object(CFilterChain))
#4 /var/www/yii-1.1.10/web/filters/CInlineFilter.php(59):
CController->filterAccessControl(Object(CFilterChain))
#5 /var/www/yii-1.1.10/web/filters/CFilterChain.php(131):
CInlineFilter->filter(Object(CFilterChain))
#6 /var/www/yii-1.1.10/web/CController.php(292): CFilterChain->run()
#7 /var/www/yii-1.1.10/web/CController.php(266):
CController->runActionWithFilters(Object(CInlineAction), Array)
#8 /var/www/yii-1.1.10/web/CWebApplication.php(276):
CController->run('view')
#9 /var/www/yii-1.1.10/web/CWebApplication.php(135):
CWebApplication->runController('language/view')
#10 /var/www/yii-1.1.10/base/CApplication.php(162):
CWebApplication->processRequest()
#11 /var/www/html/Dropbox/Websites/agro/index.php(13): CApplication->run()
#12 {main}
REQUEST_URI=/Dropbox/Websites/agro/en/language/view/1
---
-
Tried to follow the code and debug here and there.
-
The part I find strange is:
- In CInlineAction::runWithParams($params), there is $method=new ReflectionMethod($controller, $methodName);
$method->getName() returns false, while $method->name returns properly ‘actionView’.
- CInlineAction::runWithParams($params) leads to CAction::runWithParamsInternal($object, $method, $params), where again $param->getName() returns false and $param->name returns properly ‘id’.
So the view page is rendered properly if $name= $param->getName() is replaced by $name= $param->name or is replaced by $name= $param->getName() ? $param->getName() : $param->name;
Am I doing something wrong? Thank you.