Skip to content
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

Change order of autoload file import #25

Conversation

raissanorth
Copy link

This will ensure the autoload file is first searched for within the project itself, rather than outside of it.

@dhensby
Copy link
Contributor

dhensby commented Jun 12, 2018

This is a revert of #19 and I'm not sure I see the logic in making it.

As it stands (before this PR) is that the first location is not "outside the project" it's the project folder, the second location checked is the public folder (which is basically fallback logic in case you moved your index out of public and into the project root).

Especially in master, where we're going to mandate the public folder, I think this change makes little sense and we should really just remove the check in the current directory.

Copy link
Contributor

@dhensby dhensby left a comment

Choose a reason for hiding this comment

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

as per feedback

@tractorcow
Copy link

In 5.x we want to make public mandatory; Then we should ONLY check '/../vendor/autoload.php'.

@tractorcow
Copy link

Looking at the code it doesn't seem we've enforced public dir yet.

@robbieaverill
Copy link
Contributor

robbieaverill commented Jun 12, 2018

For context here:

  • composer create-project cwp/cwp-recipe-core ./cwp2-core 2.1.x-dev (includes recipe-core 1.2.x-ev)
  • no public web root is created
  • the first autoload call looks up a level from the project web root

In this case the folder above the project had had compose require foo run in it (mistake, but it happens and often doesn't become obvious), so had its own autoloader, and this order of logic was loading that autoloader rather than the one in the project. This lead to quite an annoying amount of head scratching and repeated cache flushing to work out why classes couldn't be found.

Side note: CWP 2 enforces the public webroot but it doesn't look like the cwp/cwp-recipe-core recipe does on its own. It should (I'll log a separate issue for this -> silverstripe/cwp-recipe-core#10).

@tractorcow
Copy link

Ok suggested this at silverstripe/silverstripe-framework#8168

@tractorcow
Copy link

@robbieaverill because it's opt-in for framework 4.x you need to physically add the public folder to the git repo for cwp-recipe-core.

@tractorcow
Copy link

@robbieaverill we can fix the issue by checking that basename(__DIR__) === 'public' as an added precaution.

@robbieaverill
Copy link
Contributor

Right - public isn't a configurable name at the moment is it?

@tractorcow
Copy link

Correct. You can only have it or not have it.

I've already vehemently vetod the ability to soft-code the name of the folder. We hard-code it in many places, including composer plugins, which don't have the ability to read silverstripe config.

@robbieaverill robbieaverill deleted the pulls/master/change-order-of-autoload-file-import branch June 12, 2018 23:40
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.

4 participants