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

Fatal PHP error when saving elements with URL's that use a Site with no base URL. #3624

Closed
gustavs-gutmanis opened this issue Jan 14, 2019 · 1 comment

Comments

@gustavs-gutmanis
Copy link
Contributor

Description

When saving any element that is supposed to have an URL which uses a Site that does not have a base URL, the following exception is thrown:
TypeError: Return value of craft\models\Site::getBaseUrl() must be of the type string, null returned

Steps to reproduce

  1. Have a Craft 3.1 install with more than one Site
  2. Edit any of the Sites in CP settings and untick the This site has its own base URL, so that it does not have a base URL.
  3. Create a new Section and fill out the Entry URI format and Template for the Site that you unticked the base URL setting for.
  4. Go and create a new Entry for that Section and you should be presented with the following error:
An Error occurred while handling another error:
TypeError: Return value of craft\models\Site::getBaseUrl() must be of the type string, null returned in /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/models/Site.php:105
Stack trace:
#0 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/helpers/UrlHelper.php(333): craft\models\Site->getBaseUrl()
#1 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/helpers/UrlHelper.php(514): craft\helpers\UrlHelper::baseSiteUrl()
#2 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/helpers/UrlHelper.php(229): craft\helpers\UrlHelper::_createUrl('', '', NULL, false)
#3 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/assets/cp/CpAsset.php(237): craft\helpers\UrlHelper::siteUrl()
#4 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/assets/cp/CpAsset.php(91): craft\web\assets\cp\CpAsset->_craftData()
#5 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/web/View.php(266): craft\web\assets\cp\CpAsset->registerAssetFiles(Object(craft\web\View))
#6 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/View.php(1482): yii\web\View->registerAssetFiles('craft\\web\\asset...')
#7 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/web/View.php(264): craft\web\View->registerAssetFiles('craft\\web\\asset...')
#8 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/View.php(1482): yii\web\View->registerAssetFiles('Solspace\\Calend...')
#9 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/web/View.php(162): craft\web\View->registerAssetFiles('Solspace\\Calend...')
#10 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/View.php(876): yii\web\View->endBody()
#11 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/views/errorHandler/exception.php(526): craft\web\View->endBody()
#12 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/base/View.php(336): require('/Users/gustavs/...')
#13 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/base/View.php(254): yii\base\View->renderPhpFile('/Users/gustavs/...', Array)
#14 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/web/ErrorHandler.php(266): yii\base\View->renderFile('/Users/gustavs/...', Array, Object(craft\web\ErrorHandler))
#15 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/web/ErrorHandler.php(126): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
#16 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/ErrorHandler.php(132): yii\web\ErrorHandler->renderException(Object(TypeError))
#17 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/yiisoft/yii2/base/ErrorHandler.php(111): craft\web\ErrorHandler->renderException(Object(TypeError))
#18 /Users/gustavs/dev/php/solspace/installs/craft31/vendor/craftcms/cms/src/web/ErrorHandler.php(63): yii\base\ErrorHandler->handleException(Object(TypeError))
#19 [internal function]: craft\web\ErrorHandler->handleException(Object(TypeError))
#20 {main}

Additional info

  • Craft version: 3.1.0-beta.7
  • PHP version: 7.2.12
  • Database driver & version: mysql-8.0.12
  • Plugins & versions: Solspace Calendar 2.0.12
brandonkelly added a commit that referenced this issue Jan 15, 2019
@brandonkelly
Copy link
Member

Fixed for the next release. Thanks!

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

No branches or pull requests

2 participants