• Resolved philiprabbett

    (@philiprabbett)


    Hi,

    I have a CSV import script running via server cron but Wordfence seams to be causing issues with it. PHP-cli has an unlimited memory_limit => -1 however with Wordfence enabled, this is restricted to 128MB.

    I think I’ve tracked it down to line 38 of wordfence.php where you cast the memory limit to an int.

    
    if((int) @ini_get('memory_limit') < 128){
        if(strpos(ini_get('disable_functions'), 'ini_set') === false){
    	@ini_set('memory_limit', '128M'); //Some hosts have ini set at as little as 32 megs. 64 is the min sane amount of memory.
        }
    }
    

    In my case, -1 is less than 128, theoretically and and thus Wordfence sets a new limit which in turn actually restricts it.

    Should there not be an additional check here to see if the memory_limit is -1 or if the current server api is cli php_sapi_name() !== 'cli'

Viewing 1 replies (of 1 total)
  • Hi @philiprabbett,

    I think that code snippet is from an older version of Wordfence.

    This was an issue in the past, but has since been fixed (Internal Ref: #FB7049).

    Can you update or reinstall your version of Wordfence?
    The code that should appear is as follows:

    $maxMemory = @ini_get('memory_limit');
    $last = strtolower(substr($maxMemory, -1));
    $maxMemory = (int) $maxMemory;
    
    if ($last == 'g') { $maxMemory = $maxMemory * 1024 * 1024 * 1024; }
    else if ($last == 'm') { $maxMemory = $maxMemory * 1024 * 1024; }
    else if ($last == 'k') { $maxMemory = $maxMemory * 1024; }
    
    if ($maxMemory < 134217728 /* 128 MB */ && $maxMemory > 0 /* Unlimited */) {

    Dave

Viewing 1 replies (of 1 total)
  • The topic ‘Wordfence Memory Limit’ is closed to new replies.