jenssegers / jenssegers/codeigniter-hmvc-modules

Relative path issue & fix

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
187
Forks
102
PR merge metrics
No merged PRs in 30d

Description

In `core/Codeigniter.php` lines 402, 408, there is a reference to this path:
`APPPATH.'controllers/'.$RTR->directory.$class.'.php'`
Normally, this works, but for users using custom loaders (like HVMC), it creates a problem on some machines.
It tries to access `application/controllers/../modules/countries/controllers/Countries/index`
Which on some machines translate correctly to `application/modules/countries/controllers/Countries/index`
And on some returns 404

A solution to that is using your own path resolver, something like:
Replace 402-408

```
function resolve_path($path) {
$stack = [];
foreach(explode('/', $path) as $segment)
if($segment == "..")
array_pop($stack);
else
$stack[] = $segment;
return implode('/', $stack);
}
$controller_path = resolve_path(APPPATH.'controllers/'.$RTR->directory.$class.'.php');

if (empty($class) OR ! file_exists($controller_path))
{
$e404 = TRUE;
}
else
{
require_once($controller_path);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.