When exporting a table, the row after the table headers is the caption (doesn't matter if it's empty or not) that comes as a string and this is adding a warning on the CSV.

Ex:

"Program name","Program code","Start time"
<b>Warning</b>:  fputcsv() expects parameter 2 to be array, string given in <b>/docroot/modules/contrib/tablefield/src/Controller/TablefieldController.php</b> on line <b>70</b><br />
"Advanced Communication for Professionals",ACP1.1,"9  a.m."
"Advanced Ergonomic Studies",AES1.1,"9 a.m."
"Advanced Filmmaking",AF2.1,"2 p.m."

So I've added a simple patch that checks if the row is an array before inserting it in the CSV as fputcsv expects an array.

Comments

bbombachini created an issue. See original summary.

bbombachini’s picture

StatusFileSize
new646 bytes
bbombachini’s picture

Status: Active » Needs review
lolandese’s picture

Status: Needs review » Reviewed & tested by the community
martin@martin-XPS-13-9370 /var/www/html/brown.localhost/web/modules/tablefield (8.x-2.x=) $ git apply -v table_export_error_fputcsv_3093269-1.patch
Checking patch src/Controller/TablefieldController.php...
Applied patch src/Controller/TablefieldController.php cleanly.

The patch solves the issue. The PHP warning does not occur anymore.

  • lolandese committed 41dfe4c on 8.x-2.x authored by bbombachini
    Issue #3093269 by bbombachini: Table export error "fputcsv() expects...
lolandese’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for both reporting and solving this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.