Skip to content

getAbsolutePath returns wrong path when module is out of magento root path #3328

Closed
@jalogut

Description

@jalogut

Magento new PSR-4 and registration.php features are great and allow to set modules out of the Magento root folder. This works smoothly for classes but it does not work when it has to find source files like .phtml, .js or .css.

The problem comes from the Magento\Framework\Filesystem\Driver\File::getRelativePath() method. If the module is out of the Magento root then the Magento root path is added at the beginning of an already correct absolute path. That return a completely wrong path and in consequence files are not found. From my point of view, if the path already contains a "/" at the beginning it should be treated as absolute path and there is no need to add the magento root at the beginning.

A possible solution would be like that:

public function getAbsolutePath($basePath, $path, $scheme = null)
{
    if ($path[0] == "/") {
        return $path;
    }

    return $this->getScheme($scheme) . $basePath . ltrim($this->fixSeparator($path), '/');
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions