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

Problem making changes to Text format configuration with i18n #129

Open
eleven3 opened this issue Jan 3, 2024 · 8 comments
Open

Problem making changes to Text format configuration with i18n #129

eleven3 opened this issue Jan 3, 2024 · 8 comments

Comments

@eleven3
Copy link

eleven3 commented Jan 3, 2024

I am using the standard Filtered HTML text format in a Backdrop site (v 1.26.2, php 8.2x). This is on a development site running on my localhost, although the problem also exists with ckeditor4 on the live version of the same site.

When I click the Configure link in the dropdown next to Filtered HTML on /admin/config/content/formats, I consistently get an error message in watchdog:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 220 of {…}/modules/contrib/i18n/i18n_string/i18n_string.module).

The toolbars do appear and function correctly on the text fields where it is configured. However, it remains impossible to make changes to the configuration.

@argiepiano
Copy link

While I'm no expert on this module, this seems to be a problem with your configuration file i18n.settings.json. When i18n_string is enabled, it should write some information about allowed text formats to that file, automatically selecting the filter_fallback_format() format as translatable. Apparently this is missing in your installation.

As a quick fix, visit admin/config/regional/i18n/strings (you'll see a warning) and then click "Save". This should populate the missing configurations and should remove the warnings.

As to why this happened... I'm not sure. Maybe something went wrong during the installation of the string translation module.

The maintainer of this module may have more accurate insights.

@indigoxela
Copy link
Member

@eleven3 many thanks for your report, and @argiepiano many thanks for your quick and correct answer.

The first thing that comes to my mind: is the site (with this error) upgraded from Drupal 7 or is it a native Backdrop install.

Because it's not really clear to me, how $translatable_formats can end up unset. It gets set when enabling the module and when upgrading from D7.

In case, you didn't save the form yet (which is the correct fix), can you provide a screenshot from the form on /admin/config/regional/i18n/strings?

@eleven3
Copy link
Author

eleven3 commented Jan 8, 2024

This was a in a native Backdrop site, not an update from D7. I was able to solve the problem by enabling translation on one of the text formats at admin/config/regional/i18n/strings, as suggested by @Layrn in the backdrop forum.

Before that none of the text formats had had translation enabled and, as a result, none of them could be edited. But once one of them was enabled, then they all could be edited.

@laryn
Copy link
Member

laryn commented Jan 8, 2024

Thanks for filing this issue @eleven3!

@indigoxela Maybe adding a default in the config would solve this?
https://github.com/backdrop-contrib/i18n/blob/1.x-1.x/config/i18n.settings.json

EDIT: Nevermind, just saw this in the install, but unsure why it didn't work in this case:
$config->set('i18n_string.allowed_formats', array(filter_fallback_format()));

@indigoxela
Copy link
Member

Nevermind, just saw this in the install

@laryn right, that was the thing, that baffled me. How can that be NULL then... 🤔

Will do some more experiments.

@eleven3 glad, that you were able to solve it.

@indigoxela
Copy link
Member

indigoxela commented Jan 9, 2024

Some experiments, but still can't reproduce the problem.

On a fresh install, the i18n_string.allowed_formats config item is always present.

@laryn
Copy link
Member

laryn commented Jan 9, 2024

I was wondering if the fallback maybe changed after i18n_string was installed, but I just verified that you can't even disable (let alone delete) the fallback format...

@indigoxela
Copy link
Member

indigoxela commented Jan 9, 2024

@laryn it's not the format (or missing format) that caused the notices, it's the result of config_get('i18n.settings', 'i18n_string.allowed_formats'); that was apparently NULL.

It can be empty, but it can't be null - it's always an array.

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

4 participants