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]: Internal server error - shortcodesToEmoji #14782

Closed
samdi opened this issue Apr 10, 2024 · 5 comments
Closed

[5.x]: Internal server error - shortcodesToEmoji #14782

samdi opened this issue Apr 10, 2024 · 5 comments
Labels

Comments

@samdi
Copy link

samdi commented Apr 10, 2024

What happened?

In the production craftcms admin, I cannot access SOME structure entries due to this error:

craft\helpers\StringHelper::shortcodesToEmoji(): Argument #1 ($str) must be of type string, array given, called in /vendor/craftcms/cms/src/fields/PlainText.php on line 166

Screenshot: https://i.imgur.com/VLcEfZi.png https://i.imgur.com/XNIkppc.png

Other entries are accessible. I also cannot disable those entries with the error shortcodesToEmoji.

In frontend: https://i.imgur.com/ii9dsLJ.png

An Error occurred while handling another error:
TypeError: craft\helpers\StringHelper::shortcodesToEmoji(): Argument #1 ($str) must be of type string, array given, called in /vendor/craftcms/cms/src/fields/PlainText.php on line 166 and /vendor/craftcms/cms/src/helpers/StringHelper.php:1983

Craft CMS version

Solo 5.0.3

PHP version

8.2.17

Operating system and version

Linux 4.19.0

Database type and version

MariaDB 10.6.17

Image driver and version

Imagick 3.7.0

Installed plugins and versions

  • CKEditor 4.0.3
  • Element API 4.1.0
  • Feed Me 6.0.0
  • Minify 5.0.0-beta.2
  • SEO v5.0.0-rc1
@samdi samdi added the bug label Apr 10, 2024
@i-just
Copy link
Contributor

i-just commented Apr 10, 2024

Hi, thanks for reaching out! Could you please post the full stack trace for this error?

@samdi
Copy link
Author

samdi commented Apr 11, 2024

In admin page, I access a structure entry with this error: https://cldup.com/n20M4rtNN9.png
View the entry with this error: https://cldup.com/7gO0jMSBU7.png

@i-just
Copy link
Contributor

i-just commented Apr 11, 2024

Thanks! I can’t seem to replicate this issue. Any chance you could send your composer.json, composer.lock and database export to support@craftcms.com and point out the entry that is giving you this error?

@samdi
Copy link
Author

samdi commented Apr 12, 2024

Thanks for your info. I think if there is something wrong due to the changing the field type (table to plain text). The entry is saved the table data of the previous field type while the field type is plain text. In database table element_sites > content of all entries, the data of table field is still existing, for example.

{"col1":"Original title","col2":"Abc title"},{"col1":"Alternative title","col2":"XYZ title"}

Anyway, I deleted those entries. Do you think if the issue is due to changing the type of field and the old data exists in the element_sites > content?

@i-just
Copy link
Contributor

i-just commented Apr 12, 2024

Thanks for providing more info!

due to the changing the field type (table to plain text)

With that missing piece of information, I can replicate it straight away.

When you change the type of the field, Craft doesn’t alter your data in the database. In Craft 4, changing a Field Type could lead to a database column that stored this data to be altered, therefore leading to data loss. In Craft 5, content is stored in a json column, but data incompatibility can still occur. There’s a warning under the Field Type dropdown about potential data loss and the types that should be safe to switch to don’t have the warning icon next to them.

You can still change the Field Type to one with a warning, but issues like this can occur. You can use the resave command to fix this. You can use it to clear out the field value or change it to something else. For example, php craft resave/entries --section blog --type article --set table --to "=" --if-empty 0 will clear out the value of a field with a handle table for a section blog and entry type article.

I hope this helps!
I will close this now, but feel free to reach out if you run into any more problems.

@i-just i-just closed this as completed Apr 12, 2024
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

2 participants