Hi,

When exporting certain webforms we're receiving the following fatal error during the batch process:

Recoverable fatal error: Object of class stdClass could not be converted to string in webform_exporter_excel_xlsx->add_row() (line 27 of /vagrant/docroot/sites/all/modules/webform/includes/exporters/webform_exporter_excel_xlsx.inc).

Upon further review this is caused by:

$value = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $value);

As there are some "values" that are arrays and objects. Notably the foreach loop kept failing when the current value is the node object of the node related to the webform.

Are node objects normally passed in the $data array? Or is this something we're not doing correctly?

Issue fork webform-2810653

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nathandentzau created an issue. See original summary.

pifagor’s picture

Status: Active » Needs review
StatusFileSize
new7.27 KB

check patch

nathandentzau’s picture

StatusFileSize
new3.75 KB

I don't think a complete refactor of this class is required. We can leverage some OOP principles here. See my patch.

liam morland’s picture

Why not just put an if statement around the preg_replace() instead of making a new method?

Even with this patch, when the $value is added to $output, there will be an object or array to string conversion, so I think the error will still happen

What are the steps to reproduce this problem? Is anyone else seeing this?

liam morland’s picture

Status: Needs review » Needs work

Should "UTF-A" be "UTF-8"?

pifagor’s picture

Status: Needs work » Needs review

The last submitted patch, 2: webform-2810653-2.patch, failed testing. View results

liam morland’s picture

Status: Needs review » Needs work

Thanks for the patches.

@pifagor Your patch needs to be re-rolled so that it applies and passes testing. Can you explain why you prefer it to the approach in #3?

@nathandentzau If you would like your patch to move ahead, please reply to the comments I made about it.

nicxvan’s picture

Reroll for 4.23

Nishant2312 made their first commit to this issue’s fork.

liam morland’s picture

Status: Needs work » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.