New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoloader is not deterministic and possibly performs too many file stats #9619

Closed
bantu opened this Issue Jul 14, 2014 · 3 comments

Comments

Projects
None yet
6 participants
@bantu
Copy link
Member

bantu commented Jul 14, 2014

When the autoloader currently receives a class to be loaded, it generates an array of possible paths that class may be found in. Furthermore it uses stream_resolve_include_path() to resolve these paths. This leads to a lot of unncessary "does that file exist" checks and provokes issues like #9524.

To fix this problem, the autoloader should be made entirely deterministic. That means, given a class name, the autoloader should take that class name and transform it into a file path (deterministically, without looking at the filesystem). Only this single file should be tried to be loaded.
If the file does not exist, an error should be generated (either hard by just using require or soft by performing file_exists() on that single file).
Furthermore the ownCloud autoloader should not make use of stream_resolve_include_path(). This should only be necessary for legacy libraries. These can probably be loaded via the Composer autoloader which ensures only necessary paths are traversed.

Please note that deterministic does not mean that different prefixes can not be used. It will still allow mapping the OCP prefix to the lib/public folder and OC to the lib/private folder.

@bantu bantu added the Tech. Debt label Jul 14, 2014

@bantu bantu changed the title Autoloader is not deterministic and possibly performs too many file stats() Autoloader is not deterministic and possibly performs too many file stats Jul 14, 2014

@AdamWill

This comment has been minimized.

Copy link
Contributor

AdamWill commented Jul 15, 2014

I filed #9643 to cover the bit about using Composer's autoloader (not OC's) to handle bundled libraries.

@bantu

This comment has been minimized.

Copy link
Member Author

bantu commented Jul 16, 2014

The "searching in all possible paths" feature might be in use by core apps. See e.g. https://github.com/owncloud/core/blob/master/apps/files_external/lib/owncloud.php which defines a class OC\Files\Storage\OwnCloud. This breaks determinism.

@MorrisJobke

This comment has been minimized.

Copy link
Member

MorrisJobke commented Jan 19, 2016

This is more or less a duplicate of #13241 -> closing.

@MorrisJobke MorrisJobke removed this from the backlog milestone Jan 19, 2016

@DeepDiver1975 DeepDiver1975 added this to the backlog milestone Jan 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment