Commit
- Loading branch information
There are no files selected for viewing
5 comments
on commit 9710b26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeskew / @Seldaek This seems like a really roundabout way to require a file only once, especially since PHP has a require_once construct which can be used to do the exact same thing this appears to be implementing. Is there a reason it was done this way instead of simply changing require to require_once?
This code change breaks the magento-composer-installer, resulting in the issue outlined on magento/magento2-community-edition#15.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidalger You may want to take a look at the discussion in #4389.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidalger This solves a different problem than require_once
. Packages installed globally are sometimes configured to load a project-local autoloader, which can cause conflicts among the autoload_files
(as described here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidalger the problem it solves is not that of require_once, it's solving having multiple times the same file added in a global dependency and a local one.
It seems the problem in magento is that the file does not yet exist when the autoloader is dumped. I changed the algo in 8072448 to use only the package name + path for the hash. That should solve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Seldaek Thanks for the added context! It makes a lot more sense now…
Yes, in this case, these files are copied into place via the magento/magento-composer-installer plugin which I guess does not run until after the auto-loader is dumped, as you noted. I've updated my composer and re-run the test which reproduced the issue, and your fix resolved it. Thanks for the quick response! :) Think I like the new solution better too because it won't have to load a bunch of files from disk, meaning quicker autoloader generation.
IMO, the var_export should be done when writing the code, not here