CLI jobs not finished or broken (cron product feeds)

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

CLI jobs not finished or broken (cron product feeds)

Postby admin » Tue Nov 26, 2019 7:02 pm

hello, we just discovered an issue which breaks any CLI or mass operations on Virtuemart when it's run in unlimited memory mode via CLI or with memory_limit = -1

virtuemart automatically sets memory limit to 2GB even when a sitemap or other product feed export may need to up to 10GB of ram in special cases on large shops.

to fix this we are adding an automatic fix to OPC installer which updates:

administrator\components\com_virtuemart\helpers\config.php

original function:
Code: Select all
static function getMemoryLimitBytes(){
      static $mLimit;
      if($mLimit===null){
         $mL = ini_get('memory_limit');
         $mLimit = 0;
         if(!empty($mL)){

            if($mL < 0){
               $mLimit = 2;
               $u = 'G';
            } else {
               $u = strtoupper(substr($mL,-1));
               $ord = ord($u);
               //Just numbers
               if (($ord>=48)&&($ord<=57)) {
                  $mLimit = (int)($mL);
               } else {
                  $mLimit = (int)substr($mL,0,-1);
               }
            }

            if($mLimit>0){
               if($u == 'M'){
                  $mLimit *= 1048576;
               } else if($u == 'G'){
                  $mLimit *= 1073741824;
               } else if($u == 'K'){
                  $mLimit *= 1024;
               }

               $mTest = $mLimit - 5242880; // 5 MB reserve

               if($mTest<=0){
                  $m = 'Increase your php memory limit, which is much too low to run VM, your current memory limit is set as '.$mL.' = '.$mLimit.'B';
                  vmError($m,$m);
               }
            }
         }

         if($mLimit<=0) $mLimit = 2142240768;
         vmdebug('My Memory Limit in Bytes '.$mLimit);
      }

      return $mLimit;
   }



updated to:
Code: Select all
static function getMemoryLimitBytes(){
      static $mLimit;
      if($mLimit===null){
         $mL = ini_get('memory_limit');
         $mLimit = 0;
         if(!empty($mL)){

            if($mL < 0){
               $mLimit = 2;
               $u = 'G';
            } else {
               $u = strtoupper(substr($mL,-1));
               $ord = ord($u);
               //Just numbers
               if (($ord>=48)&&($ord<=57)) {
                  $mLimit = (int)($mL);
               } else {
                  $mLimit = (int)substr($mL,0,-1);
               }
            }

            if($mLimit>0){
               if($u == 'M'){
                  $mLimit *= 1048576;
               } else if($u == 'G'){
                  $mLimit *= 1073741824;
               } else if($u == 'K'){
                  $mLimit *= 1024;
               }

               $mTest = $mLimit - 5242880; // 5 MB reserve

               if($mTest<=0){
                  $m = 'Increase your php memory limit, which is much too low to run VM, your current memory limit is set as '.$mL.' = '.$mLimit.'B';
                  vmError($m,$m);
               }
            }
         }

         if($mLimit<=0) $mLimit = PHP_INT_MAX;
         vmdebug('My Memory Limit in Bytes '.$mLimit);
      }

      return $mLimit;
   }



which sets the memory limit to 2^64 bytes instead of 2GB.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Return to One Page Checkout for Virtuemart 3 on Joomla 3.x