Skip to content

Add an option for setup:config:set to define the document root #29176

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

Closed
wants to merge 11 commits into from

Conversation

AntonEvers
Copy link
Contributor

@AntonEvers AntonEvers commented Jul 16, 2020

Description (*)

Add bin/magento setup:config:set --document-root-is-pub
I think this is needed in order to raise awareness for https://devdocs.magento.com/guides/v2.3/install-gde/tutorials/change-docroot-to-pub.html section 3, and to simplify automating this setting in deployment scripts.

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Add an option for setup:config:set to define the document root #29523: Add an option for setup:config:set to define the document root

@m2-assistant
Copy link

m2-assistant bot commented Jul 16, 2020

Hi @AntonEvers. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@AntonEvers
Copy link
Contributor Author

@magento run all tests

@ihor-sviziev ihor-sviziev self-assigned this Jul 17, 2020
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

@AntonEvers good idea!
Could you cover this new command with any kind of test? I think unit will be ok there.

Based on the description i have few questions:

  1. What if we'll run just bin/magento setup:config:set --document-root-is-pub? Will it set to "true" or it will ask for setting true / false?
  2. What if we'll run just bin/magento setup:config:set --document-root-is-pub true? Will it set to "true"?
  3. What if we'll run bin/magento setup:config:set --document-root-is-pub false? Will it set it as "false"?

Would be nice to have more clear description for the command option

@AntonEvers
Copy link
Contributor Author

@AntonEvers good idea!
Could you cover this new command with any kind of test? I think unit will be ok there.

Based on the description i have few questions:

  1. What if we'll run just bin/magento setup:config:set --document-root-is-pub? Will it set to "true" or it will ask for setting true / false?
  2. What if we'll run just bin/magento setup:config:set --document-root-is-pub true? Will it set to "true"?
  3. What if we'll run bin/magento setup:config:set --document-root-is-pub false? Will it set it as "false"?

Would be nice to have more clear description for the command option

Hi @ihor-sviziev
The command option currently works similar to --allow-parallel-generation, --skip-db-validation, --db-ssl-verify, --cleanup-database and --use-sample-data.
It is a flag, rather than an option and it does not allow a value. bin/magento setup:config:set --document-root-is-pub would add the following to env.php:

'directories' => [
    'document_root_is_pub' => true
]

I will add some unit testing. Please let me know if the command should behave more like --use-secure=USE-SECURE instead, to allow setting it both to true or false.

@AntonEvers
Copy link
Contributor Author

I changed the command to a boolean select option.
During interactive installation it will now asK:

Is the webserver's document root set to ./pub/?
  [0] no
  [1] yes

It accepts inputs: yes, no, 1, 0, true, false.

@AntonEvers
Copy link
Contributor Author

Now I have set the default value to false, so that the key is always present in env.php. This should make developers more aware of the fact that this option exists.

@ihor-sviziev
Copy link
Contributor

From first look - looks good!
@magento run all tests

@ihor-sviziev ihor-sviziev added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Jul 17, 2020
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Hi @AntonEvers ,
Could you fix static tests? Everything else looks good

@AntonEvers
Copy link
Contributor Author

@magento run Static Tests

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@ihor-sviziev
Copy link
Contributor

Looks like that’s last part of requests changes, sorry for not requesting them earlier.

@AntonEvers
Copy link
Contributor Author

No problem at all @ihor-sviziev!

@AntonEvers
Copy link
Contributor Author

@magento run all tests

ihor-sviziev
ihor-sviziev previously approved these changes Jul 27, 2020
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

✔ Approved.

Failing tests looks not related to changes form this PR.

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-7889 has been created to process this Pull Request

@engcom-Alfa engcom-Alfa self-assigned this Jul 28, 2020
@gabrieldagama
Copy link
Contributor

@magento run all tests

@gabrieldagama
Copy link
Contributor

@magento run all tests

@sidolov
Copy link
Contributor

sidolov commented Sep 14, 2020

@magento run all tests

@ihor-sviziev
Copy link
Contributor

@gabrieldagama @sidolov is there any reasons why this PR isn't getting merged?

