chamilo / chash

Chamilo Shell
GNU General Public License v3.0
15 stars 10 forks source link

getSysPath() returns empty on 1.9.8 portals #36

Closed ywarnier closed 10 years ago

ywarnier commented 10 years ago

I have something close to a 1.9.8 version, and inside the getDataFolders() method (of ConfigurationHelper), the following line returns an empty string:

$sysPath = $this->getSysPath();

I believe this might be caused by recent changes to support v10, but I cannot find the exact source just yet (as I cannot find where the setSysPath() method is called from.

ywarnier commented 10 years ago

Until now, my intermediate solution is to add this in getDataFolders():

        if (empty($sysPath)) {
            $sysPath = $this->configuration['root_sys'];
            if (empty($sysPath)) {
                return null;
            }
        }
ywarnier commented 10 years ago

I traced the issue down to getSysPathFromConfigurationFile(), which erroneously tests where the main/install/index.php is located: if the Chamilo installation is properly made, this main/install directory shouldn't exist anymore (or it should not be readable, anyway).

ywarnier commented 10 years ago

This is the original code of getSysPathFromConfigurationFile():

        $configurationPath = dirname($configurationFile);

        // New structure
        if (file_exists($configurationPath.'/../../main/install/index.php')) {
            return realpath($configurationPath.'/../../').'/';
        }

        // Old structure
        if (file_exists($configurationPath.'/../../install/index.php')) {
            return realpath($configurationPath.'/../../../').'/';
        }

This is the new one:

        $configurationPath = dirname($configurationFile);

        // New structure
        if (file_exists($configurationPath.'/../../web/app.php')) {
            return realpath($configurationPath.'/../../').'/';
        }

        // Old structure
        if (file_exists($configurationPath.'/../../../user_portal.php')) {
            return realpath($configurationPath.'/../../../').'/';
        }