- Issue created by @Alen Simonyan
- @alen-simonyan opened merge request.
- last update
almost 2 years ago 30,341 pass - Status changed to Postponed: needs info
over 1 year ago 10:08am 12 December 2023 - 🇳🇱Netherlands Lendude Amsterdam
Thanks for reporting this.
Do you have some steps to reproduce this on a clean Drupal install? Usually this is a symptom of a problem further up and just adding some checks is just hiding the real problem
- 🇦🇲Armenia Alen Simonyan
Hi @Lendude,
I diddn't manage to reproduce this on fresh install yet.
- 🇧🇪Belgium seutje Antwerp
I also ran into this issue. The MR linked above fixed it for 9.x, but failed to apply when I upgraded to 10.x, so I rerolled it, but I changed it to fall back on
$this->options['content']
Unfortunately, I have no clue what the cause is, so I cannot provide any more information... I have a strong suspicion it's being caused by a control module, as I only experience this issue with 1 specific project.
I encountered the same error and implemented a temporary fix, which needs review. The issue arises because $this->options['content'] is expected to be an array but can sometimes be a string.
Here’s the patch I applied to web/core/modules/views/src/Plugin/views/area/Text.php:
/** * {@inheritdoc} */ public function preQuery() { // Normalize $this->options['content'] to ensure it's an array. if (is_string($this->options['content'])) { // If it's a string, treat it as the content value with a default format. $this->options['content'] = [ 'value' => $this->options['content'], 'format' => filter_default_format(), ]; } // Proceed as normal with the now-normalized content array. $content = $this->options['content']['value']; // Check for tokens that require a total row count. if (str_contains($content, '[view:page-count]') || str_contains($content, '[view:total-rows]')) { $this->view->get_total_rows = TRUE; } }
- 🇳🇱Netherlands Lendude Amsterdam
$this->options['content'] is expected to be an array but can sometimes be a string
@lance lancelot Have you been able to pin down when or why this would be the case? We still need steps to reproduce this on a fresh Drupal install since as it stands currently, the error might just be the correct way to handle this because there is something wrong upstream.
The error occurred after upgrading from Drupal 9 to Drupal 10. To investigate, I exported the configuration files and searched for occurrences of 'content:' strings.
For example, could the following configuration in views.view.comments_recent.yml be causing the error?
label: 'Recent comments' description: 'Recent comments.' display: default: display_title: Default display_options: title: 'Recent comments' fields: changed: settings: future_format: '@interval hence' past_format: '@interval ago' empty: area_text_custom: content: 'No comments available.' # Could this be the source of the problem? block_1: display_title: Block display_options: block_description: 'Recent comments' block_category: 'Lists (Views)'
I’m not entirely sure, but could the content: 'No comments available.' string format be causing the issue? Should it now be structured as:
content: value: 'No comments available.' format: 'plain_text'
Is this new format required in Drupal 10, and if so, was this change documented? I’d appreciate any clarification or guidance regarding this.
- 🇩🇪Germany alxn
I just encountered this issue with Drupal 10.3.10 and Workbench 1.6 and can confirm that the error is resolved after changing the content structure in the relevant configuration to:
content: value: '<h3>Example</h3>' format: 'basic_html'
I noticed that the following warning was issued during the configuration import with the structured content:
[warning] Array to string conversion StatementWrapperIterator.php:113
- 🇺🇸United States smustgrave
Before closing out anyone able to add concrete steps?
Got the same problem on a watchdog view in a drupal 10 upgraded from 9.
After exporting configuration from that view and compared with one coming from a new drupal 10, I found this difference :empty: area: id: area table: views field: area relationship: none group_type: group admin_label: "Aucune entrée du journal n'est disponible." plugin_id: text empty: true content: "Aucune entrée du journal n'est disponible." tokenize: false
from the old
empty: area: id: area_text_custom table: views field: area_text_custom relationship: none group_type: group admin_label: "Aucune entrée du journal n'est disponible." plugin_id: text_custom empty: true content: "Aucune entrée du journal n'est disponible." tokenize: false
from the new.
Re-importing the view config with only this difference make it works.