Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2008-12-01 21:22:29

gerhard01
Plugin Author
Registered: 2006-12-07
Posts: 108

Re: yab_download

php-setup or plugin-related anomaly?:

When I try to download my file list (40 files à 30 KB each) as zip, I get the following error message:

Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 1039468 bytes) in /home/www/www /textpattern/lib/txplib_misc.php(570) : eval()'d code on line 429

Thanks a lot!

Last edited by gerhard01 (2008-12-01 21:22:45)

Offline

#14 2008-12-01 21:32:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: yab_download

gerhard01 wrote:

Allowed memory size of 10485760 bytes exhausted

Dammit, why do I feel I’ve opened a massive can of worms for poor trenc… sorry.

(Stef slinks away into the distance)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#15 2008-12-02 10:45:54

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 573
Website GitHub

Re: yab_download

gerhard01 wrote:

Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 1039468 bytes) in /home/www/www/textpattern/lib/txplib_misc.php(570) : eval()’d code on line 429

This is a limit of your php setup by your hosting provider.
In your php.ini is a line

memory_limit = 10M

which alllows a php script a max memory usage of 10MB.
And the on-the-fly-creation of the zip of your related files will consumes nearly 11MB. So this is not allowed by the php settings.

Possible workarounds:

  1. Try to change the entry in your php.ini. But most hosters will prevend this. Or better: Ask them to increase the memory limit, but note: If you will zip sometimes more and/or bigger files so you need more allocated memory than 11MB or 12 MB.
  2. Try to set the memory limit in the plugin code by yourself. Copy the following line at the top of the plugin code. But this overwriting of the php.ini-settings will not work on most hostings:
ini_set("memory_limit","12M");

Methods I prefer:

  1. Try to organize your files so you will have less files per category.
  2. Don’t offer the zip download for files those will consume more memory than allowed.

Bloke wrote:

Dammit, why do I feel I’ve opened a massive can of worms for poor trenc… sorry.

No, no Stef! The more I write plugins, the more the possible problems, the more I learn about programming. :)

Offline

#16 2008-12-02 13:18:19

gerhard01
Plugin Author
Registered: 2006-12-07
Posts: 108

Re: yab_download

Try to set the memory limit in the plugin code by yourself.
ini_set("memory_limit","12M");

That worked – great! Thanks!

Methods I prefer:

  1. Try to organize your files so you will have less files per category.
  2. Don’t offer the zip download for files those will consume more memory than allowed.

IMHO, the zip-option is especially useful if you have a lot of files, where your plugin is extremely useful for downloading them all with a single click. Few files – less need for a zip option.

So I will test now my provider’s memory limit ;-).

Last edited by gerhard01 (2008-12-02 13:20:23)

Offline

#17 2008-12-21 12:04:59

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 573
Website GitHub

Re: yab_download

Small update to v0.4: The consumed memory of the zipfile-creation should be decreased (by half) now.

Offline

#18 2009-01-08 13:26:28

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 573
Website GitHub

Re: yab_download

New update to v0.5:
If you have zip creation enabled and you are running a php version 5.2.0 or above then the zip will now be created on harddisk, so the plugin is able to zip many and big files without exhausting memory.
If you are running a php version 5.2.0 or above and you have trouble with some restrictions (safe_mode, open_basedir etc.) so you can force the zip creation in memory (as in plugin version 0.4) with zip="2" instead of zip="1".

Offline

#19 2009-01-08 14:28:47

gerhard01
Plugin Author
Registered: 2006-12-07
Posts: 108

Re: yab_download

New update to v0.5:

Thanks for the update!

However,

<txp:yab_download label1="title" label3="Do it!" label4="zip file" size="KB" cats="files" sort="filename desc" zip="1" zipname="files.zip" />

on my page just resulted in http://article-page#yab_cd_download though I use the tag just once in this article-page. The very same tag and attributes did work with version 0.4.

Last edited by gerhard01 (2009-01-08 15:51:59)

Offline

#20 2009-01-08 16:18:49

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 573
Website GitHub

Re: yab_download

Oh sorry Gerhard,

was my fault: It was a my php4-hack of class constant call, which won’t worked.
I’ve reupped the the corrected version 0.5, please download and install it again!

Sorry for that! :(

Offline

#21 2009-01-09 07:53:16

gerhard01
Plugin Author
Registered: 2006-12-07
Posts: 108

Re: yab_download

reupped the the corrected version 0.5

Thanks a lot for the quick fix – works like a charm.

Offline

#22 2009-11-16 03:30:25

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: yab_download

Hi Tommy,

Nice plugin!

I’m interested in the ZIP file download functionality but want to present the list of individual files separately. A couple of additional options to slim down the output, so that only a download button is output, would be great:

1) Suppress output of the select list markup (it is possible use some CSS to hide it but it would be nice to not to have to do this).
2) An option to not present the zip download checkbox (i.e. the plugin assumes that the box is ticked)
3) An option to escape special characters in the select list (some of my file descriptions have ampersands which are not output as &amp;)

Thanks,

Adi

Offline

#23 2009-11-16 12:02:28

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 573
Website GitHub

Re: yab_download

Hi Adi,

your request is solved – at least I think so – by the new yab_download_v0.6:

  • bugfix: filenames and filedescriptions are now correctly escaped
  • added: new attribute ‘hidelist’ hides the file selection list
  • added: new attribute ‘hidezip’ hides the download-as-zip checkbox

Offline

#24 2009-11-16 23:32:29

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: yab_download

trenc wrote:

your request is solved – at least I think so

Tommy, you’re most kind. It works great … if there’s only one instance on the page. If there’s more than one (& I’m using unique formid) all download buttons download the first ZIP file!

Adi

Offline

Board footer

Powered by FluxBB