Does Elgg have a limit to how much can be saved to a file at once?

So I have been using buttons for a few weeks now and im finally in a place where the save function 'works'. however before this time, I have worked on smaller files with maybe a single object being put into a text file. However, I recently upgraded that to the way it is supposed to be (which has MANY different objects which are sent) and it appears having more than 13 causes an interseting security error.

Fatal Error.

Redirect could not be issued due to headers already being sent. Halting execution for security.

This comes while using:

$GroupArray = elgg_get_entities(array(
'type' => 'group',
'order_by' => 'e.time_created desc',
'limit' => 14,
'pagination' => true,
'offset' => $Offset,

13 works with no issue, and the limit is supposed to be 0 for the final push. This loop is how I get all of my objects, and it prints out just a few texts lines based on the values it takes.

The save function I use is:


$file = new ElggFile();
$file->owner_guid = 5001;
$file->setFilename("All Reports " . $date . ".txt");


if ($file->exists()) {
system_message("Report Created (" . basename("All Reports " . $date . ".txt") . ")");
$bytes = $file->grabFile();
echo $bytes;
//try to send past memebers back to the report page and turn that into the next member difference


else {
register_error("Report (" . basename("All Reports " . $date . ".txt") . ") was not saved!");


I can confirm that lower numbers do in fact work, but anything above 13 causes this fatal error.

My Elgg Version is 1.8.

My question is essentially the title, and any help would be appreciated. 

  • To further explain my issue if it may help in any way, the issue appears to come from the save function which is echo $bytes. All the information seems to come up on the page as blue text above the fatal error shown. Yet due to my elgg version, it is allegedly the only way to actually save information, so it must be kept.

    To put it plainly, my code has no issue unless I directly open what should save, then proceeds to break. Otherwise it prints out the system message that everything saved correctly. At the same time, I have never had a successful file where it actually saves to the location it should, even without the fail error at the higher use number.

     I still cannot seem to figure out why it does this, so any help would be lovely.

  • You are outputting content before redirect headers are set, so you get the error. Why do you need to echo file contents in the action? 

  • I was under the impression that the echo is the way that the file would be able to be downloaded? I also was told get_download_url would work, but trying that gave me the indication that it may not be supported by 1.8.

    Besides the echo that im using to try and pull the save, is there another way? I havent completely phased out the get_download_url yet, but it does seem the errors I get from that were because of the lack of the function existing in this version.


    *Edit: Ignore the above, I misunderstood what you were saving.

    That seemed to have cleared the error, thank you very much! I didnt realize it would give me an issue if I put it before the redirect.

  • I am not sure if you are able to answer this question, but the below code should technically work, yet grab file specifically does not work.


    if ($file->exists()) {
    system_message("Report Created (" . basename($folderName) . ")");
    $bytes = $file->grabFile();
    // system_message($bytes);
    echo $bytes;

    Going by what I know, echoing the Grabfile variable should allow it to be saved locally, no?

    Whenever I begin the process, it completes successfully, but nothing is actually saved and im simply redirected back to the Forward(). Is grab file supposed to be automatic, or would it bring up some sort of prompt?

    Apologies but this being the final step of my plugin before I have finished the important bits, its odd that I am having so much issue doing this while the code is essentially correct, so any help is very appreciated.