Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 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);
 }
 public function testCheckPhpSettingsMemoryLimitError()
 {
     $this->dataSize->expects($this->any())->method('convertSizeToBytes')->willReturnMap([['512M', 512], ['756M', 756], ['2G', 2048]]);
     $rawPostMessage = 'Your current PHP memory limit is 512M.
              Magento 2 requires it to be set to 756M 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.';
     $expected['memory_limit'] = ['message' => $rawPostMessage, 'error' => true, 'warning' => false];
     $this->assertEquals($expected, $this->phpReadinessCheck->checkMemoryLimit());
 }
Exemplo n.º 4
0
 /**
  * @dataProvider getConvertSizeToIntegerDataProvider
  * @backupStaticAttributes
  * @param string $value
  * @param int $expected
  * @return void
  */
 public function testConvertSizeToInteger($value, $expected)
 {
     $this->assertEquals($expected, $this->dataSize->convertSizeToBytes($value));
 }