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.

Comments

wadmiraal’s picture

Status: Active » Postponed (maintainer needs more info)

Thank you, that seems like a very good idea.

Your patch does not apply, though. Could you re-roll it from a clean checkout ?

nerdacus’s picture

StatusFileSize
new1.74 KB

Yeah, sorry. I was in a rush when I rolled it out. Here's a better one.

wadmiraal’s picture

Status: Postponed (maintainer needs more info) » Needs review
wadmiraal’s picture

Status: Needs review » Needs work

Some tests are failing, but I am note sure why. Let me check.

wadmiraal’s picture

Status: Needs work » Fixed

Commited to dev.

  • wadmiraal committed ae1dec1 on 7.x-3.x
    Issue #2332315 by nerdacus, wadmiraal: Allow appending data to an...

Status: Fixed » Closed (fixed)

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

ey’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new2.42 KB

I'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_export function's $options array like that:

phpexcel_export($header, $data, $path, array('append' => TRUE);

Please review the patch.

wadmiraal’s picture

Status: Needs review » Needs work

I 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?

ey’s picture

Before 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.

wadmiraal’s picture

Status: Needs work » Needs review

I 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.

wadmiraal’s picture

Status: Needs review » Fixed

All tests are green. Committed to dev, thanks.

ey’s picture

Yes 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 :)

Status: Fixed » Closed (fixed)

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