Magento错误地报告内存限制

时间:2018-12-06 15:50:37

标签: magento magento2

我使用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

1 个答案:

答案 0 :(得分:2)

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

错误消息本身来自此处

#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数字)与该方法的逻辑不符。

更新:根据注释-32位版本的PHP整数溢出。