General Category > Bug Reports
Logic to check if controller class file exists is wrong
(1/1)
murugaprabum:
I am a new user trying TinyMVC for the first time. I have placed the htdocs directory in my webroot. I have placed the tinymvc folder in a directory above the web root. I created a new controller as given in the wiki. When I try to access it, I am still seeing the default output that you get when you hit the index.php. To know what is happening behind the screen, I opened the file index.php and found it is instantiating a class 'tmvc' defined in tinymvc/sysfiles/TinyMVC.php. Inside is a function setupController() which routes the request to the corresponding controller.
--- Code: ---
if(!file_exists($controller_file))
{
$controller_name = $this->config['default_controller'];
$controller_file = "{$controller_name}.php";
}
--- End code ---
Inside the function, there exists a file_exists of the controller file. The value of it in my case is hello.php located in tinymvc/myapp/controllers/ . Since the value of $controller_file is hello.php and file_exists checks for the presence of the file in the current working directory, it is not invoking the appropriate controller. If I comment the if file_exists check, my controller gets invoked.
sabuwona:
I'm a TinyMVC rookie (as well)
My solution to this problem is:
--- Code: --- /* if no controller, use default */
if(!stream_resolve_include_path($controller_file))
{
$controller_name = $this->config['default_controller'];
$controller_file = "{$controller_name}.php";
}
--- End code ---
mohrt:
patched in SVN.
Navigation
[0] Message Index
Go to full version