Skip to content

Magento modules symlinked into vendor from outside of the Magento Basedir are not watched by this module #117

@gwharton

Description

@gwharton

The

\Magento\Framework\Component\ComponentRegistrar->getPaths('module')

command returns paths outside of the magento basedir when modules are symlinked in by composer into vendor from outside of the magento basepath.

The removal of basepath from these modules path (who's path doesnt start with basepath) causes the path to be butchered by removing a fixed length string (length of basepath + 1) from the beginning of the path.

(defn- list-components-cmd
"Returns the PHP command to run to output a list of all Magento components of the given type.
Currently the base path is removed from the beginning of the paths, only to be added
again later in `list-component-dirs`. This doesn't make sense, except that I'm thinking
about allowing a different Magento base dir path for PHP commands to be specified by
the user. In that case the magento-basedir provided to this method would be a
different one than the one added back on later.
If I decide against this feature then I can remove this logic again and let PHP
return complete paths directly again.
Reference https://github.com/mage2tv/magento-cache-clean/issues/33#issuecomment-479791859"
[magento-basedir type]
(let [composer-autoload (str magento-basedir "vendor/autoload.php")]
(when-not (fs/exists? composer-autoload)
(throw (ex-info (str "Composer autoload.php not found: " composer-autoload) {})))
(unescape-php-var-on-win-os
(str "php -r "
"\"require '" composer-autoload "'; "
"\\$bp = strlen(dirname(dirname(realpath('" composer-autoload "')))) + 1; "
"foreach ((new \\Magento\\Framework\\Component\\ComponentRegistrar)->getPaths('" type "') as \\$m) "
"echo substr(\\$m, \\$bp).PHP_EOL;\""))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions