Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Applications packaged as not capable of loading modules contained within the archive #7151

Closed
wants to merge 4 commits into from

Conversation

basz
Copy link
Contributor

@basz basz commented Jan 24, 2015

The ModuleAutoloader fails to load modules when the modules are part of the phar that contains the application.

A realpath check on phar://path/to/phar.phar/modules/Application/Module.php will return false. There no such thing as a realpath on the real filesystem for these kind of files.

This fix uses the Phar::current(true) method to find out the correct basepath of the application. Then regular loadModuleFromDir is after minor adjustment capable to load the module.php 'fromDir'.

Note existing tests still pass, but I did not write a new one for this addition. I wouldn't know how to do that for such a case.

original #7148

@Ocramius
Copy link
Member

Requiring a test case...

$file = new SplFileInfo($dirPath . '/Module.php');
if ($file->isReadable() && $file->isFile()) {
$modulePath = $dirPath . '/Module.php';
if (substr($modulePath, 0, 7) == 'phar://') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use strict comparision

@basz
Copy link
Contributor Author

basz commented Jan 26, 2015

@Ocramius : haz test

@Ocramius Ocramius added this to the 2.3.5 milestone Jan 26, 2015
@Ocramius Ocramius self-assigned this Jan 26, 2015
@Ocramius
Copy link
Member

@basz thanks, looks much better!

@basz
Copy link
Contributor Author

basz commented Jan 27, 2015

@Ocramius out of curiosity, if this lands, will it land in master when reviews are done or are you waiting with merging moments before 2.3.5 is released?

@Ocramius
Copy link
Member

@basz I'm waiting for a legendary magical beast called "free time" ;-)

I merge when I have a bit of dedicated time to do so. Yes, merge will happen before 2.3.5/2.4

@basz
Copy link
Contributor Author

basz commented Jan 27, 2015

fat

hook your magic method __sleep to __clone and time is multiplied.

thanks

@Ocramius
Copy link
Member

Ocramius commented Feb 2, 2015

@basz merged, thanks!

master: d035b6a
develop: 5aed8a9

@Ocramius Ocramius added the Loader label Feb 2, 2015
gianarb pushed a commit to zendframework/zend-loader that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-loader that referenced this pull request May 15, 2015
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants