CSV Export Fatal error

By gregThomas - September 17, 2015

Hi s2smedia,

Are you're trying to export a lot of records in one go? I think the issue is that CMSB is running out of memory while attempting the export. The easiest way to resolve the problem is to increase the amount of memory CMSB is allowed to use from 128MB to 512MB. You can do this by changing line 172 of lib/init.php to this:

  umask(0);                             // use default permission on created files
  ini_set('open_basedir', null);        // PHP 5.3+ disable open_basedir restrictions (we also set this with php.ini for earlier php versions)
  if (!ini_get('suhosin.memory_limit')) { // don't increase memory if suhosin doesn't allow it (or script will die): http://www.hardened-php.net/suhosin/configuration.html#suhosin.memory_limit
    ini_set('memory_limit', '512M');            // raise memory limit (if allowed)
  }
  ini_set('magic_quotes_runtime', 0);   // disable magic_quotes_runtime (backslashes quotes in input)

This involves making a change to a core CMSB file, so ensure you've made a full backup of the site first, and you'll have to reimplement the change if you upgrade CMSB.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By s2smedia - September 17, 2015

now I get this error:

Fatal error: Maximum execution time of 30 seconds exceeded in XXXXXXXXX/csvExport.php on line 0

By Dave - September 22, 2015

Hi s2smedia, 

Basically you're hitting the memory and time limits that your server allows.  Without modifying the code, one option would be to export fewer records at a time, perhaps by using the search fields to export all records that matched one criteria and then another export for records matching remaining criteria (eg: active vs archived users).  

Depending on the server configuration, sometimes you can bypass some of the limits.  If you want to try bypassing the max execution time you can add this to the plugin (csvExport.php) before the line that says "DON'T UPDATE ANYTHING BELOW THIS LINE": 

// DON'T UPDATE ANYTHING BELOW THIS LINE

set_time_limit(60*2); // allow up to 2 minutes of execute time

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com