Skip to content

Commit

Permalink
Merge pull request #3798 from carlcs/develop
Browse files Browse the repository at this point in the history
Don’t warn about manually set @web
  • Loading branch information
brandonkelly authored Feb 7, 2019
2 parents dd3c72c + 2b34601 commit 2776b84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/templates/_includes/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@
: 'This can be set to an environment variable.'|t('app'))
~ ' <a href="https://docs.craftcms.com/v3/config/environments.html" class="go">' ~ 'Learn more'|t('app') ~ '</a>'
}) %}
{% elseif config.warning is not defined and (value == '@web' or value[0:5] == '@web/') %}
{% elseif config.warning is not defined and (value == '@web' or value[0:5] == '@web/') and craft.app.request.isWebAliasSetDynamically %}
{% set config = config|merge({
warning: 'The `@web` alias is not recommended.'|t('app')
warning: 'The `@web` alias is not recommended if it is determined automatically.'|t('app')
}) %}
{% endif %}
{% endif %}
Expand Down
16 changes: 16 additions & 0 deletions src/web/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class Request extends \yii\web\Request
*/
private $_actionSegments;

/**
* @var bool
*/
private $_isWebAliasSetDynamically = false;

/**
* @var bool
*/
Expand Down Expand Up @@ -156,6 +161,7 @@ public function init()
}
if (Craft::getRootAlias('@web') === false) {
Craft::setAlias('@web', $this->getHostInfo() . $this->getBaseUrl());
$this->_isWebAliasSetDynamically = true;
}

$generalConfig = Craft::$app->getConfig()->getGeneral();
Expand Down Expand Up @@ -447,6 +453,16 @@ public function getActionSegments()
return $this->_actionSegments;
}

/**
* Returns whether the `@web` alias is set dynamically.
*
* @return bool Whether the `@web` alias is set dynamically.
*/
public function getIsWebAliasSetDynamically(): bool
{
return $this->_isWebAliasSetDynamically;
}

/**
* Returns whether this is a Live Preview request.
*
Expand Down

0 comments on commit 2776b84

Please sign in to comment.