Skip to content

Conversation

@remicollet
Copy link
Collaborator

Lot of noise related to php-cs-fixer run...

@siwinski
Copy link
Member

If we are going to do this, shouldn't all array dependencies be checked?

For example:

First autoload file:

\Fedora\Autoloader\Dependencies::required(array(
    '/usr/share/php/PhpParser/autoload.php',
));

Second autoload file:

\Fedora\Autoloader\Dependencies::required(array(
    '/usr/share/php/PhpParser3/autoload.php',
    '/usr/share/php/PhpParser2/autoload.php',
    '/usr/share/php/PhpParser/autoload.php',
));

/usr/share/php/PhpParser/autoload.php would have already been loaded via the first autoload file, but then /usr/share/php/PhpParser3/autoload.php would be loaded by the second autoload file even though one of the autoload files from the array of dependencies was already loaded.

@remicollet
Copy link
Collaborator Author

Sorry, but I think your example doesn't really make sense, your are not going to require 3 versions of PhpParser ;)
See the unit which should be more close to real case.

@remicollet
Copy link
Collaborator Author

remicollet commented Dec 22, 2016

BTW some cases are not fixed by this PR,

Ex:

\Fedora\Autoloader\Dependencies::required(array(
  array(
    '/usr/share/php/PhpParser3/autoload.php',
    '/usr/share/php/PhpParser2/autoload.php',
    '/usr/share/php/PhpParser/autoload.php',
)));

Then

\Fedora\Autoloader\Dependencies::required(array(
    '/usr/share/php/PhpParser/autoload.php',
));

In this case PhpParser3 will be load, while the second package is not compatible.

So autoloader order is still very important (owncloud case)

This PR is only design to avoid loading PhpParser3 when PhpParser is already load, so when autoloader order is correct.

@siwinski
Copy link
Member

Sorry, but I think your example doesn't really make sense, your are not going to require 3 versions of PhpParser ;)

Yeah, sorry. That's what I get for typing that up while I was in a meeting. Here's the correct example I was trying to type out:

First autoload file:

\Fedora\Autoloader\Dependencies::required(array(
    '/usr/share/php/PhpParser/autoload.php',
));

Second autoload file:

\Fedora\Autoloader\Dependencies::required(array(
    array(
        '/usr/share/php/PhpParser3/autoload.php',
        '/usr/share/php/PhpParser2/autoload.php',
        '/usr/share/php/PhpParser/autoload.php',
    )
));

See the unit which should be more close to real case.

This PR is only design to avoid loading PhpParser3 when PhpParser is already load, so when autoloader order is correct.

My example is almost exactly the test case. Sorry, I also misread the diff and missed that first loop through the entire dependency array to check if any of the dependencies are loaded.

@siwinski siwinski merged commit 2626d64 into master Dec 22, 2016
@siwinski siwinski deleted the issue-12 branch December 22, 2016 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants