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

[5.x]: Craft 4 link field content can trigger exception after Craft 5 upgrade #16212

Closed
michaelij opened this issue Nov 26, 2024 · 2 comments
Closed
Assignees
Labels

Comments

@michaelij
Copy link

michaelij commented Nov 26, 2024

What happened?

Description

In a starter site, I have link fields set with placeholder content of https:// so that they are not blank and appear on the frontend. Upon upgrading to Craft 5, editing entries with these fields throws an exception and requires a manual database update to make that page accessible again.

The frontend still works without exception.

Steps to reproduce

  1. On Craft 4, have a saved entry with a link field that contains this as the link: https://#
  2. Perform an upgrade to Craft 5
  3. Attempt to edit the entry

Expected behavior

The entry page loads successfully, perhaps with a validation error.

Totally happy that those URLs are considered invalid, but the prior link field allowed them to save.

Actual behavior

Admin page is unavailable with this exception.

League\Uri\Exceptions\SyntaxError: The uri `https://#` is invalid for the `https` scheme. in /var/www/html/vendor/league/uri/Uri.php:885
Stack trace:
#0 /var/www/html/vendor/league/uri/Uri.php(239): League\Uri\Uri->assertValidState()
#1 /var/www/html/vendor/league/uri/Uri.php(398): League\Uri\Uri->__construct('https', NULL, Object(SensitiveParameterValue), '', NULL, '', NULL, '')
#2 /var/www/html/vendor/craftcms/cms/src/fields/linktypes/Url.php(80): League\Uri\Uri::new('https://#')
#3 /var/www/html/vendor/craftcms/cms/src/fields/linktypes/BaseTextLinkType.php(90): craft\fields\linktypes\Url->validateValue('https://#')
#4 /var/www/html/vendor/craftcms/cms/src/fields/Link.php(554): craft\fields\linktypes\BaseTextLinkType->inputHtml(Object(craft\fields\Link), 'https://#', 'fields-youtubeL...')
#5 /var/www/html/vendor/craftcms/cms/src/web/View.php(1777): craft\fields\Link->craft\fields\{closure}()
#6 /var/www/html/vendor/craftcms/cms/src/fields/Link.php(553): craft\web\View->namespaceInputs(Object(Closure), 'youtubeLink[url...')
#7 /var/www/html/vendor/craftcms/cms/src/base/Field.php(682): craft\fields\Link->inputHtml(Object(craft\fields\data\LinkData), Object(craft\elements\Entry), false)
#8 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(404): craft\base\Field->getInputHtml(Object(craft\fields\data\LinkData), Object(craft\elements\Entry))
#9 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(365): craft\fieldlayoutelements\CustomField->inputHtml(Object(craft\elements\Entry), false)
#10 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(355): craft\fieldlayoutelements\BaseField->formHtml(Object(craft\elements\Entry), false)
#11 /var/www/html/vendor/craftcms/cms/src/web/View.php(1777): craft\fieldlayoutelements\CustomField->craft\fieldlayoutelements\{closure}()
#12 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(354): craft\web\View->namespaceInputs(Object(Closure), 'fields')
#13 /var/www/html/vendor/craftcms/cms/src/models/FieldLayout.php(1015): craft\fieldlayoutelements\CustomField->formHtml(Object(craft\elements\Entry), false)
#14 /var/www/html/vendor/craftcms/cms/src/web/View.php(1771): craft\models\FieldLayout->craft\models\{closure}()
#15 /var/www/html/vendor/craftcms/cms/src/models/FieldLayout.php(1014): craft\web\View->namespaceInputs(Object(Closure), NULL)
#16 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(937): craft\models\FieldLayout->createForm(Object(craft\elements\Entry), false, Array)
#17 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(411): craft\controllers\ElementsController->_prepareEditor(Object(craft\elements\Entry), false, true, Object(craft\web\Response), 'main-form', Object(Closure), Object(Closure), Object(Closure))
#18 [internal function]: craft\controllers\ElementsController->craft\controllers\{closure}(Object(craft\web\Response), 'main-form')
#19 /var/www/html/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(125): call_user_func(Object(Closure), Object(craft\web\Response), 'main-form')
#20 /var/www/html/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(50): craft\web\CpScreenResponseFormatter->_formatTemplate(Object(craft\web\Response), Object(craft\web\CpScreenResponseBehavior))
#21 /var/www/html/vendor/yiisoft/yii2/web/Response.php(1109): craft\web\CpScreenResponseFormatter->format(Object(craft\web\Response))
#22 /var/www/html/vendor/craftcms/cms/src/web/Response.php(339): yii\web\Response->prepare()
#23 /var/www/html/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#24 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#25 /var/www/html/web/index.php(12): yii\base\Application->run()
#26 {main}

Craft CMS version

5.5.3

PHP version

8.2.24

Operating system and version

Linux 6.10.4-linuxkit

Database type and version

MySQL 8.0.36

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

"carlcs/craft-diywidget": "4.1.1",
"craftcms/ckeditor": "4.4.0",
"craftcms/cms": "^5.0.0",
"ether/seo": "5.0.0",
"miranj/craft-obfuscator": "1.2.0",
"mmikkel/cp-clearcache": "2.0.1",
"mmikkel/cp-field-inspect": "2.0.2",
"nystudio107/craft-twigpack": "5.0.0",
"verbb/default-dashboard": "3.0.1",
"verbb/expanded-singles": "3.0.1",
"verbb/field-manager": "4.0.3",
"verbb/super-table": "4.0.2",
"vlucas/phpdotenv": "^5.6.1",
"xpertbot/craft-wheelform": "4.0.2"
@i-just
Copy link
Contributor

i-just commented Nov 26, 2024

Hi, thanks for reporting! I raised a PR for this.

@brandonkelly
Copy link
Member

Craft 5.5.4 is out with that fix. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants