Jump to content

[SOLVED ob_end_flush(); ] zip download problems... encoding gzip problem ? prestashop ?


Recommended Posts

hello,
I have some problem with my zip.
When a customer download them, the zip cannot be open directly with OS like windows, or even Mac OSX.

Indeed, when I make a diff between the zip downloaded & the initial one, when the zip pass through the php zip in prestashop, it is modified.


Maybe, it is "only" the webserver engine (apache, php)
But I disabled gzip compression, it is all the same.


Any ideas?

Btw, I have also a problem with "pure" text file download.
They seem to be reencoded as UTF8 and in some case it is annoying.

Link to comment
Share on other sites

I found something IMPORTANT.

I'm not sure the problem comes from a gzip encoding problem.
I tested and commented those lines:
- init.php line 12 : ob_start();
- get-file.php line 261 : ob_end_flush();

all the same.

so I basically opened the 2 differents zip files in notepad++

the corrupted one just contains an empty line at the beginning.
removing it drives to change the corrupted file into a safe one!


so, next step: how to remove this blank line (I mean a carriage return I guess) inside the downloaded file ???

Link to comment
Share on other sites

$mimeTypes in the qet-file.php file seems to be unuseful.
when I upload a zip through the admin product creation interface, it creates a kind of hash name for the filename
thus, the $mimeTypes is never filled by the right mimetype.

btw, replacing $mimeTypes by application/octet-stream in the header creation didn't drive to remove this blank line (but make my browser understand it is a zip, that is unuseful :P )

Link to comment
Share on other sites

tweaked, turned, changed around fgets(), around the rb option didn't change anything.

I also tried to find ALL whitespace before <? and after ?> .............. nothing found.

and I still have this annoying blank line !


I'm near to give up :-(

Link to comment
Share on other sites

Where you have:

header('Content-Disposition: attachment; filename="'.$filename.'"');
ob_end_flush();

$fp = fopen($file, 'rb');



you should have:

header('Content-Disposition: attachment; filename="'.$filename.'"');
ob_end_flush();
ob_end_clean();

$fp = fopen($file, 'rb');



there are a lot of includes in those php files & if things are not done correctly, without ob_end_clean(); the download could be corrupted.

Link to comment
Share on other sites

Where you have:

header('Content-Disposition: attachment; filename="'.$filename.'"');
ob_end_flush();

$fp = fopen($file, 'rb');



you should have:

header('Content-Disposition: attachment; filename="'.$filename.'"');
ob_end_flush();
ob_end_clean();

$fp = fopen($file, 'rb');



there are a lot of includes in those php files & if things are not done correctly, without ob_end_clean(); the download could be corrupted.




Thats just the thing. I did add ob_end_clean(); into my getfile.php
But still does not work for me.

Did you not see the ob_end_clean(); part in my getfile.php ?
Link to comment
Share on other sites

well the problem is still there.
I did double check it, and its just as you describe it should be, atleast that part.
I know how to copy and paste a code, and that it has to be just right, and it is, so beats me why it wont work.

Any tips?
How goes if someone test my file on their server?
in case, remember to backup yours first

Link to comment
Share on other sites

did you make a diff on your two file (the initial & the other one) ?


A diff?

If by that you ment checking my original file with the downloadet one, then yea, original works just fine, but as soon as I upload it, and run the downloadet version lateron, I get this problem.

If not, then I am unsure what diff is.
sorry, english not my main language.
Link to comment
Share on other sites

diff is an unix command.

did you try to open your two files in a text editor to compare them, especially the first line?

in my case, and without the added function I did, the first line was a blank line.
removing the blank line corrected the problem and thus, I understood where the cause was!

Link to comment
Share on other sites

Its a bug if you use 1.3.6 version.

To fix it just delete the last empty lines of those files

/classes/Cart.php
/classes/Currency.php
/classes/Customer.php
/classes/Meta.php
/classes/OrderDetail.php
/classes/Product.php



You my friend are a champion to say the least.
I have been in dispair because of this issue here.
Not so easy when you know almost next to nothing about stuff like this.

It now works like a charm :)
Link to comment
Share on other sites

Its a bug if you use 1.3.6 version.

To fix it just delete the last empty lines of those files

/classes/Cart.php
/classes/Currency.php
/classes/Customer.php
/classes/Meta.php
/classes/OrderDetail.php
/classes/Product.php


Perfect, Solved my problem for downloading virtual product (photos) in 1.3.6.

To solve the lack of Virtual Product download link email not sent along with Payment Accepted email no sent in 1.3.6 I had to rename OrderHistory.php to OrderHistory.php.1.3.6 and upload an older version or OrderHistory from 1.3.2.3
You can get 1.3.2.3 here: http://code.google.com/p/prestashop/downloads/list
Link to comment
Share on other sites

  • 4 months later...
Its a bug if you use 1.3.6 version.

To fix it just delete the last empty lines of those files

/classes/Cart.php
/classes/Currency.php
/classes/Customer.php
/classes/Meta.php
/classes/OrderDetail.php
/classes/Product.php

This didn't seem to work for me, but since I can't currently access the Bug Tracker (search isn't working on the new Bug Tracker), I'm not 100% confident I know what is needed.

Do I do the following?
Change classes/Cart.php:
    /* DEPRECATED */
   public function getCustomeremail()
   {
       $customer = new Customer(intval($this->id_customer));
       return $customer->email;
   }
}
[bLANK LINE HERE]



to:

    /* DEPRECATED */
   public function getCustomeremail()
   {
       $customer = new Customer(intval($this->id_customer));
       return $customer->email;
   }
}



That is, I take out the blank line (I couldn't represent it accurately using this bulletin board code).

The other .php files actually end with

?>

with a blank line just about that. Do I delete that blank line, or actually the

;>

?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...