Closed (fixed)
Project:
ZipCart
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Jul 2011 at 01:59 UTC
Updated:
6 Feb 2013 at 08:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
xurizaemonThis patch extracted from the one submitted by Matthias on #1226582: Anonymous users not able to add items to cart via AJAX.
Comment #2
xurizaemon@Matthias, can you tell why you removed the by reference ampersand from zipcart_filterzip()?
(
function zipcart_filterzip(&$files)=>function zipcart_filterzip($files)).I recall that originally this was intended to allow custom site code to require the addition or removal of certain files on add to cart. However, it seems like the reference isn't required with the module as it is. Would be good to know if that was changing or breaking how things worked on your site, or if you just removed it as cleanup because it wasn't necessary?
Comment #3
Matthias Lersch commentedIt was the basic problem but more related to #1144436: Block's download count doesn't remain on page refresh.
There is a PHP-warnings if you add somthing to the cart:
Warning: Parameter 1 to zipcart_filterzip() expected to be a reference, value given in module_invoke_all()
as a result the return value of $files = module_invoke_all('filterzip', $files) in zipcart_add_file_to_cart() is empty.
Comment #4
xurizaemonThanks for that, I committed the related change in #1144436.
For portability I suggest we use file_get_mimetype() instead of 'application/zip' as per this new patch - that way we get the correct mime type for the generated filename, and no changes are required if a new archive method is implemented (eg for tgz).
Comment #5
Matthias Lersch commentedfile_get_mimetype() is a good Idea.
for me the patch works fine now
Comment #6
ckngSince this is somewhat related, my suggestion to further improvement is to refactor the code to have
- a #1233304: Reusable file transfer function
- #1233302: User definable download filename
- register_shutdown_function to call a hook to indicate download completion (download counter) and clean up the temp file, #1233306: Hook for download completion
EDIT: filed separate issues
Comment #7
xurizaemonCommitted: 96627c15 / 3ae117c.