Problem/Motivation
The latest version of https://www.drupal.org/project/xls_serialization drops support for v1 of PhpOffice\PhpSpreadsheet which has a published security vulnerabilities (CVE-2024-45048 and CVE-2024-45046).
Batch exports using the xlsx / xls serializer provied by xls_serialization serialization now fail as setCellValueByColumnAndRow was dropped in v2.
This issue was originally reported as a deprecation but is now critical for using this module with the latest version of xls_serialization.
Steps to reproduce
- Enable xls_serialization
- Configure data export with xlsx format and batch mode
- Run batch - this will fail
Proposed resolution
Resolve code deprecation error (done and RTBC in MR27)
Consider use of conflict for lower version (not implemented in MR yet)
"conflict": {
"phpoffice/phpspreadsheet": "<1.23.0"
}
Original report below:
I searched quite a bit and can't find an existing issue for this. When I do an upgrade status scan, I get one error for this module:
Views Data Export, 8.x-1.3
Scanned on Wed, 09/20/2023 - 12:59
FILE:
web/modules/contrib/views_data_export/src/Plugin/views/display/DataExport.php
STATUS LINE MESSAGE
--------------------------------------------------------------------------------
Check manually 838 Call to deprecated method setCellValueByColumnAndRow() of
class PhpOffice\PhpSpreadsheet\Worksheet\Worksheet: 1.23.0
Use the setCellValue() method with a cell address such as
'C5' instead;, or passing in an array of [$columnIndex,
$row] (e.g. [3, 5]), or a CellAddress object.
--------------------------------------------------------------------------------
I've confirmed that that call is still there in the dev branch, and didn't immediately see any conditional indicating that this might be a call for backwards compatibility.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | views_data_export-3388703-MR27-19.patch | 683 bytes | mably |
Issue fork views_data_export-3388703
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
Comment #2
shubham_jain commentedComment #4
shubham_jain commentedHi, fixed the issue was causing because the parameters inside the setCellValueByColumnAndRow is now changed and they have to be defined in a new way. So, raised MR for that which fixes the issue. Please review and verify.
Comment #5
shubham_jain commentedComment #7
gngn commentedMR 27 worked for me, thank you.
Comment #8
godotislateThis actually caused an error on our project when used with Data export phpspreadsheet:
Error: Call to undefined method PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::setCellValueByColumnAndRow() in Drupal\views_data_export\Plugin\views\display\DataExport::processBatch() (line 838 of {...}/modules/contrib/views_data_export/src/Plugin/views/display/DataExport.php).That module has a composer dependency on
"phpoffice/phpspreadsheet": "^1 || ^2". View Data Export does not have a dependency on that library. It does have a dev-dependency on Excel Serialization, which has a dependency on"phpoffice/phpspreadsheet": "^1.26", but dev-dependencies of a dependency are not loaded by composer for the root project. In any case, there no constraints against loading 2.x of phpoffice/phpspreadsheet, whereWorksheet::setCellValueByColumnAndRow()has been removed.Added a suggestion to the MR for a more minimal diff.
Comment #9
ericgsmith commentedJust flagging that https://git.drupalcode.org/project/xls_serialization/-/commit/aace003203... was committed to xls_serialization so this looks like it will be needed for the next release.
Suggestion from @godotislate on the MR looks good to me
Comment #11
amanp commentedSuggested simplification applied. Please review
Comment #12
ericgsmith commentedTested MR27
Implementation of the change suggested by godotislate looks good and export using a batch now works as expected.
PHPStan error in pipeline as is per the pipeline on 8.x-1.x-dev so looks good to me.
Comment #13
ericgsmith commentedAs mentioned in #8 as there is no hard dependency on the lib version in this module there is a chance users could be running a very old version. (And as mentioned in 8, users could also already be on v2 where this fix is needed for the batch exports to work).
For reference the new method was introduced in version 1.23.0 https://github.com/PHPOffice/PhpSpreadsheet/blob/master/CHANGELOG.md#123...
It might be worth calling out in the release notes that users should check to see if they need to update PHPOffice/PhpSpreadsheet
Also not mentioned in this thread but related - the 1.x branch has the following CVEs so support for 2.x is very important to us:
Comment #14
godotislateIt might make sense to add this to composer.json:
See https://getcomposer.org/doc/04-schema.md#conflict.
Because of the CVEs, it might actually be be better to make that conflict constraint "<2.2.1", but that's possibly out of scope for this issue.
Comment #15
nitesh624MR27 worked for me also
Comment #16
nitesh624Hoping This should be committed soon as there is security issue mentioned in https://www.drupal.org/project/views_data_export/issues/3388703#comment-...
Comment #17
ericgsmith commentedBumping to critical since latest version of xls_serialization only supports v2 and we can't do batch exports without this patch now
Comment #18
ericgsmith commentedUpdating issue summary to reflect that now this is an error rather than a deprecation report
Comment #19
mably commentedUploaded a static patch for composer usage.
Comment #20
saganakat commentedThanks! MR27 worked for me.
Comment #21
crzdev commented+1 to RTBC! Thanks!
Comment #22
andriy khomych commentedI faced the same issue and the above patch works fine.
I guess, such cases should be covered with tests.
Comment #23
lfersoy commented+1 to RTBC! Thanks!
Comment #24
tokiPatch #19 worked for me here, thanks!
Comment #25
leducdubleuet commentedThis patch is working well and is now mandatory. Would be great to have a new version including it!
Thx
Comment #26
david.qdoscc commentedComment #27
david.qdoscc commentedLooks like this change has been implemented in the latest push to 8.x-1.x-dev so this patch is no longer required.
Comment #28
steven jones commentedYeah, sorry about that, I didn't appreciate that this issue was here. Thanks for all the effort though.
Comment #29
steven jones commentedI think @godotislate makes a great point in #14 and we should probably add that conflict section to our composer.json.
Comment #32
steven jones commentedAdded that section to 8.x-1.x. Thanks again everyone.