-
Notifications
You must be signed in to change notification settings - Fork 42
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
Class finder loads files it should not load #241
Comments
@enricobono see discussion in this issue alekitto/class-finder#24 |
Thanks Andrii. I'd propose the opposite:
What do you think? |
@enricobono seems like a useful configuration. But I suggest preserving the current behavior by default and making it opt-out (configured to use a path like an |
Make sense, thanks. |
@enricobono it's not searching everywhere, but in relevant namespaces according to the dependencies (and project itself) - If package configured autoload like this [1], it leads to "full scan" - so this is architecture limitation of [1]
|
We were in the process of upgrading our application from
graphqlite
v6 to v8, and we discovered an issue with v8.This is a consequence of what was introduces here: thecodingmachine/graphqlite#657.
With this PR,
graphqlite
will now look for Types not only in thesrc/
space, but in the vendors as well. Which bwt is totally legit. To reach this goal, the class explorer package was replaced withkcs/class-finder
.Now, we notices that, in the dev environment,
kcs/class-finder
was looking for all the classes in thevendor/
directory and in thetests/
directory as well. It iterates over all the .php files, looking for classes:The issue now is that
class_exists
will include the file, if not already loaded.In our case, we have a
tests/bootstrap.php
file which contains plain code, no class declarations.So
kcs/class-finder
will doclass_exists('tests/bootstrap.php', true)
, the file will be included and its content executed. So we are basically executing every php file (which does not contain a class) in bothvendor/
andtests/
. Which should not be the case. For example, in our case, a simple run of:will execute the
tests/bootstrap.php
, which has implementation specific for thetest
env.And, moreover, it may pose some security issue, given it will execute any code in any plain php file in any
vendor/
subfolder.Moreover, as per the current configuration,
kcs/class-finder
is called several times, so it requests the lists of files many times in each session, which means ourtests/bootstrap.php
file is included more than once, which causes other issues and makes the process slower.Has anybody else experienced similar issues related to this?
The text was updated successfully, but these errors were encountered: