/**
  * Checks php memory limit
  * @return array
  */
 public function checkMemoryLimit()
 {
     $data = [];
     $warning = false;
     $error = false;
     $message = '';
     $minimumRequiredMemoryLimit = '756M';
     $recommendedForUpgradeMemoryLimit = '2G';
     $currentMemoryLimit = ini_get('memory_limit');
     $currentMemoryInteger = intval($currentMemoryLimit);
     if ($currentMemoryInteger > 0 && $this->dataSize->convertSizeToBytes($currentMemoryLimit) < $this->dataSize->convertSizeToBytes($minimumRequiredMemoryLimit)) {
         $error = true;
         $message = sprintf('Your current PHP memory limit is %s.
              Magento 2 requires it to be set to %s or more.
              As a user with root privileges, edit your php.ini file to increase memory_limit. 
              (The command php --ini tells you where it is located.) 
              After that, restart your web server and try again.', $currentMemoryLimit, $minimumRequiredMemoryLimit);
     } elseif ($currentMemoryInteger > 0 && $this->dataSize->convertSizeToBytes($currentMemoryLimit) < $this->dataSize->convertSizeToBytes($recommendedForUpgradeMemoryLimit)) {
         $warning = true;
         $message = sprintf('Your current PHP memory limit is %s.
              We recommend it to be set to %s or more to use Setup Wizard.
              As a user with root privileges, edit your php.ini file to increase memory_limit. 
              (The command php --ini tells you where it is located.) 
              After that, restart your web server and try again.', $currentMemoryLimit, $recommendedForUpgradeMemoryLimit);
     }
     $data['memory_limit'] = ['message' => $message, 'error' => $error, 'warning' => $warning];
     return $data;
 }
Beispiel #2
0
 /**
  * Get max upload size
  *
  * @param string $configuredLimit
  * @return int
  */
 private function _getMaxUploadSize($configuredLimit)
 {
     $maxIniUploadSize = $this->_fileSize->getMaxFileSize();
     if ($configuredLimit === null) {
         return $maxIniUploadSize;
     }
     $maxUploadSize = $this->dataSize->convertSizeToBytes($configuredLimit);
     return min($maxUploadSize, $maxIniUploadSize);
 }
Beispiel #3
0
 /**
  * @dataProvider getConvertSizeToIntegerDataProvider
  * @backupStaticAttributes
  * @param string $value
  * @param int $expected
  * @return void
  */
 public function testConvertSizeToInteger($value, $expected)
 {
     $this->assertEquals($expected, $this->dataSize->convertSizeToBytes($value));
 }