Skip to content

Loading…

Fix for Hmvc lite subfolder default controller handling #853

Merged
merged 1 commit into from

2 participants

@tomcode

When the URL would only contain the subfolder but not the controller
name, the used routine was wrong.

example URL: http://example.com/index.php/subfolder/

  1. use of array_unshift instead of array_shift
  2. since we're in a subfolder, the $default segments contain the directory as first segment
@tomcode tomcode Router.php: Fix validate_route() for default controller in subfolder
When the URL would only contain the subfolder but not the controller
name, the used routine was wrong.
0f3d6d1
@narfbg narfbg merged commit a6e1698 into bcit-ci:hmvc-lite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 1, 2012
  1. @tomcode

    Router.php: Fix validate_route() for default controller in subfolder

    tomcode committed
    When the URL would only contain the subfolder but not the controller
    name, the used routine was wrong.
Showing with 10 additions and 3 deletions.
  1. +10 −3 system/core/Router.php
View
13 system/core/Router.php
@@ -273,9 +273,14 @@ public function validate_route($route)
continue;
}
- // Get class and method
- $class = array_unshift($default);
- $method = array_unshift($default);
+ // Get class and method:
+ // - index 0 and 1 are always present
+ // - since we are in a sub-folder the
+ // first entry is now the directory
+ $directory = array_shift($default);
+ $class = array_shift($default);
+ // the $default route may not have the method set
+ $method = count($default) ? array_shift($default) : 'index';
}
// Does the requested controller exist in the sub-folder?
@@ -534,6 +539,8 @@ public function _set_overrides($routing)
/**
* Get segments of default controller
*
+ * Returns at least two segments
+ *
* @access protected
* @return array array of segments
*/
Something went wrong with that request. Please try again.