Problem/Motivation
When enabling block_class module, if the language module is already enabled and a new language installed (french in my case), drush outputs the message "In TranslatableMarkup.php line 132: $string ("") must be a string".
Version 2.0.0 does not produce this error.
The error message seems to be generated because the LocaleConfigManager.php (line 178) receives a boolean value to translate (instead of a string)
Some configuration info
- Drupal 9.4.5
- PHP 8.1
- Drush 11.1.1
- Install profile minimal
- Linux OS
Steps to reproduce
Drupal was installed with the following commands:
- composer create-project drupal/recommended-project:^9 /var/www/html
- composer require drush/drush
- composer update
- drush site:install minimal […]
Installing block_class was done with the following commands:
- drush pm:enable language
- drush language:add fr
- composer require drupal/block_class:2.0.2
- drush pm:enable block_class
Comments
Comment #2
renatog commentedThanks a lot for reporting @Zigazou. Let's take a look
P.S. Any patch or Merge requests from anyone is welcome 😊
Comment #3
zigazou commentedNotes:
Comment #4
zigazou commentedIt seems there is a conflict between types declared in block_class.schema.yml and types of values in block_class.settings.yml.
Here's a patch to be applied to block_class.settings.yml.
Comment #5
zigazou commentedComment #6
xaa commentedHi, Zigazou patch seems working fine. Thank you and weolcome on drupal.org.
Same issue here in the same context (update from 2.0.0 to 2.0.2 on Drupal 9.4.5 multilang). However block_class module was already enabled. I get the error in several places: when trying to install a theme (like Seven, Claro, Olivero) or when placing a block on
admin/structure/block/list/xx.Here is the full log
Comment #7
xaa commentedComment #8
anybodyI can confirm this issue. It appears when saving ANY block!
The patch in #4 sadly won't be able to fix this for existing installations! As confing/install/* files are only used at installation, not for existing installations!
So this also needs an update hook to correct values or a different solution.
Comment #9
anybodyComment #10
anybodyComment #11
anybodyRaising priority to critical as this affects any multilingual page and makes it impossible to save blocks!
Any maintainer plans how to fix this for existing installations? Can we safely downgrade to a prior version? Or did the DB schema change already?
Comment #12
anybodyAs written in #8 I guess that patch won't be able to solve this for existing installations.
But indeed the
block_class.settings.ymldata doesn't match well with types defined inblock_class.schema.yml!So a separate issue should be opened for that or this should be solved combined with this issue. But as written above, changing the
install/block_class.settings.ymlwill not change anything for existing installation! There it needs an additional update hook to correct values!The main issue here seems to be within
BlockClassHelperService.phparound$config->save();in line 212.To be honest, it looks very complicated to me what's done there and for example
$block_classes_storedis never used after line 193. I think the code in that area needs a closer look from a maintainer, despite this issue ;)Also I don't really understand why the config is saved several times, which is bad for performance, but I didn't look into this closer...
If commenting out the
$config->save();in line 213, the block saves fine, so I think the issue is in the$configthere, which would relate to the patch from #4 fixing this for fresh installations.debugging returns the following result:
I couldn't find a clear issue in this array, but we must be close to the root cause here.
So until someone fixes this cleanly, commenting out the
$config->save();in line 212 allows you to save the block.That's enough for me here, over and out ;)
Comment #13
renatog commentedSo updating the issue status to needs works
Comment #14
renatog commentedBased on #12 attaching a patch with the workaround
This isn't the final fix, but can help someone until the final fix
Comment #15
maxmendez commentedThe original error seems to be provocate by filter_html_clean_css_identifier = FALSE on config/install/block_class.settings.yml, i've been upgrading from 2.0.0 to 2.0.2 and change manually that line to test and the problem apararently disapeare.
So i think the patch #4 could fix the problem.
Comment #16
anybodyIf that's the case, can anyone tell me, why a config file from
config/install/affects existing installations?I'd still expect this needs an update hook or is there any "magic" in the module?
So to resolve this, the maintainer and community should please
Comment #17
maxmendez commentedI think config/install/ is used as base by system while the yml file does not exists as a file in the file system only in the database. That theory applies in my case.
I don´t know if config/install/ is always use by system when individual block settings are manage or when translations are updated.
Comment #18
demon326 commentedSo that is the cause of the error that has having me running around in circles. It was driving me crazy that i could not find the error.
I'm not sure if it means anything, but running 2.0.2 on a backup database does NOT give the issue. The backup is about a day before i upgraded to 2.0.2.
Comment #19
vvs commentedpatch #14 is ok
Comment #20
anybody#14 is not okay and just a workaround that should not be used in production! Please don't RTBC such!
Comment #21
joseph.olstad2.x crashes for me on 9.4.5
so I downgraded to 1.x , everything is good on 1.x
Comment #23
renatog commentedNew version 2.0.3 released with the fix
$ composer require 'drupal/block_class:^2.0'Thank you so much everyone for your contribution
Comment #24
Zsuffa Dávid commented2.0.3 works for me. All blocks can be saved now. Thank you!
Drupal 9.4.5
PHP 8.1.8
Comment #25
renatog commented@zsuffad I'm happy to know that 😊
Thank you so much, zsuffad. Have a great day