@gabrieldagama
Copy link
Contributor

@ihor-sviziev We are having some issues with its tests that are being looked at internally. Just for reference, the internal ticket is https://jira.corp.magento.com/browse/MTS-1593

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Nov 11, 2020

Hi @AntonEvers,
According to the recent changes in 2.4-develop - the support of non-pub was removed and now Magento always uses the pub directory (finally👍) .
640cad5#diff-2323d6157444b3cf24d4d76635f27185a4e6ad979b0ec2af53e6592d3ca465d5R13

Due to this change I think we could close this PR as not relevant anymore.
What do you thing?

@m2-assistant
Copy link

m2-assistant bot commented Nov 11, 2020

Hi @AntonEvers, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@hostep
Copy link
Contributor

hostep commented Nov 11, 2020

@ihor-sviziev: nice find!

But I really don't understand how they can make such a major change in a minor release? This change will probably be scheduled for Magento 2.4.2, even though it should be for 2.5.0. This might break a lot of installations.

I'm not saying it's a bad thing, it should have happened much earlier, but big changes like these really shouldn't be done in a minor release.

(sorry to interrupt here in this PR)

@ihor-sviziev
Copy link
Contributor

@sivaschenko @sidolov could you provide more info why this commit was merged to 2.4-develop as it's introducing backward incompatible changes? 640cad5#diff-2323d6157444b3cf24d4d76635f27185a4e6ad979b0ec2af53e6592d3ca465d5R13

@shiftedreality
Copy link
Member

@hostep we updated Apache config to use pub directory. Since Apache reads configs on-fly, we didn't notice any issue having it updated.

This solves a few issues:

  • Deprecates usage of \Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot. This class was added but not used in the places where it should.
  • Standardizes pub directory paths all over magento without class above
  • Standartazise both Apache and Nginx entrypoints

Without this change, we saw a lot of issues while adding RemoteStorage functionality and saw possible issues for developers who work with FS API.

Could you provide any possible risks which we might miss?

@hostep
Copy link
Contributor

hostep commented Nov 11, 2020

@shiftedreality: I understand why this is a good improvement, it really is, I and many others have been wanting it even 2 years before Magento 2.0.0 was launched.

But where I'm seeing problems is that certain users now will be surprised when they perform a minor update and notice they have to change their document root and somehow can't. I'm pretty sure that there are (cheap) hosting companies around which don't allow you to change the document root and make it very difficult to host magento from inside the pub directory. Which is a shame and people shouldn't use these sort of hosting companies, but yes, a lot of people want cheap hosting... So I think it only makes sense to introduce such a big change in a major release like 2.5.0 to avoid breaking shops just because they made a wrong decision in choosing a certain hosting company.
If that's really not possible and it needs to be shipped in 2.4.x, then the release notes will have to add a very big warning on top (and not hidden in the hundreds of changes) so that users are aware of this change.

@shiftedreality
Copy link
Member

@hostep my understanding is those Customers have an Apache which reads .htaccess file. So, it should be supported fine, since the file is updated. Isn't this standard case for Apache on hosting companies?

@hostep
Copy link
Contributor

hostep commented Nov 11, 2020

The .htaccess file in the Magento root is deleted, so I'm not sure what you are saying?
Also, you can not change the document root from a .htaccess file as far as I'm aware.

@shiftedreality
Copy link
Member

@hostep
Copy link
Contributor

hostep commented Nov 11, 2020

Aaaaaah ok, the github interface tricked me, I assumed it was removed when I saw all those red blocks 😄
Okay, thanks for the explanation, those new lines in there will probably solve it (untested), sorry about the noise! 🙂

@shiftedreality
Copy link
Member

Sure, thank you for paying so much attention and passion for Magento!

@ihor-sviziev
Copy link
Contributor

@shiftedreality thx for good explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage Component: Config Component: Developer Component: Filesystem Component: MessageQueue Component: Setup Priority: P3 May be fixed according to the position in the backlog. QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Risk: medium Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Add an option for setup:config:set to define the document root
10 participants