【问题标题】:Magento incorrectly reporting memory limitMagento 错误地报告内存限制
【发布时间】:2018-12-07 07:15:04
【问题描述】:

我使用 xampp 在 Windows 10 中安装了 Magento 2.3。我正在尝试通过运行来设置我的 cron 作业

php bin\magento setup:cron:run

我得到了错误

setup-cron: Please check var/log/update.log for execution summary

当我查看 update.log 时,我看到以下两个错误

[2018-12-06 15:44:37] setup-cron.ERROR: Your current PHP memory limit is 2048M. 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. [] []
[2018-12-06 15:44:37] setup-cron.ERROR: Could not locate magento/magento2-base/composer.json file. [] []

对于第一个错误,为什么即使我的内存限制高于所需的内存限制,我也会收到错误消息?

对于第二个错误,我应该做些什么来创建magento2-base 目录吗?我的 Magento 主目录(名为 magento23)中没有该目录?

这是php -i 的缩写输出,其中包含memory_limit

Core

PHP Version => 7.2.12

Directive => Local Value => Master Value
allow_url_fopen => On => On
allow_url_include => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => C:\xampp\php\extras\browscap.ini => C:\xampp\php\extras\browscap.ini
default_charset => UTF-8 => UTF-8
default_mimetype => text/html => text/html
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => STDOUT => STDOUT
display_startup_errors => On => On
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => Off => Off
enable_post_data_reading => On => On
error_append_string => no value => no value
error_log => C:\xampp\php\logs\php_error_log => C:\xampp\php\logs\php_error_log
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
expose_php => On => On
extension_dir => C:\xampp\php\ext => C:\xampp\php\ext
file_uploads => On => On
hard_timeout => 2 => 2
highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => C:\xampp\php\PEAR => C:\xampp\php\PEAR
input_encoding => no value => no value
internal_encoding => no value => no value
log_errors => On => On
log_errors_max_len => 1024 => 1024
mail.add_x_header => Off => Off
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
max_input_vars => 1000 => 1000
memory_limit => 2048M => 2048M
open_basedir => no value => no value
output_buffering => 0 => 0
output_encoding => no value => no value
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 4096K => 4096K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => GP => GP
sendmail_from => no value => no value
sendmail_path => no value => no value
serialize_precision => -1 => -1
short_open_tag => Off => Off
SMTP => localhost => localhost
smtp_port => 25 => 25
sys_temp_dir => no value => no value
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => C:\xampp\tmp => C:\xampp\tmp
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => GPCS => GPCS
windows.show_crt_warning => Off => Off
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
zend.assertions => 1 => 1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.multibyte => Off => Off
zend.script_encoding => no value => no value

【问题讨论】:

  • 你能显示php -i的输出吗?
  • 我更新了问题。我还看到php -i 中有一行写着Zend Memory Manager =&gt; enabled 这会导致这种情况吗?
  • 不 - 但这条线可能:memory_limit =&gt; 2048M =&gt; 2048M
  • 打开加载的配置文件(ini文件),你应该看到memory_limit设置为2048M
  • 我投票结束这个问题,因为 Stack Overflow 是一个programming-related 问答网站。您的问题与编程无关。也许你应该把它发到magento.stackexchange.com 上?

标签: magento magento2


【解决方案1】:

这是一个非常奇怪的错误。

错误信息本身来自这里

#File: setup/src/Magento/Setup/Model/PhpReadinessCheck.php
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
    );
}

convertSizeToBytes住在这里

#File: vendor/magento/framework/Convert/DataSize.php
public function convertSizeToBytes($size)
{
    if (!is_numeric($size)) {
        $type = strtoupper(substr($size, -1));
        $size = (int)$size;

        switch ($type) {
            case 'K':
                $size *= 1024;
                break;

            case 'M':
                $size *= 1024 * 1024;
                break;

            case 'G':
                $size *= 1024 * 1024 * 1024;
                break;

            default:
                break;
        }
    }
    return (int)$size;
}

我最好/第​​一个猜测是 - 不知何故 - 在您的 memory_limit 值中有一些额外的字符(空格、不可见、非 ASCII 数字)与此方法中的逻辑不匹配。

更新:根据 cmets - 它是 32 位版本 PHP 的整数溢出。

【讨论】:

  • 我将内存限制更改为 1024M,它正在工作。会不会是 2048 * 1024 * 1024 溢出了int
  • @BenRubin 好眼力!这很有可能——但前提是您运行的是 32 位版本的 PHP。
  • 是的,我正在运行 32 位 PHP。这就是我在 xampp 网站上看到的全部内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-03
  • 1970-01-01
  • 2018-02-21
  • 1970-01-01
  • 1970-01-01
  • 2018-05-30
相关资源
最近更新 更多