-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
add document root check for vcl generation #25360
Conversation
Hi @torhoehn. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @torhoehn Please check my comments and fix the failing tests.
Thanks
remove line fix tests fix codestyle fix code style again
@rodrigowebjump Fixed tests, but couldn‘t find any comments. |
@@ -67,6 +74,7 @@ public function __construct( | |||
$accessList, | |||
$gracePeriod, | |||
$sslOffloadedHeader, | |||
DirectoryList $directoryList, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@torhoehn The new param should come as last one.
See: https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/
Add a new constructor param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. I fixed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigowebjump One of the test says, that arguments with default values must be at the end of the argument list. Should I undo my latest changes or add the DirectoryList as optional parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigowebjump I think everything looks fine now. :)
@@ -67,7 +74,8 @@ public function __construct( | |||
$accessList, | |||
$gracePeriod, | |||
$sslOffloadedHeader, | |||
$designExceptions = [] | |||
$designExceptions = [], | |||
DirectoryList $directoryList = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi you also need to add the DirectoryList as optional ?DirectoryList $directoryList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigowebjump This isn't mentioned in DevDocs (https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/#php), so im not sure about that.
public function __construct(
\Old\Dependency\Interface $oldDependency,
$oldRequiredConstructorParameter,
$oldOptionalConstructorParameter = null,
\New\Dependency\Interface $newDependency = null
) {
...
$this->newDependency = $newDependency ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\New\Dependency\Interface::class);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @torhoehn
This is a good practice.
I create a PR for this magento/devdocs#6033
It's is supported since PHP 7.1 (https://www.php.net/manual/en/migration71.new-features.php) and is recommended when adding a nullable param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigowebjump Okay, I added it. :)
@magento give me test instance |
Hi @rodrigowebjump. Thank you for your request. I'm working on Magento instance for you |
Hi @rodrigowebjump, here is your new Magento instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @torhoehn
Thanks for your contribution
Pull Request state was updated. Re-review required.
@engcom-Alfa So you configured the document root instead of the Base URL pointing to 'pub' directory? @sivaschenko Maybe we should check the request and the Base URL if one of them contains 'pub'? |
*/ | ||
private function getHealthCheck() : string | ||
{ | ||
if (strpos($this->url->getBaseUrl(), 'pub') === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@torhoehn missed that during the review, sorry. If base url contains pub
- health check should also contain pub
and vice-versa
if (strpos($this->url->getBaseUrl(), 'pub') === false) { | |
if (strpos($this->url->getBaseUrl(), 'pub') !== false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it.
Hi @sivaschenko, thank you for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @torhoehn.
During testing, we faced the issue.
Problem: If base url contains /pub
health check also contain pub
and everything works well. But, if base url doesn't contain /pub
health check also doesn't contain 'pub' and we will get an 503 error.
Manual testing scenario:
- Configure Base URL pointing to 'pub' directory ('
http://magento24.loc/pub/
' in my case); - Go to Admin->Stores->Configuration->Advanced->System->Full Page Cache;
- Choose "Varnish Cache" from "Caching Application" drop-down and click on "Save" button;
- Then click on "Export VCL for Varnish 6" button and open it;
- Copy the file to the /etc/varnish/ directory;
- Open home page;
- Configure Base URL to default ('
http://magento24.loc/
' in my case); - Repeat steps 2-4;
- Copy the file to the /etc/varnish/ directory;
- Open home page;
Actual Result: ✖️ 503 Backend fetch failed
@torhoehn @sivaschenko Could you take a look?
Thanks!
Pull Request state was updated. Re-review required.
@engcom-Alfa @sivaschenko So depending on the Base URL the health check should always contain |
@engcom-Alfa have you changed the webserver configuration to be pointed to |
@sivaschenko yes, Magento is accessible at http://magento24.loc/ on 7th step |
@sivaschenko , @engcom-Alfa , @torhoehn guys, any updates on it? |
@sivaschenko Any idea? |
@torhoehn do you have the same test results on your environment? |
Hi @torhoehn, I'm closing this PR now due to inactivity. |
Hi @torhoehn, thank you for your contribution! |
Description (*)
#11692
Manual testing scenarios (*)
Contribution checklist (*)