For building large files via Batch API, phpexcel_export() would overwrite any existing files and so the final product contained only the data of the last batch process.
Attached is a patch for some small changes to allow the appending of existing files.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | make-appending-files-optional-2332315-10.patch | 2.54 KB | ey |
| #8 | make-appending-files-optional-2332315-8.patch | 2.42 KB | ey |
| #2 | phpexcel-append_existing_files-2332315-2.patch | 1.74 KB | nerdacus |
Comments
Comment #1
wadmiraal commentedThank you, that seems like a very good idea.
Your patch does not apply, though. Could you re-roll it from a clean checkout ?
Comment #2
nerdacus commentedYeah, sorry. I was in a rush when I rolled it out. Here's a better one.
Comment #3
wadmiraal commentedComment #4
wadmiraal commentedSome tests are failing, but I am note sure why. Let me check.
Comment #5
wadmiraal commentedCommited to dev.
Comment #8
ey commentedI'm not sure if I had to open a new issue for that. If this is not the right place, I'll open a new issue.
The problem is, that we have some export functions with a static filename. Some of those filenames are fixed names like 'export.xlsx', and some of them are suffixed with the current date like 'export-2016-08-03.xlsx'. On both situations, if a user exports some data, then another or the same user wants to export same data again, the previously exported file would be still on the server and the data will be appended. This is not the intended output.
A more detailed case is that we allow users to select which data to export (using VBO or some custom forms). When the first user selects some data and exports them, it is all good. Then the second user comes and also selects some data to export, this time the selected data will be appended to the first user's data.
I have attached a patch, which makes the appending of the files optional, which should be set in the
phpexcel_exportfunction's$optionsarray like that:Please review the patch.
Comment #9
wadmiraal commentedI think that's a great idea. It makes sense to make this optional. However, this is no longer backward compatible, and would break sites that rely on the implicit appending. We would need to make sure that the $options['append'] value is TRUE by default. Could you have a look at it, and re-roll a patch?
Comment #10
ey commentedBefore this commit, none of the sites relied on the implicit appending, since there was no such feature. The first commit was already not backward compatible, which effectively broke my site, which also led me to write this patch to make it backward compatible again.
Whatever, for me it doesn't make any difference. I can adjust my existing code to set
array('append' => FALSE')to explicitly disable appending. But this won't fix other existing sites which also had been broken by the first commit #2332315-6: Append existing files.Attached is the re-rolled patch that makes the default value of $options['append'] as TRUE.
Please review.
Comment #11
wadmiraal commentedI don't see what you're talking about. This functionality was added more than a year ago, in 7.x-3.9. Which means that potentially 1000s of sites now rely on this behavior. I'm sorry if the release of this functionality broke your setup back then, but I don't see how that's relevant now.
Anyway, thanks for the patch. I'll check it ASAP.
Comment #13
wadmiraal commentedAll tests are green. Committed to dev, thanks.
Comment #14
ey commentedYes I didn't update the PHPExcel module over more then a year (it was still on 7.x-3.8). As far as I remember, back then I didn't have enough time to dig into that problem after the update and rolled it back to 3.8.
Anyways, I didn't meant to start a discussion. Everything is good, thanks for committing the patch :)